-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_tags
or_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_tags
or_get_tags
. This change was introduced in scikit-learn=1.6
Added in scikit-learn/scikit-learn#30268
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, except one comment below. Thank you for coming back and simplifying this!
Follow-up to #6718
In that PR, I'd skipped the method resolution order ("MRO") for
__sklearn_tags__()
in thescikit-learn
estimators, to provide compatibility with earlier versions of that library. During development, we switched to having e.g.LGBMClassifier.__sklearn_tags__()
raise anAttributeError
if 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)