Thanks to visit codestin.com
Credit goes to github.com

Skip to content

API rename Y to y for estimators from the PLS module#27666

Closed
IamjustNick wants to merge 2 commits intoscikit-learn:mainfrom
IamjustNick:issue_26945
Closed

API rename Y to y for estimators from the PLS module#27666
IamjustNick wants to merge 2 commits intoscikit-learn:mainfrom
IamjustNick:issue_26945

Conversation

@IamjustNick
Copy link

@IamjustNick IamjustNick commented Oct 25, 2023

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!

@github-actions
Copy link

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: 8aee30a. Link to the linter CI: here

@glemaitre glemaitre changed the title [MRG] Issue 26945 Replaced y for Y DEPR rename Y to y for PLS model Oct 26, 2023
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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to make this check first at the beginning of the function.

Comment on lines +240 to +241
"The use of Y as a parameter is currently being deprecated in favour"
" of y."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same remarks than in the previous fit function apply here.

Copy link
Member

@glemaitre glemaitre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all the feedback I will get to work on these points.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@glemaitre One quick question. Should I rename Y to y in all functions in the module, or just in the previously worked fit functions?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@glemaitre glemaitre changed the title DEPR rename Y to y for PLS model API rename Y to y for estimators from the PLS module Oct 26, 2023
@davidleon123
Copy link
Contributor

@IamjustNick
Could you please let know if you are still planning on working on this issue?
If it's a stall pull request, I'd like to work on it.

@IamjustNick
Copy link
Author

@IamjustNick Could you please let know if you are still planning on working on this issue? If it's a stall pull request, I'd like to work on it.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[PLSRegression] The standard scikit interface should have the argument in lowercase "y" not uppercase "Y"

3 participants