@@ -368,17 +368,15 @@ def decision_function(self, X):
368368 X = self ._validate_for_predict (X )
369369 X = self ._compute_kernel (X )
370370
371- X = self ._validate_for_predict (X )
372-
373371 if self ._sparse :
374372 dec_func = self ._sparse_decision_function (X )
375373 else :
376374 dec_func = self ._dense_decision_function (X )
377375
378376 # In binary case, we need to flip the sign of coef, intercept and
379377 # decision function.
380- if self .impl != 'one_class' and len (self .classes_ ) == 2 :
381- return - dec_func
378+ if self ._impl in [ 'c_svc' , 'nu_svc' ] and len (self .classes_ ) == 2 :
379+ return - dec_func . ravel ()
382380
383381 return dec_func
384382
@@ -412,11 +410,11 @@ def _sparse_decision_function(self, X):
412410 self .support_vectors_ .indices ,
413411 self .support_vectors_ .indptr ,
414412 self ._dual_coef_ .data , self ._intercept_ ,
415- LIBSVM_IMPL .index (self .impl ), kernel_type ,
416- self .degree , self .gamma , self .coef0 , self .tol ,
413+ LIBSVM_IMPL .index (self ._impl ), kernel_type ,
414+ self .degree , self ._gamma , self .coef0 , self .tol ,
417415 self .C , self .class_weight_ ,
418416 self .nu , self .epsilon , self .shrinking ,
419- self .probability , self .n_support_ , self . _label ,
417+ self .probability , self .n_support_ ,
420418 self .probA_ , self .probB_ )
421419
422420 def _validate_for_predict (self , X ):
0 commit comments