@@ -537,6 +537,12 @@ def decision_function(self, X):
537
537
The signed 'distances' to the hyperplane(s).
538
538
"""
539
539
X = atleast2d_or_csr (X )
540
+ return self ._decision_function (X )
541
+
542
+ def _decision_function (self , X ):
543
+ """predict decision function assuming that X is either sparse
544
+ matrix or array-like.
545
+ """
540
546
scores = safe_sparse_dot (X , self .coef_ .T ) + self .intercept_
541
547
if self .classes_ .shape [0 ] == 2 :
542
548
return np .ravel (scores )
@@ -588,12 +594,13 @@ def predict_proba(self, X):
588
594
raise NotImplementedError ("predict_(log_)proba only supported"
589
595
" for binary classification" )
590
596
591
- proba = np .ones ((len (X ), 2 ), dtype = np .float64 )
597
+ X = atleast2d_or_csr (X )
598
+ proba = np .ones ((X .shape [0 ], 2 ), dtype = np .float64 )
592
599
if self .loss == "log" :
593
- proba [:, 1 ] = 1.0 / (1.0 + np .exp (- self .decision_function (X )))
600
+ proba [:, 1 ] = 1.0 / (1.0 + np .exp (- self ._decision_function (X )))
594
601
elif self .loss == "modified_huber" :
595
602
proba [:, 1 ] = np .minimum (1 , np .maximum (- 1 ,
596
- self .decision_function (X )))
603
+ self ._decision_function (X )))
597
604
proba [:, 1 ] += 1
598
605
proba [:, 1 ] /= 2
599
606
else :
0 commit comments