-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
[MRG+1] Added unit test for adding classes_ property to GridSearchCV, fixes #6298 #7661
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
Conversation
Adds a "classes_" property to BaseSearchCV
Please also test that if a regressor is used, Thansk. |
Added a second test to make sure regressors don't have a classes_ attribute. |
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.
Otherwise, and with the Travis issues addressed, LGTM.
@@ -785,3 +786,30 @@ def test_parameters_sampler_replacement(): | |||
sampler = ParameterSampler(params_distribution, n_iter=7) | |||
samples = list(sampler) | |||
assert_equal(len(samples), 7) | |||
|
|||
|
|||
def test_classes__property(): |
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.
It's okay to combine these into one test function
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.
And I'd prefer it.
|
||
clf = LinearSVC(random_state=0) | ||
|
||
grid_search = GridSearchCV(clf, {'C': Cs}, scoring='accuracy') |
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.
scoring='accuracy'
is unnecessary.
Cs = [.1, 1, 10] | ||
|
||
clf = LinearSVC(random_state=0) | ||
|
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.
I don't think this blank line does much good.
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.
In fact, I'd be fine with GridSearchCV(LinearSVC(random_state=0), param_grid)
y = np.array([0] * 5 + [1] * 5) | ||
|
||
regr = Ridge() | ||
|
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.
Similarly, this is unhelpful whitespace
Please add a what's new entry. |
Merged the two tests into a single test, and fixed the whitespace issues found by Travis CI. I can't find any information on adding a what's new entry, are there instructions that I'm missing? |
Just checkout |
@@ -19,6 +19,11 @@ New features | |||
Enhancements | |||
............ | |||
|
|||
- Added ``classes_`` attribute to gridSearchCV object that matches the |
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.
gridSearchCV
should be
:class:`model_selection.GridSearchCV`
Fixed reference to gridSearchCV in what's new entry. |
thanks! |
- Added ``classes_`` attribute to :class:`model_selection.GridSearchCV` | ||
that matches the ``classes_`` attribute of ``best_estimator_``. (`#7661 | ||
<https://github.com/scikit-learn/scikit-learn/pull/7661>`_) by `Alyssa | ||
Batula`_ and `Dylan Werner-Meier`_. |
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.
You need to add your names to the bottom of the file for the links to work. I'll do that.
…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
…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
…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
Fixes #6298
Completes closed pull request #6449
Added a test to ensure the classes_ property is correclty added to GridSearchCV, and also check that regressors do not have the classes_ attribute. This should complete the previously closed pull request.