Influence diagnostics: dffits + influence masks (#27 batch 3) - #30
Merged
Conversation
Add 4 influence diagnostics following the established pattern:
- dffits_fit + pl_dffits: scaled per-row influence on fitted value.
- influential_cooks_fit + pl_influential_cooks: boolean mask of
observations above Cook's distance threshold (default 4/n).
- influential_dffits_fit + pl_influential_dffits: boolean mask of
observations above DFFITS threshold (default 2 * sqrt(p/n)).
- high_leverage_points_fit + pl_high_leverage_points: boolean mask
of observations with leverage > threshold (default 2*p/n). Takes
only X (no y).
Each fits OLS internally via fit_ols_for_residual_diag (except
high_leverage_points which only builds the design matrix).
Two new struct output schemas:
dffits_output_dtype{dffits: List<Float64>, n_observations}
influence_mask_output_dtype{is_influential: List<Boolean>,
n_influential, n_observations}
Python (exprs/regression.py): dffits, influential_cooks,
influential_dffits, high_leverage_points — all exported.
Tests:
tests/test_influence_diagnostics.py: 7 pytests covering shape and
detection of planted high-influence points (large DFFITS,
influential masks flag the planted indices, high_leverage_points
catches extreme x values, custom thresholds tighten/loosen masks).
tests/rust_api.rs: smoke tests in diagnostic_fits for all four
*_fit entry points.
Full Python suite: 448/448 pass (441 prior + 7 new).
Rust integration: 12/12 pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This was referenced May 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Batch 3 of 4 for #27. Adds 4 influence diagnostics as Polars expressions.
Implemented
All four follow the rlib split pattern (public
*_fit+pl_*shim). Each fits OLS internally via the sharedfit_ols_for_residual_diaghelper introduced in batch 1, excepthigh_leverage_pointswhich only builds the design matrix (no y needed).Tests
tests/test_influence_diagnostics.py, 7 new pytests:influential_cooksandinfluential_dffitsflag the planted indices.high_leverage_pointscatches extreme x values without taking y.tests/rust_api.rs: smoke tests indiagnostic_fitsfor all 4*_fitentry points.Full Python suite: 448/448 pass (441 prior + 7 new). Rust integration: 12/12 pass.
Remaining work on #27
Test plan
cargo build --no-default-featurescleancargo clippy --all-targets -- -D warningscleancargo fmt --checkcleancargo test --no-default-features— 12/12 passpytest— 448/448 pass🤖 Generated with Claude Code