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
MNT deprecate attributes in Partial Least Squares module #18768
MNT deprecate attributes in Partial Least Squares module #18768
Conversation
we're already deprecating a few attributes in 0.24 in these classes, and this PR deprecates more (which I'm in favor of), but there are a bunch of other attributes which can be made private as well, like, all of these maybe:
should we deprecate them and include them in the release? Kinda looks cleaner if they're all deprecated in the same release, WDYT @ogrisel @NicolasHug |
apart from the scores (already deprecated), the rest of the attributes are relevant and shouldn't be deprecated |
what do you mean by relevant? I mean, what's the difference between |
they all have specific meanings: https://scikit-learn.org/dev/modules/cross_decomposition.html#cross-decomposition |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @marenwestermann , looks good.
we'll also need a quick test making sure these are deprecated. You can parametrize with all estimators and with all attributes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @marenwestermann , LGTM if green!
@adrinjalali to expand on my (probably too short) reply above re the attributes: I think they're more relevant than the means and stds because they can be used for some specific purposes and they can also be used for inspection. The |
fair point, that's convincing :) |
@NicolasHug I added the TODO note and removed the classes from the IGNORED set in |
@@ -488,6 +488,18 @@ def test_norm_y_weights_deprecation(Est): | |||
est.norm_y_weights | |||
|
|||
|
|||
# TODO: Remove test in 0.26 | |||
@pytest.mark.parametrize('Est', (PLSRegression, PLSCanonical, CCA, PLSSVD)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pytest.mark.parametrize('Est', (PLSRegression, PLSCanonical, CCA, PLSSVD)) | |
@pytest.mark.parametrize('Estimator', (PLSRegression, PLSCanonical, CCA, PLSSVD)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will need an entry in the what's new to announce the deprecation of the parameters since they could be used.
Otherwise, LGTM
@@ -488,6 +488,18 @@ def test_norm_y_weights_deprecation(Est): | |||
est.norm_y_weights | |||
|
|||
|
|||
# TODO: Remove test in 0.26 | |||
@pytest.mark.parametrize('Est', (PLSRegression, PLSCanonical, CCA, PLSSVD)) | |||
@pytest.mark.parametrize('attr', ("x_mean_", "y_mean_", "x_std_", "y_std_")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pytest.mark.parametrize('attr', ("x_mean_", "y_mean_", "x_std_", "y_std_")) | |
@pytest.mark.parametrize('attribute', ("x_mean_", "y_mean_", "x_std_", "y_std_")) |
Y = rng.randn(10, 3) | ||
est = Est().fit(X, Y) | ||
with pytest.warns(FutureWarning, match=f"{attr} was deprecated"): | ||
getattr(est, attr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getattr(est, attr) | |
getattr(estimato, attribute) |
X = rng.randn(10, 5) | ||
Y = rng.randn(10, 3) | ||
est = Est().fit(X, Y) | ||
with pytest.warns(FutureWarning, match=f"{attr} was deprecated"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with pytest.warns(FutureWarning, match=f"{attr} was deprecated"): | |
with pytest.warns(FutureWarning, match=f"{attribute} was deprecated"): |
rng = np.random.RandomState(0) | ||
X = rng.randn(10, 5) | ||
Y = rng.randn(10, 3) | ||
est = Est().fit(X, Y) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
est = Est().fit(X, Y) | |
estimator = Estimator().fit(X, Y) |
I implemented the suggested changes and made an entry in the what's new section. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @marenwestermann
ping @ogrisel for the release |
Reference Issues/PRs
Towards #14312
Closes #18764
What does this implement/fix? Explain your changes.
Deprecation of the attributes x_mean_, y_mean_, x_std_, y_std_ in module _pls.py
Any other comments?
ping @adrinjalali