-
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] scikit-learn FutureWarning: 'requires_y' tag #4958
Comments
Hi all, I started to deep dive into this issue today and I have some interesting findings. First of all, the warning is raised only in this test case:
It is interesting to notice that the same warning is not raised for I have checked the source code of check_requires_y_none from sklearn and I noticed this part here (source): warning_msg = (
"As of scikit-learn 0.23, estimators should have a "
"'requires_y' tag set to the appropriate value. "
"The default value of the tag is False. "
"An error will be raised from version 1.0 when calling "
"check_estimator() if the tag isn't properly set."
)
expected_err_msgs = (
"requires y to be passed, but the target y is None",
"Expected array-like (array or non-string sequence), got None",
"y should be a 1d array",
)
try:
estimator.fit(X, None)
except ValueError as ve:
if not any(msg in str(ve) for msg in expected_err_msgs):
warnings.warn(warning_msg, FutureWarning) So, the warning message is raised when the estimator does not fail with the proper error message when y=None is passed as input. In LGBMRegressor the input is validated with This does not happen in The behaviour of LGBMRegressor seems completely legit to me. I think that the issue comes from an inconsistency between |
@ClaudioSalvatoreArcidiacono thanks so much for your thorough investigation and help with this! We'll subscribe to the |
@ClaudioSalvatoreArcidiacono Thank you very much for going such lengths in your investigation! |
Thank you @jameslamb and @StrikerRUS for checking out my investigation. Thank you for your contributions to this brilliant package! I use it very a lot and I finally got a chance to give back a little. Also happy that by doing so I can improve another amazing package like scikit-learn, that's two birds with one stone ;). |
scikit-learn/scikit-learn#22578 was merged. I just installed the latest available versions of LightGBM and scikit-learn and can confirm that the warning about @ClaudioSalvatoreArcidiacono Thanks a lot! |
This issue has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this. |
Description
I've recently noticed the following warning in logs for LightGBM's Python tests.
This should be addressed in the next release of LightGBM, to ensure that
lightgbm
remains compatible with newer versions ofscikit-learn
.See https://scikit-learn.org/stable/developers/develop.html#estimator-tags for details on that and other estimator tags.
Note that estimator tags were added in
scikit-learn
0.21.0 (May 2019). A fix for this issue should attempt to keeplightgbm
compatible with that and earlierscikit-learn
versions.Reproducible example / Environment Info
I've observed this on many of LightGBM's Python CI jobs. For example,
regular (macOS-latest, Python 3.8)
https://github.com/microsoft/LightGBM/runs/4845750605?check_suite_focus=true.Additional Comments
See #3533 for some related development and conversations.
The text was updated successfully, but these errors were encountered: