API rename Y to y for estimators from the PLS module#27666
API rename Y to y for estimators from the PLS module#27666IamjustNick wants to merge 2 commits intoscikit-learn:mainfrom
Y to y for estimators from the PLS module#27666Conversation
Y to y for PLS model
| y : array-like of shape (n_samples,) or (n_samples, n_targets) | ||
| Target vectors, where `n_samples` is the number of samples and | ||
| `n_targets` is the number of response variables. | ||
|
|
There was a problem hiding this comment.
You need to add a docsring for the Y parameter and add the .. deprecated:: info. You can check the following documentation for more details: https://scikit-learn.org/dev/developers/contributing.html#deprecation
| Y = check_array( | ||
| Y, input_name="Y", dtype=np.float64, copy=self.copy, ensure_2d=False | ||
|
|
||
| if Y is not None: |
There was a problem hiding this comment.
We need to make this check first at the beginning of the function.
| "The use of Y as a parameter is currently being deprecated in favour" | ||
| " of y." |
There was a problem hiding this comment.
| "The use of Y as a parameter is currently being deprecated in favour" | |
| " of y." | |
| "`Y` is deprecated in 1.4 and will be removed in 1.6. Use `y` instead." |
| "The use of Y as a parameter is currently being deprecated in favour" | ||
| " of y." | ||
| ) | ||
| y = Y |
There was a problem hiding this comment.
We also need to check before hand that the user does not specify both y and Y and raise a ValueError if this is the case.
| ) | ||
|
|
||
| def fit(self, X, Y): | ||
| def fit(self, X, y, Y=None): |
There was a problem hiding this comment.
The same remarks than in the previous fit function apply here.
glemaitre
left a comment
There was a problem hiding this comment.
We also need tests to check that we raise the warning with the expected pattern. We also need to check that we raise the ValueError when setting both y and Y.
In addition, we need to make sure that none of our tests are raising the warning in which case we need to be sure to never call Y=... and just pass the variable instead.
We need an entry in the changelog doc/v1.4.rst to acknowledge the deprecation.
|
|
||
| @_fit_context(prefer_skip_nested_validation=True) | ||
| def fit(self, X, Y): | ||
| def fit(self, X, y, Y=None): |
There was a problem hiding this comment.
Thanks for all the feedback I will get to work on these points.
There was a problem hiding this comment.
@glemaitre One quick question. Should I rename Y to y in all functions in the module, or just in the previously worked fit functions?
There was a problem hiding this comment.
I did not look at the rest of the module but I think this is reasonable to do it for the full _pls.py module.
Y to y for PLS modelY to y for estimators from the PLS module
|
@IamjustNick |
Hi, sorry for this. I did want to get to it at the moment but clearly underestimated the amount of effort. I am at the moment packed with commitments and unable to get to it. I will close the request, feel free to get to it and my apologies again @davidleon123 |
I replaced Y for y in fit functions and introduced a deprecation warning in case the user still uses Y.
I have only replaced it on the fit functions. Please let me know if replacing it in the entire module would be better
Reference Issues/PRs
Fixes #26945
What does this implement/fix?
The issue mentions that Y should be replaced for y in the sci-kit learn interface. I wasn't sure if it should be for the entire module so I just replaced it on the fit functions.
Any other comments?
No extra comments, this is my first contribution I welcome feedback and criticism. Thanks!