You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been developing a custom estimator class that follows scikit-learn's estimator API. Up to scikit-learn version 1.5.2, this was straightforward because the estimator checks did not enforce strict type checks on tags, so I didn't need to import scikit-learn at all, my custom estimator would simply implement the required interface.
However, starting with scikit-learn version 1.6, a new requirement was introduced: the estimator must implement a __sklearn_tags__() method that returns an instance of scikit-learn’s internal Tags class. The built-in estimator checks now assert that the returned object is exactly an instance of this Tags class, which forces me to subclass or at least import this class from scikit-learn. This creates a problem for projects that want to be compatible with the scikit-learn estimator API but do not want to include scikit-learn itself as a direct dependency, either to reduce install size or avoid version conflicts.
Is there an easy or recommended way to satisfy this new scikit-learn 1.6+ tagging API requirement without having to add scikit-learn itself as a dependency? For example, can I somehow provide the Tags class or a compatible substitute so my custom estimator passes the checks, but without fully depending on the scikit-learn package?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I have been developing a custom estimator class that follows scikit-learn's estimator API. Up to scikit-learn version
1.5.2
, this was straightforward because the estimator checks did not enforce strict type checks on tags, so I didn't need to import scikit-learn at all, my custom estimator would simply implement the required interface.However, starting with scikit-learn version
1.6
, a new requirement was introduced: the estimator must implement a__sklearn_tags__()
method that returns an instance of scikit-learn’s internalTags
class. The built-in estimator checks now assert that the returned object is exactly an instance of thisTags
class, which forces me to subclass or at least import this class from scikit-learn. This creates a problem for projects that want to be compatible with the scikit-learn estimator API but do not want to include scikit-learn itself as a direct dependency, either to reduce install size or avoid version conflicts.Is there an easy or recommended way to satisfy this new scikit-learn 1.6+ tagging API requirement without having to add scikit-learn itself as a dependency? For example, can I somehow provide the Tags class or a compatible substitute so my custom estimator passes the checks, but without fully depending on the scikit-learn package?
Beta Was this translation helpful? Give feedback.
All reactions