Commit 7975c30
* Add .worktrees/ to .gitignore
* Fix CausalRandomForestRegressor predicting inf from division by zero (#589)
Guard against zero treatment/control counts in CausalMSE and TTest
criterion functions. When a tree split creates a child node with no
treatment or no control observations, the variance formula
`var/count` produces infinity. Now skips impurity contribution for
that treatment group (zero impurity), preventing the splitter from
favoring degenerate splits.
Affected methods:
- CausalMSE.node_impurity()
- CausalMSE.children_impurity()
- TTest.children_impurity()
* Add regression test for inf predictions with sparse groups (#589)
Test that CausalRandomForestRegressor.predict() returns finite values
when imbalanced data causes zero-count treatment/control nodes.
* Add ttest criterion regression test for inf predictions (#589)
* Fix ttest criterion name: 'ttest' -> 't_test'
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 123cc1f commit 7975c30
2 files changed
Lines changed: 64 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
463 | 463 | | |
464 | 464 | | |
465 | 465 | | |
466 | | - | |
| 466 | + | |
| 467 | + | |
467 | 468 | | |
468 | 469 | | |
469 | 470 | | |
| |||
500 | 501 | | |
501 | 502 | | |
502 | 503 | | |
503 | | - | |
504 | | - | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
505 | 508 | | |
506 | 509 | | |
507 | 510 | | |
| |||
577 | 580 | | |
578 | 581 | | |
579 | 582 | | |
580 | | - | |
581 | | - | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
582 | 589 | | |
583 | 590 | | |
584 | 591 | | |
585 | 592 | | |
586 | | - | |
| 593 | + | |
587 | 594 | | |
588 | | - | |
589 | | - | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
590 | 599 | | |
591 | 600 | | |
592 | 601 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
0 commit comments