-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
StandardScaler is stateless
#30840
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
Hello @benHeid, thanks for reporting. I have checked and would also think it is a bug. This code returned from sklearn.preprocessing import StandardScaler, MinMaxScaler
print(StandardScaler()._get_tags()["stateless"])
print(MinMaxScaler()._get_tags()["stateless"]) As a workaround please use the The issue is related to #30327. |
Actually it is the right way to do with the new tag infrastructure from sklearn.utils import get_tags
from sklearn.preprocessing import StandardScaler
get_tags(StandardScaler()).requires_fit And indeed, there is a bug with the conversion if the old tag infrastructure that we need to solve. |
So the bug is here: https://github.com/scikit-learn/scikit-learn/blob/main/sklearn/utils/_tags.py#L590 We should change to: "stateless": not new_tags.requires_fit, |
@EmilyXinyi, would you like to take care of that? Don't feel obliged though, only if you like. |
Hi @StefanieSenger thanks for flagging! I can probably take care of this next weekend, but if it's an urgent change that needs to go out before then, I most likely won't have time during the work week. |
I just put in a PR for a fix, but out of curiosity, what is the purpose of this tag thing? I have not used this functionality before, I can't seem to understand it very well just by reading the associated code, so if someone could please enlighten me that would be greatly appreciated 😸 |
Maybe the documentation can help: https://scikit-learn.org/stable/developers/develop.html#estimator-tags In short, the first use of it was to give some information regarding the capabilities of an estimator and it was used in the common tests to know whether an estimator is compatible with the scikit-learn API. Here, the Nowadays, we sometime use the tag in the source code as well (not only in test). |
Closing since we end the deprecation cycle and it will be fixed in the up coming 1.7 release. |
Describe the bug
The StandardScaler seems to be stateless in version 1.6.1. But fit changes the state of the StandardScaler if I got it correctly.
Steps/Code to Reproduce
Expected Results
False
Actual Results
True
Versions
The text was updated successfully, but these errors were encountered: