8000 corrected doc for predic_proba, also caught few errors. · satra/scikit-learn@3340bf0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3340bf0

Browse files
AWintermanamueller
authored andcommitted
corrected doc for predic_proba, also caught few errors.
1 parent 742072b commit 3340bf0

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

sklearn/multiclass.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,10 @@ def predict_proba_ovr(estimators, X, is_multilabel):
9595
#in the multi-label case, these are not disjoint. In the single-label case,
9696
#these are disjoint
9797

98-
if not multilabel:
98+
if not is_multilabel:
9999
#then probabilities should be normalized to 1.
100-
Y /= np.sum(Y,axis = 1)[:,np.newaxis]
100+
Y /= np.sum(Y,axis = 1)[:,np.newaxis]
101+
#could use Y.T instead of np.newaxis, but I'd lose succintness and gain little clairity.
101102
return Y
102103

103104
class _ConstantPredictor(BaseEstimator):
@@ -208,8 +209,14 @@ def predict_proba(self, X):
208209
"""Probability estimates.
209210
210211
The returned estimates for all classes are ordered by label of classes.
211-
Note that since this is a multilabel problem, and each sample can have
212-
any number of labels, probabilities will *not* sum to unity.
212+
213+
Note that in the multilabel case, each sample can have any number of
214+
labels. This returns the marginal probability that the given sample has
215+
the label in question. For example, it is entirely consistent that two
216+
labels both have a 90% probability of applying to a given sample.
217+
218+
In the single label multiclass case, the rows of the returned matrix
219+
should sum to unity.
213220
214221
Parameters
215222
----------
@@ -221,7 +228,7 @@ def predict_proba(self, X):
221228
Returns the probability of the sample for each class in the model,
222229
where classes are ordered as they are in self.classes_.
223230
"""
224-
self._check_has_proba(self)
231+
self._check_has_proba()
225232

226233
return predict_proba_ovr(self.estimators_, X,
227234
is_multilabel=self.multilabel_)

0 commit comments

Comments
 (0)
0