Skip to content
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 {n_}classes_ attribute for tree regressors #15028

Merged
merged 28 commits into from Sep 20, 2019

Conversation

adrinjalali
Copy link
Member

@adrinjalali adrinjalali commented Sep 19, 2019

Closes #14935.
Closes #14803

@NicolasHug I think we should also deprecate n_classes_ at the same time.

I also figured the Tree object requires the n_classes_ which doesn't make much sense at all.

I didn't touch the tree.pyx, but that needs to be fixed.

WDYT?

@NicolasHug
Copy link
Member

@NicolasHug NicolasHug commented Sep 19, 2019

Yeah I'm fine with that. LGTM if all goes green

@@ -1695,7 +1695,9 @@ def _run_search(self, evaluate):
for attr in dir(gscv):
if attr[0].islower() and attr[-1:] == '_' and \
attr not in {'cv_results_', 'best_estimator_',
'refit_time_'}:
'refit_time_',
'classes_' # TODO: remove in 0.24
Copy link
Member

@amueller amueller Sep 19, 2019

Choose a reason for hiding this comment

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

This seems a very weird thing to do. Why not catch the deprecation warning and keep the equality test?

Copy link
Member Author

@adrinjalali adrinjalali Sep 20, 2019

Choose a reason for hiding this comment

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

ok, catching the warning now

assert n == clf.n_outputs_

with pytest.warns(DeprecationWarning, match=match):
clf.n_classes_
Copy link
Contributor

@glemaitre glemaitre Sep 20, 2019

Choose a reason for hiding this comment

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

You can have an additional assert for the value

Copy link
Member Author

@adrinjalali adrinjalali Sep 20, 2019

Choose a reason for hiding this comment

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

ok, done.

@glemaitre
Copy link
Contributor

@glemaitre glemaitre commented Sep 20, 2019

I am +1 for this version since we deprecate n_classes_ as well which make sense.

@glemaitre glemaitre added this to TO BE MERGED in Guillaume's pet Sep 20, 2019
@NicolasHug
Copy link
Member

@NicolasHug NicolasHug commented Sep 20, 2019

Thanks Adrin

@NicolasHug NicolasHug merged commit 186629b into scikit-learn:master Sep 20, 2019
19 checks passed
@glemaitre glemaitre moved this from TO BE MERGED to MERGED in Guillaume's pet Sep 23, 2019
@adrinjalali adrinjalali deleted the dep_classes_tree_regressor branch Sep 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants