-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
RFC Make estimator tags available at class level instead of instance level #20590
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
Comments
Fundamentally, I have been thinking that the estimator tags feel more natural attached to the class. We use the instance when we define "pairwise": scikit-learn/sklearn/cluster/_affinity_propagation.py Lines 422 to 423 in a5a9d17
That was a recent addition, where I assumed that tags will stay connected to the instance. (If we want to move tags into the class level, I would greatly prefer "pairwise" to just be an public attribute third party developers can set "X_pairwise_". |
Meta-estimators I assume, since they must delegate most tags to the inner estimator which is only known after instantiation, and sometimes even after |
Hmm, I guess the most visible one is |
There are other meta-estimators like SFS and RFE, but not as many as I expected:
Indeed, tag delegation doesn't seem to be fully implemented. But it does seem that we rely on it at least partially, so making the tags a class-level property might be a bit tricky |
For good or bad, the parameters of an estimator fundamentally change its capabilities/API at times. I think the answer to this is "sorry, no, find another way". |
Ok. |
#20350 uses class attributes such as
_metadata_request__sample_weight
to change or set default values for requests related to certain metadata. Those attributes need to be available at the class level (as opposed to instance) since we generate certain methods for the classes and that part of the process has access to the class, and not the instance. Therefore as it stands we can't put default request information in estimator tags.But what we do there, is that we go through the MRO, and we find all we need, and we create the default values. This is very similar to what estimator tags do.
On the other hand, estimator tags are really an attribute of the class, and not the instance, therefore it'd make sense for them to be class attributes.
Are there any reasons why we have them specifically on the instance? If not, I propose we move them to be a class thing.
WDYT @scikit-learn/core-devs ?
The text was updated successfully, but these errors were encountered: