@@ -49,12 +49,14 @@ def check_svm_model_equal(dense_svm, sparse_svm, X_train, y_train, X_test):
4949 assert_true (sparse .issparse (sparse_svm .dual_coef_ ))
5050 assert_array_almost_equal (dense_svm .support_vectors_ ,
5151 sparse_svm .support_vectors_ .toarray ())
52- assert_array_almost_equal (dense_svm .dual_coef_ , sparse_svm .dual_coef_ .toarray ())
52+ assert_array_almost_equal (dense_svm .dual_coef_ ,
53+ sparse_svm .dual_coef_ .toarray ())
5354 if dense_svm .kernel == "linear" :
5455 assert_true (sparse .issparse (sparse_svm .coef_ ))
5556 assert_array_almost_equal (dense_svm .coef_ , sparse_svm .coef_ .toarray ())
5657 assert_array_almost_equal (dense_svm .support_ , sparse_svm .support_ )
57- assert_array_almost_equal (dense_svm .predict (X_test_dense ), sparse_svm .predict (X_test ))
58+ assert_array_almost_equal (dense_svm .predict (X_test_dense ),
59+ sparse_svm .predict (X_test ))
5860 assert_array_almost_equal (dense_svm .decision_function (X_test_dense ),
5961 sparse_svm .decision_function (X_test ))
6062 assert_array_almost_equal (dense_svm .decision_function (X_test_dense ),
@@ -122,7 +124,8 @@ def test_unsorted_indices():
122124
123125
124126def test_svc_with_custom_kernel ():
125- kfunc = lambda x , y : safe_sparse_dot (x , y .T )
127+ def kfunc (x , y ):
128+ return safe_sparse_dot (x , y .T )
126129 clf_lin = svm .SVC (kernel = 'linear' ).fit (X_sp , Y )
127130 clf_mylin = svm .SVC (kernel = kfunc ).fit (X_sp , Y )
128131 assert_array_equal (clf_lin .predict (X_sp ), clf_mylin .predict (X_sp ))
@@ -144,10 +147,10 @@ def test_svc_iris():
144147
145148
146149def test_sparse_decision_function ():
147- #Test decision_function
150+ # Test decision_function
148151
149- #Sanity check, test that decision_function implemented in python
150- #returns the same as the one in libsvm
152+ # Sanity check, test that decision_function implemented in python
153+ # returns the same as the one in libsvm
151154
152155 # multi class:
153156 svc = svm .SVC (kernel = 'linear' , C = 0.1 , decision_function_shape = 'ovo' )
@@ -262,7 +265,7 @@ def test_sparse_liblinear_intercept_handling():
262265
263266
264267def test_sparse_oneclasssvm ():
265- """ Check that sparse OneClassSVM gives the same result as dense OneClassSVM"""
268+ # Check that sparse OneClassSVM gives the same result as dense OneClassSVM
266269 # many class dataset:
267270 X_blobs , _ = make_blobs (n_samples = 100 , centers = 10 , random_state = 0 )
268271 X_blobs = sparse .csr_matrix (X_blobs )
@@ -273,8 +276,8 @@ def test_sparse_oneclasssvm():
273276 kernels = ["linear" , "poly" , "rbf" , "sigmoid" ]
274277 for dataset in datasets :
275278 for kernel in kernels :
276- clf = svm .OneClassSVM (kernel = kernel , random_state = 0 )
277- sp_clf = svm .OneClassSVM (kernel = kernel , random_state = 0 )
279+ clf = svm .OneClassSVM (kernel = kernel )
280+ sp_clf = svm .OneClassSVM (kernel = kernel )
278281 check_svm_model_equal (clf , sp_clf , * dataset )
279282
280283
0 commit comments