@@ -57,6 +57,7 @@ def test_libsvm_iris():
57
57
for k in ('linear' , 'rbf' ):
58
58
clf = svm .SVC (kernel = k ).fit (iris .data , iris .target )
59
59
assert_greater (np .mean (clf .predict (iris .data ) == iris .target ), 0.9 )
60
+ assert_true (hasattr (clf , "coef_" ) == (k == 'linear' ))
60
61
61
62
assert_array_equal (clf .classes_ , np .sort (clf .classes_ ))
62
63
@@ -257,7 +258,7 @@ def test_oneclass():
257
258
assert_array_almost_equal (clf .dual_coef_ ,
258
259
[[0.632 , 0.233 , 0.633 , 0.234 , 0.632 , 0.633 ]],
259
260
decimal = 3 )
260
- assert_raises ( ValueError , lambda : clf . coef_ )
261
+ assert_false ( hasattr ( clf , " coef_" ) )
261
262
262
263
263
264
def test_oneclass_decision_function ():
@@ -641,7 +642,8 @@ def test_linearsvc():
641
642
assert_array_almost_equal (clf .intercept_ , [0 ], decimal = 3 )
642
643
643
644
# the same with l1 penalty
644
- clf = svm .LinearSVC (penalty = 'l1' , loss = 'squared_hinge' , dual = False , random_state = 0 ).fit (X , Y )
645
+ clf = svm .LinearSVC (penalty = 'l1' , loss = 'squared_hinge' , dual = False ,
646
+ random_state = 0 ).fit (X , Y )
645
647
assert_array_equal (clf .predict (T ), true_result )
646
648
647
649
# l2 penalty with dual formulation
0 commit comments