@@ -1713,8 +1713,9 @@ def test_sgd_oneclass_convergence():
1713
1713
# that the stopping criterion is working
1714
1714
for nu in [0.1 , 0.5 , 0.9 ]:
1715
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 )
1716
+ model = SGDOneClassSVM (
1717
+ nu = nu , max_iter = 100 , tol = 1e-3 , learning_rate = "constant" , eta0 = 1e-3
1718
+ )
1718
1719
model .fit (iris .data )
1719
1720
# 6 is the minimal number of iterations, after which optimization can stop
1720
1721
assert model .n_iter_ > 6
@@ -1724,9 +1725,10 @@ def test_sgd_oneclass_vs_linear_oneclass():
1724
1725
# Test convergence vs. liblinear OCSVM with kernel="linear"
1725
1726
for nu in [0.1 , 0.5 , 0.9 ]:
1726
1727
# allow enough iterations, small dataset
1727
- model = SGDOneClassSVM (nu = nu , max_iter = 20000 , tol = None ,
1728
- learning_rate = "constant" , eta0 = 1e-3 )
1729
- model_ref = OneClassSVM (kernel = "linear" , nu = nu , tol = 1e-6 ) # reference model
1728
+ model = SGDOneClassSVM (
1729
+ nu = nu , max_iter = 20000 , tol = None , learning_rate = "constant" , eta0 = 1e-3
1730
+ )
1731
+ model_ref = OneClassSVM (kernel = "linear" , nu = nu , tol = 1e-6 ) # reference model
1730
1732
model .fit (iris .data )
1731
1733
model_ref .fit (iris .data )
1732
1734
@@ -1740,8 +1742,8 @@ def test_sgd_oneclass_vs_linear_oneclass():
1740
1742
preds_corr = np .corrcoef (preds , preds_ref )[0 , 1 ]
1741
1743
# check weights and intercept concatenated together for correlation
1742
1744
coef_corr = np .corrcoef (
1743
- np .concatenate ([model .coef_ , - model .offset_ ]),
1744
- np .concatenate ([model_ref .coef_ .flatten (), model_ref .intercept_ ])
1745
+ np .concatenate ([model .coef_ , - model .offset_ ]),
1746
+ np .concatenate ([model_ref .coef_ .flatten (), model_ref .intercept_ ]),
1745
1747
)[0 , 1 ]
1746
1748
# share of predicted 1's
1747
1749
share_ones = (preds == 1 ).sum () / len (preds )
@@ -1750,7 +1752,7 @@ def test_sgd_oneclass_vs_linear_oneclass():
1750
1752
assert dec_fn_corr > 0.99
1751
1753
assert preds_corr > 0.95
1752
1754
assert coef_corr > 0.99
1753
- assert_allclose ( 1 - share_ones , nu )
1755
+ assert_allclose (1 - share_ones , nu )
1754
1756
1755
1757
1756
1758
def test_l1_ratio ():
0 commit comments