@@ -157,20 +157,23 @@ def __call__(self, clf, X, y, sample_weight=None):
157
157
if y_type not in ("binary" , "multilabel-indicator" ):
158
158
raise ValueError ("{0} format is not supported" .format (y_type ))
159
159
160
- try :
161
- y_pred = clf .decision_function (X )
160
+ if getattr (clf , "estimator_type" , None ) == "regressor" :
161
+ y_pred = clf .predict (X )
162
+ else :
163
+ try :
164
+ y_pred = clf .decision_function (X )
162
165
163
- # For multi-output multi-class estimator
164
- if isinstance (y_pred , list ):
165
- y_pred = np .vstack (p for p in y_pred ).T
166
+ # For multi-output multi-class estimator
167
+ if isinstance (y_pred , list ):
168
+ y_pred = np .vstack (p for p in y_pred ).T
166
169
167
- except (NotImplementedError , AttributeError ):
168
- y_pred = clf .predict_proba (X )
170
+ except (NotImplementedError , AttributeError ):
171
+ y_pred = clf .predict_proba (X )
169
172
170
- if y_type == "binary" :
171
- y_pred = y_pred [:, 1 ]
172
- elif isinstance (y_pred , list ):
173
- y_pred = np .vstack ([p [:, - 1 ] for p in y_pred ]).T
173
+ if y_type == "binary" :
174
+ y_pred = y_pred [:, 1 ]
175
+ elif isinstance (y_pred , list ):
176
+ y_pred = np .vstack ([p [:, - 1 ] for p in y_pred ]).T
174
177
175
178
if sample_weight is not None :
176
179
return self ._sign * self ._score_func (y , y_pred ,
0 commit comments