@@ -511,7 +511,7 @@ def fit(self, X, y):
511
511
512
512
def predict (self , X ):
513
513
"""Estimate the best class label for each sample in X.
514
-
514
+
515
515
This is implemented as ``argmax(decision_function(X), axis=1)`` which
516
516
will return the label of the class with most votes by estimators
517
517
predicting the outcome of a decision for each possible class pair.
@@ -532,7 +532,7 @@ def predict(self, X):
532
532
def decision_function (self , X ):
533
533
"""Decision function for the OneVsOneClassifier.
534
534
535
- The decision values for the samples are computed by adding the
535
+ The decision values for the samples are computed by adding the
536
536
normalized sum of pair-wise classification confidence levels to the
537
537
votes in order to disambiguate between the decision values when the
538
538
votes for all the classes are equal leading to a tie.
@@ -569,9 +569,14 @@ def decision_function(self, X):
569
569
if max_confidences == min_confidences :
570
570
return votes
571
571
572
- # Scale the sum_of_confidences to [-0.4, 0.4] and add it with votes
573
- return votes + sum_of_confidences * \
574
- (0.4 / max (abs (max_confidences ), abs (min_confidences )))
572
+ # Scale the sum_of_confidences to (-0.5, 0.5) and add it with votes.
573
+ # The motivation is to use confidence levels as a way to break ties in
574
+ # the votes without switching any decision made based on a difference
575
+ # of 1 vote.
576
+ eps = np .finfo (sum_of_confidences .dtype ).eps
577
+ max_abs_confidence = max (abs (max_confidences ), abs (min_confidences ))
578
+ scale = (0.5 - eps ) / max_abs_confidence
579
+ return votes + sum_of_confidences * scale
575
580
576
581
577
582
@deprecated ("fit_ecoc is deprecated and will be removed in 0.18."
0 commit comments