Repository navigation
Fix unequal-fold PPI weighting - #13
Merged
Merged
Conversation
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.
Closes #11.
PPI now normalizes weights within each correction fold and averages the fold mean vectors equally, matching deployment imputation. The delta covariance sums the within-fold covariances and divides by the squared number of models. IWCV uses the same fold weighting, and effective sample size follows those normalized weights.
Bootstrap resampling preserves every correction fold. It samples rows or nested clusters within folds; clusters that span folds remain intact, and draws that omit a correction fold are redrawn. This keeps each replicate's imputation and correction on the same fixed-model target.
Direct cross-fit calls to
ppi_estimateandppi_macro_f1with multiple deployment models now requirefold_l.auditsupplies it automatically. Single-model calls retain their existing behavior.The issue's reproduction now returns accuracy 0.50 with a 95% interval of [0.448349, 0.551651], rather than 0.38 with an interval that excludes the truth.
The regression cases cover accuracy and pooled macro-F1 with unequal fold sizes, fold-specific inclusion weights, IWCV, delta variance, and row, nested-cluster and cross-fold-cluster bootstrap intervals. All 18 tests pass on Python 3.10 and 3.13 with pinned dependencies. Ruff lint passes, and a grouped audit with real logistic trainers produces identical bootstrap results for
n_jobs=1andn_jobs=2.The README revision is separate in #12. This PR changes only the estimator, pipeline and regression tests.