Commit 490e35c
* Fix uplift tree p-value NaN from division by zero (#585)
When a tree node has zero treatment or control observations (n_t=0
or n_c=0), the p-value variance formula divides by zero, producing
NaN. Also guards against zero variance when all observations in a
group have the same outcome (p=0 or p=1). Returns p_value=1.0
(maximally non-significant) in these degenerate cases.
* Add edge-case test for p-value with sparse treatment groups
Test verifies predictions don't contain NaN when tree nodes have
zero treatment or control observations (min_samples_treatment=0,
heavily imbalanced groups).
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7975c30 commit 490e35c
File tree
2 files changed
+32
-1
lines changed- causalml/inference/tree
- tests
2 files changed
+32
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2095 | 2095 | | |
2096 | 2096 | | |
2097 | 2097 | | |
2098 | | - | |
| 2098 | + | |
| 2099 | + | |
| 2100 | + | |
| 2101 | + | |
| 2102 | + | |
| 2103 | + | |
| 2104 | + | |
| 2105 | + | |
2099 | 2106 | | |
2100 | 2107 | | |
2101 | 2108 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
365 | 365 | | |
366 | 366 | | |
367 | 367 | | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
0 commit comments