8000 Fixed pep8 violations and sampleweight format · scikit-learn/scikit-learn@113d048 · GitHub
[go: up one dir, main page]

Skip to content

Commit 113d048

Browse files
committed
Fixed pep8 violations and sampleweight format
1 parent 52ddf21 commit 113d048

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

sklearn/svm/classes.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,10 +366,6 @@ def fit(self, X, y, sample_weight=None):
366366
if self.C < 0:
367367
raise ValueError("Penalty term must be positive; got (C=%r)"
368368
% self.C)
369-
if ((sample_weight is not None) and
370-
np.atleast_1d(sample_weight).ndim > 1):
371-
sample_weight = column_or_1d(sample_weight, warn=True)
372-
373369
X, y = check_X_y(X, y, accept_sparse='csr',
374370
dtype=np.float64, order="C")
375371
penalty = 'l2' # SVR only accepts l2 penalty

sklearn/svm/tests/test_svm.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,11 @@ def test_linearsvr():
196196
svr = svm.SVR(kernel='linear', C=1e3).fit(diabetes.data, diabetes.target)
197197
score2 = svr.score(diabetes.data, diabetes.target)
198198

199-
assert_allclose( np.linalg.norm(lsvr.coef_) , np.linalg.norm(svr.coef_),1, 0.0001 )
199+
assert_allclose(np.linalg.norm(lsvr.coef_),
200+
np.linalg.norm(svr.coef_), 1, 0.0001)
200201
assert_almost_equal(score1, score2, 2)
201202

203+
202204
def test_linearsvr_fit_sampleweight():
203205
# check correct result when sample_weight is 1
204206
# check that SVR(kernel='linear') and LinearSVC() give
@@ -213,7 +215,8 @@ def test_linearsvr_fit_sampleweight():
213215
lsvr_no_weight = svm.LinearSVR(C=1e3).fit(diabetes.data, diabetes.target)
214216
score2 = lsvr_no_weight.score(diabetes.data, diabetes.target)
215217

216-
assert_allclose(np.linalg.norm(lsvr.coef_), np.linalg.norm(lsvr_no_weight.coef_), 1, 0.0001)
218+
assert_allclose(np.linalg.norm(lsvr.coef_),
219+
np.linalg.norm(lsvr_no_weight.coef_), 1, 0.0001)
217220
assert_almost_equal(score1, score2, 2)
218221

219222
# check that fit(X) = fit([X1, X2, X3],sample_weight = [n1, n2, n3]) where
@@ -230,7 +233,8 @@ def test_linearsvr_fit_sampleweight():
230233
lsvr_flat = svm.LinearSVR(C=1e3).fit(X_flat, y_flat)
231234
score4 = lsvr_flat.score(X_flat, y_flat)
232235

233-
assert_almost_equal(score3 ,score4,2)
236+
assert_almost_equal(score3, score4, 2)
237+
234238

235239
def test_svr_errors():
236240
X = [[0.0], [1.0]]

0 commit comments

Comments
 (0)
0