Skip to content

Commit

Permalink
COSMIT multiclass.predict_ovr
Browse files Browse the repository at this point in the history
  • Loading branch information
larsmans committed Oct 27, 2011
1 parent 8a487b6 commit 498f293
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions sklearn/multiclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,8 @@ def fit_ovr(estimator, X, y):
def predict_ovr(estimators, label_binarizer, X):
"""Make predictions using the one-vs-the-rest strategy."""
Y = np.array([predict_binary(e, X) for e in estimators])
if hasattr(estimators[0], "decision_function"):
return label_binarizer.inverse_transform(Y.T, threshold=0)
else:
return label_binarizer.inverse_transform(Y.T, threshold=0.5)
thresh = 0 if hasattr(estimators[0], "decision_function") else .5
return label_binarizer.inverse_transform(Y.T, threshold=thresh)


class OneVsRestClassifier(BaseEstimator, ClassifierMixin):
Expand Down

0 comments on commit 498f293

Please sign in to comment.