Bug fixes in GCM#1664
Conversation
|
🤖 This is an automated response from Repo Assist. Great work, One heads-up for maintainers: my PR #1662 ( A minor observation on the Looking forward to seeing this merged! 🎉
|
There was a problem hiding this comment.
Pull request overview
This PR addresses a broad set of correctness bugs in DoWhy’s GCM module (wrong results, crashes, and dtype edge cases) and adds targeted regression tests to prevent reintroductions.
Changes:
- Fix multiple silent wrong-result issues in sampling, bootstrap confidence intervals, entropy estimation, distribution-change scoring, and unit-change attributions.
- Harden several APIs against edge cases (empty-graph validation, single-player Shapley, categorical counterfactual abduction, NaNs in categorical detection, quantile input validation).
- Add/adjust regression tests covering each fixed scenario.
Reviewed changes
Copilot reviewed 33 out of 33 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/gcm/util/test_general.py | Adds regression test for informative error on categorical data with NaNs. |
| tests/gcm/test_whatif.py | Adds regression test for categorical-node counterfactual abduction error message. |
| tests/gcm/test_validation.py | Adds regression test for edgeless DAG refutation with FDR correction. |
| tests/gcm/test_unit_change.py | Adds regression test ensuring intercept differences are attributed in linear unit change. |
| tests/gcm/test_uncertainty.py | Updates entropy expectations and adds regression tests for small-range and constant data. |
| tests/gcm/test_stochastic_models.py | Adds regression test for spurious correlation avoidance in GMM sampling. |
| tests/gcm/test_stats.py | Adds regression test for quantile input validation error message. |
| tests/gcm/test_shapley.py | Adds regression test for single-player subset sampling Shapley. |
| tests/gcm/test_equation_parser.py | Adds tests for bayesiangaussianmixture mapping and positional arg parsing error. |
| tests/gcm/test_data_generator.py | Adds regression tests for zero-roots DAG generation and uniform noise std. |
| tests/gcm/test_confidence_intervals.py | Updates expected bootstrap CI bounds to correct two-sided percentiles. |
| tests/gcm/test_confidence_intervals_cms.py | Updates expected bootstrap CI bounds to correct two-sided percentiles. |
| tests/gcm/test_anomaly_scorers.py | Adds regression test for finite anomaly scores when MAD is zero. |
| tests/gcm/ml/test_classification.py | Adds regression test ensuring weighted classification clone preserves type/weights support. |
| dowhy/gcm/validation.py | Avoids FDR adjustment path on empty p-value lists. |
| dowhy/gcm/util/general.py | Fixes NaN-mask handling for multi-column categorical detection and raises clearer error. |
| dowhy/gcm/unit_change.py | Adds intercept support to linear mechanisms and attributes intercept deltas. |
| dowhy/gcm/uncertainty.py | Fixes discretization binning for small ranges; handles constant-data entropy. |
| dowhy/gcm/stochastic_models.py | Shuffles GMM samples to prevent spurious correlations between independently sampled nodes. |
| dowhy/gcm/stats.py | Tightens quantile validation to enforce (0, 1]. |
| dowhy/gcm/shapley.py | Fixes subset-sampling approximation for single-player case. |
| dowhy/gcm/model_evaluation.py | Fixes max_num_samples subsampling and categorical mode shape handling. |
| dowhy/gcm/ml/classification.py | Ensures weighted classifier clone returns weighted clone. |
| dowhy/gcm/influence.py | Fixes infinity check for results stored as Python list. |
| dowhy/gcm/independence_test/kernel_operation.py | Fixes per-column adaptive RBF distance computation; updates delta-kernel handling. |
| dowhy/gcm/equation_parser.py | Fixes bayesiangaussianmixture mapping; improves argument parsing and parent-name collision warning. |
| dowhy/gcm/distribution_change.py | Fixes early stopping logic to track convergence of running average. |
| dowhy/gcm/data_generator.py | Fixes zero-root DAG generation and corrects uniform noise std parameterization. |
| dowhy/gcm/confidence_intervals.py | Fixes percentile bootstrap CI bounds to use two-sided percentiles. |
| dowhy/gcm/causal_mechanisms.py | Prevents int32 overflow by using int64 in discrete ANM. |
| dowhy/gcm/auto.py | Fixes multiclass log_loss usage by passing explicit label set. |
| dowhy/gcm/anomaly_scorers.py | Avoids division-by-zero in MAD-based scorer by falling back to EPS. |
| dowhy/gcm/_noise.py | Raises clear error when noise cannot be recovered for non-invertible mechanisms. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fixes silent wrong-result bugs (GMM sampling correlation, bootstrap CI percentiles, distribution-change early stopping, unit_change intercept, adaptive RBF kernel incl. constant-column NaN, discretization entropy, uniform noise std, categorical mode collapse), crashes and dtype issues (multiclass log_loss, max_num_samples subsampling, is_categorical with NaN, int32 overflow, empty-graph refutation, quantile guard, single-player Shapley, zero-root DAG, positional eq-parser args), a wrong class mapping (bayesiangaussianmixture, weighted clone), and a dead warning. Also raises a clear error for categorical counterfactual abduction instead of a leaked AttributeError. Adds regression tests for each. Signed-off-by: Patrick Bloebaum <bloebp@amazon.com>
|
@emrekiciman any concerns left? |
fix(gcm): correct math/logic and robustness bugs across GCM Fixes silent wrong-result bugs (GMM sampling correlation, bootstrap CI percentiles, distribution-change early stopping, unit_change intercept, adaptive RBF kernel incl. constant-column NaN, discretization entropy, uniform noise std, categorical mode collapse), crashes and dtype issues (multiclass log_loss, max_num_samples subsampling, is_categorical with NaN, int32 overflow, empty-graph refutation, quantile guard, single-player Shapley, zero-root DAG, positional eq-parser args), a wrong class mapping (bayesiangaussianmixture, weighted clone), and a dead warning. Also raises a clear error for categorical counterfactual abduction instead of a leaked AttributeError. Adds regression tests for each. Signed-off-by: Patrick Bloebaum <bloebp@amazon.com>
fix(gcm): correct math/logic and robustness bugs across GCM Fixes silent wrong-result bugs (GMM sampling correlation, bootstrap CI percentiles, distribution-change early stopping, unit_change intercept, adaptive RBF kernel incl. constant-column NaN, discretization entropy, uniform noise std, categorical mode collapse), crashes and dtype issues (multiclass log_loss, max_num_samples subsampling, is_categorical with NaN, int32 overflow, empty-graph refutation, quantile guard, single-player Shapley, zero-root DAG, positional eq-parser args), a wrong class mapping (bayesiangaussianmixture, weighted clone), and a dead warning. Also raises a clear error for categorical counterfactual abduction instead of a leaked AttributeError. Adds regression tests for each. Signed-off-by: Patrick Bloebaum <bloebp@amazon.com>
Fixes silent wrong-result bugs (GMM sampling correlation, bootstrap CI percentiles, distribution-change early stopping, unit_change intercept, adaptive RBF kernel, discretization entropy, uniform noise std, categorical mode collapse), crashes and dtype issues (multiclass log_loss, max_num_samples subsampling, is_categorical with NaN, int32 overflow, empty-graph refutation, quantile guard, single-player Shapley, zero-root DAG, positional eq-parser args), a wrong class mapping (bayesiangaussianmixture, weighted clone), and a dead warning. Also raises a clear error for categorical counterfactual abduction instead of a leaked AttributeError. Adds regression tests for each.