[SC-17187] ZD-717: GINITable fails on multiclass models (follow-up to PR #535)#539
Open
juanmleng wants to merge 2 commits into
Open
[SC-17187] ZD-717: GINITable fails on multiclass models (follow-up to PR #535)#539juanmleng wants to merge 2 commits into
juanmleng wants to merge 2 commits into
Conversation
GINITable computed AUC/GINI/KS with binary-only sklearn calls against a single positive-class probability column, raising "multiclass format is not supported" on models with more than two classes. Add a one-vs-rest path that reads the full per-class probability matrix from the underlying estimator's predict_proba, one-hot encodes labels with label_binarize, and returns one row per class plus a micro-average. Binary behavior is unchanged; models without a usable predict_proba are skipped with SkipTestError instead of crashing. Add multiclass unit tests covering the per-class table and the skip path. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
Pull requests must include at least one of the required labels: |
Contributor
PR SummaryThis PR extends the functionality of the GINITable module by adding support for multiclass classification metrics. The key changes include:
Overall, these changes improve the library's capability to handle multiclass model evaluations while maintaining backward compatibility with binary classification scenarios. Test Suggestions
|
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.
Pull Request Description
What and why?
GINITable(validmind/tests/model_validation/statsmodels/GINITable.py) computed AUC/GINI/KS with binary-only sklearn calls (roc_curve,roc_auc_score) against a single positive-class probability column. On a model with more than two classes it raisedValueError: multiclass format is not supported.This adds a one-vs-rest path for multiclass models, mirroring the approach PR #535 used for the sklearn tests (ROCCurve, PrecisionRecallCurve, ConfusionMatrix, PopulationStabilityIndex). #535 fixed those four but did not touch
statsmodels.GINITable; this is the remaining follow-up.After this change:
micro-average row (with aClasscolumn). Per-class probabilities are read from the underlying estimator'spredict_proba, since theVMModelwrapper exposes only the positive-class column.SkipTestErrorinstead of crashing.How to test
Run the existing unit tests:
Or reproduce the original failure and confirm the fix directly (this is the snippet from the repro notebook used to validate the change):
Expected multiclass output:
What needs special review?
The multiclass path reads probabilities from the underlying estimator (
model.model.predict_proba) rather than theVMModelwrapper'sy_prob, because the wrapper returns only the positive-class column. Worth confirming this is the right access pattern (it matchesROCCurvefrom #535) and that theSkipTestErrorfallback covers the model types you expect (metadata-only / precomputed single-column probabilities).Dependencies, breaking changes, and deployment notes
Follow-up to #535. No breaking changes — binary output is unchanged.
Release notes
GINITable now supports multiclass classification models. For models with more than two classes it reports AUC, GINI, and KS one-vs-rest (one row per class plus a micro-average) instead of failing with
multiclass format is not supported. Binary models are unaffected.Checklist