Commit a3b35f3
committed
GH-16147: Detect classifier/regressor via MRO in __sklearn_tags__ on sklearn 1.8
On sklearn 1.8, ClassifierMixin/RegressorMixin no longer carry
`_estimator_type` — the type is exposed only via __sklearn_tags__.
Wrappers built by make_classifier / make_regressor add the matching
mixin to bases but use is_generic=False, so the dynamic __init__
doesn't take an `estimator_type` argument and the base wrapper never
records `_estimator_type` on the instance.
Result on sklearn 1.8: getattr(self, '_estimator_type', None) returns
None, super().__sklearn_tags__() returns BaseEstimator's defaults
(estimator_type=None), and the type-specific branches in our
__sklearn_tags__ override never fire. is_classifier(self) then returns
False, the params_as_h2o_frames decorator skips asfactor() on y, and
algorithms that only support binomial classification (e.g. AdaBoost)
end up training as regression and crashing in predict.
Add a final MRO-based fallback: if neither _estimator_type nor the
upstream tags expose the type, look for ClassifierMixin / RegressorMixin
in type(self).__mro__.1 parent 066cc0b commit a3b35f3
1 file changed
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
596 | 596 | | |
597 | 597 | | |
598 | 598 | | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
599 | 611 | | |
600 | 612 | | |
601 | 613 | | |
| |||
0 commit comments