-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
FIX Correct the definition of gamma=scale
in svm
#13221
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1710,19 +1710,23 @@ def test_deprecated_grid_search_iid(): | |||||||||||||||||||||||||||||||||||||||
depr_message = ("The default of the `iid` parameter will change from True " | ||||||||||||||||||||||||||||||||||||||||
"to False in version 0.22") | ||||||||||||||||||||||||||||||||||||||||
X, y = make_blobs(n_samples=54, random_state=0, centers=2) | ||||||||||||||||||||||||||||||||||||||||
grid = GridSearchCV(SVC(gamma='scale'), param_grid={'C': [1]}, cv=3) | ||||||||||||||||||||||||||||||||||||||||
grid = GridSearchCV(SVC(gamma='scale', random_state=0), | ||||||||||||||||||||||||||||||||||||||||
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. We do not always warn. scikit-learn/sklearn/model_selection/_search.py Lines 795 to 813 in d19a5dc
|
||||||||||||||||||||||||||||||||||||||||
param_grid={'C': [10]}, cv=3) | ||||||||||||||||||||||||||||||||||||||||
# no warning with equally sized test sets | ||||||||||||||||||||||||||||||||||||||||
assert_no_warnings(grid.fit, X, y) | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
grid = GridSearchCV(SVC(gamma='scale'), param_grid={'C': [1]}, cv=5) | ||||||||||||||||||||||||||||||||||||||||
grid = GridSearchCV(SVC(gamma='scale', random_state=0), | ||||||||||||||||||||||||||||||||||||||||
param_grid={'C': [10]}, cv=5) | ||||||||||||||||||||||||||||||||||||||||
# warning because 54 % 5 != 0 | ||||||||||||||||||||||||||||||||||||||||
assert_warns_message(DeprecationWarning, depr_message, grid.fit, X, y) | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
grid = GridSearchCV(SVC(gamma='scale'), param_grid={'C': [1]}, cv=2) | ||||||||||||||||||||||||||||||||||||||||
grid = GridSearchCV(SVC(gamma='scale', random_state=0), | ||||||||||||||||||||||||||||||||||||||||
param_grid={'C': [10]}, cv=2) | ||||||||||||||||||||||||||||||||||||||||
# warning because stratification into two classes and 27 % 2 != 0 | ||||||||||||||||||||||||||||||||||||||||
assert_warns_message(DeprecationWarning, depr_message, grid.fit, X, y) | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
grid = GridSearchCV(SVC(gamma='scale'), param_grid={'C': [1]}, cv=KFold(2)) | ||||||||||||||||||||||||||||||||||||||||
grid = GridSearchCV(SVC(gamma='scale', random_state=0), | ||||||||||||||||||||||||||||||||||||||||
param_grid={'C': [10]}, cv=KFold(2)) | ||||||||||||||||||||||||||||||||||||||||
# no warning because no stratification and 54 % 2 == 0 | ||||||||||||||||||||||||||||||||||||||||
assert_no_warnings(grid.fit, X, y) | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,9 +87,9 @@ def test_svc(): | |
kernels = ["linear", "poly", "rbf", "sigmoid"] | ||
for dataset in datasets: | ||
for kernel in kernels: | ||
clf = svm.SVC(gamma='scale', kernel=kernel, probability=True, | ||
clf = svm.SVC(gamma=1, kernel=kernel, probability=True, | ||
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. numerical issue here and below
|
||
random_state=0, decision_function_shape='ovo') | ||
sp_clf = svm.SVC(gamma='scale', kernel=kernel, probability=True, | ||
sp_clf = svm.SVC(gamma=1, kernel=kernel, probability=True, | ||
random_state=0, decision_function_shape='ovo') | ||
check_svm_model_equal(clf, sp_clf, *dataset) | ||
|
||
|
@@ -293,8 +293,8 @@ def test_sparse_oneclasssvm(datasets_index, kernel): | |
[X_blobs[:80], None, X_blobs[80:]], | ||
[iris.data, None, iris.data]] | ||
dataset = datasets[datasets_index] | ||
clf = svm.OneClassSVM(gamma='scale', kernel=kernel) | ||
sp_clf = svm.OneClassSVM(gamma='scale', kernel=kernel) | ||
clf = svm.OneClassSVM(gamma=1, kernel=kernel) | ||
sp_clf = svm.OneClassSVM(gamma=1, kernel=kernel) | ||
check_svm_model_equal(clf, sp_clf, *dataset) | ||
|
||
|
||
|
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.
these samples are generated randomly (maybe we should avoid doing so in the tutorial?)