Skip to content

Commit a870b90

Browse files
raghavrvamueller
authored andcommitted
ENH Scale the sum_of_confidences to (-0.5, 0.5)
1 parent ef25b77 commit a870b90

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy