@@ -95,9 +95,10 @@ def predict_proba_ovr(estimators, X, is_multilabel):
95
95
#in the multi-label case, these are not disjoint. In the single-label case,
96
96
#these are disjoint
97
97
98
- if not multilabel :
98
+ if not is_multilabel :
99
99
#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.
101
102
return Y
102
103
103
104
class _ConstantPredictor (BaseEstimator ):
@@ -208,8 +209,14 @@ def predict_proba(self, X):
208
209
"""Probability estimates.
209
210
210
211
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.
213
220
214
221
Parameters
215
222
----------
@@ -221,7 +228,7 @@ def predict_proba(self, X):
221
228
Returns the probability of the sample for each class in the model,
222
229
where classes are ordered as they are in self.classes_.
223
230
"""
224
- self ._check_has_proba (self )
231
+ self ._check_has_proba ()
225
232
226
233
return predict_proba_ovr (self .estimators_ , X ,
227
234
is_multilabel = self .multilabel_ )
0 commit comments