Skip to content

Use fitted bins for automatic numerical PSI thresholds - #1118

Open
Swapnil-byte-798 wants to merge 1 commit into
feature-engine:mainfrom
Swapnil-byte-798:fix/psi-threshold-fitted-bins
Open

Swapnil-byte-798 wants to merge 1 commit into
feature-engine:mainfrom
Swapnil-byte-798:fix/psi-threshold-fitted-bins

Conversation

@Swapnil-byte-798

Copy link
Copy Markdown

What changed

For DropHighPSIFeatures(threshold="auto"), the chi-squared threshold used the requested number of bins even when equal-frequency discretization dropped duplicate quantile boundaries. Calculate the degrees of freedom from each feature's fitted bin edges.

Reproduction

With 100 rows in each split, change a binary-valued numerical score from 50% ones in the basis to 73% ones in the test split. Requests for two and ten bins both fit the same two bins and give PSI ≈ 0.229. The current threshold is ≈ 0.217 with bins=2 and ≈ 0.558 with bins=10, so only the former flags drift. Both requests now use ≈ 0.217.

The regression checks the numerical PSI, the feature selected for removal, and the transformed dataframe. The ten-bin case failed before the patch. All 177 tests in the focused PSI and discretization suites pass locally. Black and git diff --check pass.

The numerical bin-count calculation may also be relevant to the migration in #1089.

Codex assisted with reproduction, implementation, and tests.

Copilot AI balanced review requested due to automatic review settings November 6, 2026 07:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants