Skip to content

Use fitted bins for automatic numerical PSI thresholds - #1118

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

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.

@solegalli

Copy link
Copy Markdown
Collaborator

This PR looks like it was generated end to end by an AI coding agent, without a person reviewing the change. We prefer contributions with a human in the loop: someone who understands the problem, has checked that it is real, and can discuss the design and respond to review comments. AI assistance is fine, but the contributor needs to own the change.

This change needs discussion first. Please open an issue with a small worked example showing the problem that youa re trying to resolve, the PSI value, the threshold used today, and the one you think it should use.

I'm closing this PR for now. Thanks for the contribution!

@solegalli solegalli closed this Nov 18, 2026
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.

3 participants