Skip to content

Commit b74b004

Browse files
committed
ENH Scale the sum_of_confidences to (-0.5, 0.5)
1 parent ec84a00 commit b74b004

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

sklearn/multiclass.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -569,9 +569,14 @@ def decision_function(self, X):
569569
if max_confidences == min_confidences:
570570
return votes
571571

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
575580

576581

577582
@deprecated("fit_ecoc is deprecated and will be removed in 0.18."

0 commit comments

Comments
 (0)