[python-package] simplify scikit-learn 1.6+ tags support#6735
[python-package] simplify scikit-learn 1.6+ tags support#6735
Conversation
| tags.estimator_type = "regressor" | ||
| tags.regressor_tags = _sklearn_RegressorTags(multi_label=False) | ||
| return tags | ||
| return super().__sklearn_tags__() |
There was a problem hiding this comment.
This is necessary even though it doesn't do anything, because of this check in scikit-learn:
E TypeError: Estimator LGBMRegressor has defined either
_more_tagsor_get_tags, but not__sklearn_tags__. If you're customizing tags, and need to support multiple scikit-learn versions, you can implement both__sklearn_tags__and_more_tagsor_get_tags. This change was introduced in scikit-learn=1.6
Added in scikit-learn/scikit-learn#30268
StrikerRUS
left a comment
There was a problem hiding this comment.
LGTM, except one comment below. Thank you for coming back and simplifying this!
|
This pull request has been automatically locked since there has not been any recent activity since it was closed. |
Follow-up to #6718
In that PR, I'd skipped the method resolution order ("MRO") for
__sklearn_tags__()in thescikit-learnestimators, to provide compatibility with earlier versions of that library. During development, we switched to having e.g.LGBMClassifier.__sklearn_tags__()raise anAttributeErrorif run on a too-new version ofscikit-learn, making that unnecessary... but never went back to just using inheritance to get__sklearn_tags__().This fixes that.
Notes for Reviewers
Inspired by dmlc/xgboost#11021 (comment)