Skip to content

Commit ff65305

Browse files
committed
fixed code formatting
1 parent af0270b commit ff65305

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

sklearn/linear_model/tests/test_sgd.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,17 +1709,23 @@ def test_ocsvm_vs_sgdocsvm():
17091709

17101710

17111711
def test_sgd_oneclass_convergence():
1712-
# Check that the optimization does not end early, that the stopping criterion is working
1712+
# Check that the optimization does not end early,
1713+
# that the stopping criterion is working
17131714
for nu in [0.1, 0.5, 0.9]:
1714-
model = SGDOneClassSVM(nu=nu, max_iter=100, tol=1e-3, learning_rate="constant", eta0=1e-3) # no need for large max_iter
1715+
# no need for large max_iter
1716+
model = SGDOneClassSVM(nu=nu, max_iter=100, tol=1e-3,
1717+
learning_rate="constant", eta0=1e-3)
17151718
model.fit(iris.data)
1716-
assert model.n_iter_ > 6 # 6 is the minimal number of iterations, after which optimization can stop
1719+
# 6 is the minimal number of iterations, after which optimization can stop
1720+
assert model.n_iter_ > 6
17171721

17181722

17191723
def test_sgd_oneclass_vs_linear_oneclass():
17201724
# Test convergence vs. liblinear OCSVM with kernel="linear"
17211725
for nu in [0.1, 0.5, 0.9]:
1722-
model = SGDOneClassSVM(nu=nu, max_iter=20000, tol=None, learning_rate="constant", eta0=1e-3) # allow enough iterations, small dataset
1726+
# allow enough iterations, small dataset
1727+
model = SGDOneClassSVM(nu=nu, max_iter=20000, tol=None,
1728+
learning_rate="constant", eta0=1e-3)
17231729
model_ref = OneClassSVM(kernel="linear", nu=nu, tol=1e-6) # reference model
17241730
model.fit(iris.data)
17251731
model_ref.fit(iris.data)
@@ -1733,7 +1739,10 @@ def test_sgd_oneclass_vs_linear_oneclass():
17331739
dec_fn_corr = np.corrcoef(dec_fn, dec_fn_ref)[0, 1]
17341740
preds_corr = np.corrcoef(preds, preds_ref)[0, 1]
17351741
# check weights and intercept concatenated together for correlation
1736-
coef_corr = np.corrcoef( np.concatenate([model.coef_, -model.offset_]), np.concatenate([model_ref.coef_.flatten(), model_ref.intercept_]) )[0, 1]
1742+
coef_corr = np.corrcoef(
1743+
np.concatenate([model.coef_, -model.offset_]),
1744+
np.concatenate([model_ref.coef_.flatten(), model_ref.intercept_])
1745+
)[0, 1]
17371746
# share of predicted 1's
17381747
share_ones = (preds == 1).sum() / len(preds)
17391748
share_ones_ref = (preds_ref == 1).sum() / len(preds_ref)

0 commit comments

Comments
 (0)