Expose classes_/predict_proba on calibrated classifiers for global explainers - #813
Closed
Creylay wants to merge 1 commit into
Closed
Expose classes_/predict_proba on calibrated classifiers for global explainers#813Creylay wants to merge 1 commit into
Creylay wants to merge 1 commit into
Conversation
… SGD classifiers for sklearn compatibility
Member
|
This was already fixed by #812 . Closing this PR. |
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.
Summary
LinearSVCClassifierandSGDClassifiercalibrate probabilities via an internalCalibratedClassifierCV(self._calibrated) instead of fitting themselves, so they never exposedclasses_orpredict_probaon the wrapper instance. sklearn's inspection utilities (permutation_importance,partial_dependence) readestimator.classes_unconditionally on any object tagged as a classifier, so running a global explainer (Permutation Feature Importance, Partial Dependence) on either model crashed withAttributeError: '...Classifier' object has no attribute 'classes_'. Local explainers were unaffected since they callmodel.predict()directly, bypassing that machinery.Fix proxies
classes_andpredict_probafrom the internal calibrated model ontoself, so both models now work correctly with all explainers instead of just being blocked from using them.Type of Change
Check all that apply like this [x]:
Changes (by file)
DashAI/back/models/scikit_learn/linear_svc_classifier.py: addedclasses_property andpredict_probamethod that delegate to the internalCalibratedClassifierCV.DashAI/back/models/scikit_learn/sgd_classifier.py: same fix, same root cause.tests/back/explainers/test_explainers.py: added regression tests running Permutation Feature Importance and Partial Dependence against both calibrated classifiers.Testing (optional)
To verify manually:
Linear SVCorSGD Classifiermodel on any tabular classification dataset.AttributeError: '...Classifier' object has no attribute 'classes_'. It should now complete successfully.