8000 GridSearchCV object has no attribute classes_ · Issue #6298 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

GridSearchCV object has no attribute classes_ #6298

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

Closed
aflaxman opened this issue Feb 6, 2016 · 8 comments · Fixed by #7661
Closed

GridSearchCV object has no attribute classes_ #6298

aflaxman opened this issue Feb 6, 2016 · 8 comments · Fixed by #7661
Labels
Easy Well-defined and straightforward way to resolve

Comments

@aflaxman
Copy link
Contributor
aflaxman commented Feb 6, 2016

It would be convenient for me if GridSearchCV objects had attribute classes_ after fitting. Here is a minimal example of something that I would like to do, which does not work currently:

from sklearn.datasets.samples_generator import make_classification
from sklearn.ensemble import GradientBoostingClassifier
from sklearn.model_selection import GridSearchCV

X, y = make_classification(n_samples=20, n_features=5, random_state=0)
clf = GradientBoostingClassifier()
clf.fit(X,y)
clf.classes_  # works

clf = GridSearchCV(GradientBoostingClassifier(), {'max_depth':[2,3,4]})
clf.fit(X,y)
clf.classes_  # does not work

I think this could be accomplished by copying the attribute from the self.best_estimator_ when it is created, and if so, I can make a pull request. But let me know if it is more complicated, or undesired.

@TomDLT
Copy link
Member
TomDLT commented Feb 25, 2016

What about clf.best_estimator_.classes_?
I don't think we want to copy every attribute of the best estimator into GridSearcCV.

@unautre
Copy link
unautre commented Feb 25, 2016

@TomDLT maybe we could just make a property that returns the best estimator's classes_ attribute. That wouldn't require to make a copy and still make it consistent with the estimator interface.

@amueller
Copy link
Member

the question is whether classes_ is public classifier API. It kinda is...

@GaelVaroquaux
Copy link
Member
GaelVaroquaux commented Feb 25, 2016 via email

@aflaxman
Copy link
Contributor Author

+1 for exposing classes_ in some way through the API. I guess this issue originated from my attempt to act as if it already was. Thanks all for your work on this amazingly useful package!

@mitchellsuter
Copy link

Came across this thread when searching for the exact application. Would love to see classes_ with GridSearchCV

@maniteja123
Copy link
Contributor

Hi, it seems #6449 is a WIP attempt to address this issue.

@amueller
Copy link
Member
amueller commented Oct 8, 2016

#6449 is stalled, I'll add the tag again.

@amueller amueller added Easy Well-defined and straightforward way to resolve Need Contributor labels Oct 8, 2016
amueller pushed a commit that referenced this issue Oct 20, 2016
…ixes #6298 (#7661)

* Fix issue #6298
Adds a "classes_" property to BaseSearchCV

* Added test to ensure classes_ property is added to gridSearch correctly

* Fixed formatting

* Added test to ensure gridSearchCV with a regressor does not have a classes_ attribute

* Fixed whitespace issues

* Combined tests for the new GridSearchSV.classes_ property into a single test.

* Removed trailing whitespace

* Added what's new for pull request #7661

* Fixed formatting of update in what's new
Sundrique pushed a commit to Sundrique/scikit-learn that referenced this issue Jun 14, 2017
…ixes scikit-learn#6298 (scikit-learn#7661)

* Fix issue scikit-learn#6298
Adds a "classes_" property to BaseSearchCV

* Added test to ensure classes_ property is added to gridSearch correctly

* Fixed formatting

* Added test to ensure gridSearchCV with a regressor does not have a classes_ attribute

* Fixed whitespace issues

* Combined tests for the new GridSearchSV.classes_ property into a single test.

* Removed trailing whitespace

* Added what's new for pull request scikit-learn#7661

* Fixed formatting of update in what's new
paulha pushed a commit to paulha/scikit-learn that referenced this issue Aug 19, 2017
…ixes scikit-learn#6298 (scikit-learn#7661)

* Fix issue scikit-learn#6298
Adds a "classes_" property to BaseSearchCV

* Added test to ensure classes_ property is added to gridSearch correctly

* Fixed formatting

* Added test to ensure gridSearchCV with a regressor does not have a classes_ attribute

* Fixed whitespace issues

* Combined tests for the new GridSearchSV.classes_ property into a single test.

* Removed trailing whitespace

* Added what's new for pull request scikit-learn#7661

* Fixed formatting of update in what's new
maskani-moh pushed a commit to maskani-moh/scikit-learn that referenced this issue Nov 15, 2017
…ixes scikit-learn#6298 (scikit-learn#7661)

* Fix issue scikit-learn#6298
Adds a "classes_" property to BaseSearchCV

* Added test to ensure classes_ property is added to gridSearch correctly

* Fixed formatting

* Added test to ensure gridSearchCV with a regressor does not have a classes_ attribute

* Fixed whitespace issues

* Combined tests for the new GridSearchSV.classes_ property into a single test.

* Removed trailing whitespace

* Added what's new for pull request scikit-learn#7661

* Fixed formatting of update in what's new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Easy Well-defined and straightforward way to resolve
Projects
None yet
7 participants
0