[MRG+1] Added unit test for adding classes_ property to GridSearchCV, fixes #6298 #7661
Conversation
Please also test that if a regressor is used, Thansk. |
Added a second test to make sure regressors don't have a classes_ attribute. |
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(): |
jnothman
Oct 16, 2016
Member
It's okay to combine these into one test function
It's okay to combine these into one test function
jnothman
Oct 16, 2016
Member
And I'd prefer it.
And I'd prefer it.
|
||
clf = LinearSVC(random_state=0) | ||
|
||
grid_search = GridSearchCV(clf, {'C': Cs}, scoring='accuracy') |
jnothman
Oct 16, 2016
Member
scoring='accuracy'
is unnecessary.
scoring='accuracy'
is unnecessary.
Cs = [.1, 1, 10] | ||
|
||
clf = LinearSVC(random_state=0) | ||
|
jnothman
Oct 16, 2016
Member
I don't think this blank line does much good.
I don't think this blank line does much good.
jnothman
Oct 16, 2016
Member
In fact, I'd be fine with GridSearchCV(LinearSVC(random_state=0), param_grid)
In fact, I'd be fine with GridSearchCV(LinearSVC(random_state=0), param_grid)
y = np.array([0] * 5 + [1] * 5) | ||
|
||
regr = Ridge() | ||
|
jnothman
Oct 16, 2016
Member
Similarly, this is unhelpful whitespace
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 |
jnothman
Oct 19, 2016
Member
gridSearchCV
should be
:class:`model_selection.GridSearchCV`
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`_. |
amueller
Oct 20, 2016
Member
You need to add your names to the bottom of the file for the links to work. I'll do that.
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
…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.