-
-
Notifications
You must be signed in to change notification settings - Fork 25.3k
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
[MRG+1] Added unit test for adding classes_ property to GridSearchCV, fixes #6298 #7661
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
07b474c
Fix issue #6298
unautre 0d79716
Added test to ensure classes_ property is added to gridSearch correctly
abatula b8ee33d
Fixed formatting
abatula 5c44632
Added test to ensure gridSearchCV with a regressor does not have a cl…
abatula 6a1ef11
Fixed whitespace issues
abatula 359e868
Combined tests for the new GridSearchSV.classes_ property into a sing…
abatula fc4bb72
Merge branch 'master' of https://github.com/scikit-learn/scikit-learn…
abatula c1d844a
Removed trailing whitespace
abatula 1683de4
Added what's new for pull request #7661
abatula 084d35d
Fixed formatting of update in what's new
abatula File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,7 @@ | |
from sklearn.metrics import f1_score | ||
from sklearn.metrics import make_scorer | ||
from sklearn.metrics import roc_auc_score | ||
from sklearn.linear_model import Ridge | ||
|
||
from sklearn.exceptions import ChangedBehaviorWarning | ||
from sklearn.exceptions import FitFailedWarning | ||
|
@@ -785,3 +786,20 @@ 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. And I'd prefer it. |
||
# Test that classes_ property matches best_esimator_.classes_ | ||
X = np.arange(100).reshape(10, 10) | ||
y = np.array([0] * 5 + [1] * 5) | ||
Cs = [.1, 1, 10] | ||
|
||
grid_search = GridSearchCV(LinearSVC(random_state=0), {'C': Cs}) | ||
grid_search.fit(X, y) | ||
assert_array_equal(grid_search.best_estimator_.classes_, | ||
grid_search.classes_) | ||
|
||
# Test that regressors do not have a classes_ attribute | ||
grid_search = GridSearchCV(Ridge(), {'alpha': [1.0, 2.0]}) | ||
grid_search.fit(X, y) | ||
assert_false(hasattr(grid_search, 'classes_')) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.