Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

PEP8

  • Loading branch information...
commit efa5e37c6167d9563c733c19eae5aa052fb4ace8 1 parent 87364ee
Olivier Grisel ogrisel authored larsmans committed
Showing with 7 additions and 9 deletions.
  1. +7 −9 scikits/learn/tests/test_grid_search.py
16 scikits/learn/tests/test_grid_search.py
View
@@ -15,10 +15,9 @@
from scikits.learn.svm.sparse import LinearSVC as SparseLinearSVC
from scikits.learn.metrics import f1_score
-class MockClassifier(BaseEstimator):
- """Dummy classifier to test the cross-validation
- """
+class MockClassifier(BaseEstimator):
+ """Dummy classifier to test the cross-validation"""
def __init__(self, foo_param=0):
self.foo_param = foo_param
@@ -36,6 +35,7 @@ def score(self, X=None, Y=None):
score = 0.
return score
+
X = np.array([[-1, -1], [-2, -1], [1, 1], [2, 1]])
y = np.array([1, 1, 2, 2])
@@ -48,7 +48,7 @@ def test_grid_search():
assert_equal(cross_validation.fit(X, y).best_estimator.foo_param, 2)
for i, foo_i in enumerate([1, 2, 3]):
- assert cross_validation.grid_scores_[i][0] == {'foo_param' : foo_i}
+ assert cross_validation.grid_scores_[i][0] == {'foo_param': foo_i}
def test_grid_search_error():
@@ -57,7 +57,7 @@ def test_grid_search_error():
X_, y_ = test_dataset_classif(n_samples=200, n_features=100, seed=0)
clf = LinearSVC()
- cv = GridSearchCV(clf, {'C':[0.1, 1.0]})
+ cv = GridSearchCV(clf, {'C': [0.1, 1.0]})
assert_raises(ValueError, cv.fit, X_[:180], y_)
@@ -66,14 +66,14 @@ def test_grid_search_sparse():
X_, y_ = test_dataset_classif(n_samples=200, n_features=100, seed=0)
clf = LinearSVC()
- cv = GridSearchCV(clf, {'C':[0.1, 1.0]})
+ cv = GridSearchCV(clf, {'C': [0.1, 1.0]})
cv.fit(X_[:180], y_[:180])
y_pred = cv.predict(X_[180:])
C = cv.best_estimator.C
X_ = sp.csr_matrix(X_)
clf = SparseLinearSVC()
- cv = GridSearchCV(clf, {'C':[0.1, 1.0]})
+ cv = GridSearchCV(clf, {'C': [0.1, 1.0]})
cv.fit(X_[:180], y_[:180])
y_pred2 = cv.predict(X_[180:])
C2 = cv.best_estimator.C
@@ -102,5 +102,3 @@ def test_grid_search_sparse_score_func():
assert_array_equal(y_pred, y_pred2)
assert_equal(C, C2)
-
-
Please sign in to comment.
Something went wrong with that request. Please try again.