8000 DOC Add tiebreaking explanation to DecisionTreeClassifier docs (#17783) · scikit-learn/scikit-learn@a8067f7 · GitHub
[go: up one dir, main page]

Skip to content

Commit a8067f7

Browse files
Thomas9292alfaro96NicolasHugthomas.wesselink@ing.com
authored
DOC Add tiebreaking explanation to DecisionTreeClassifier docs (#17783)
Co-authored-by: Juan Carlos Alfaro Jiménez <JuanCarlos.Alfaro@uclm.es> Co-authored-by: Nicolas Hug <contact@nicolas-hug.com> Co-authored-by: thomas.wesselink@ing.com <thomas.wesselink@ing.com>
1 parent 3cd62b3 commit a8067f7

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

doc/modules/tree.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,13 @@ After being fitted, the model can then be used to predict the class of samples::
106106
>>> clf.predict([[2., 2.]])
107107
array([1])
108108

109-
Alternatively, the probability of each class can be predicted, which is the
110-
fraction of training samples of the same class in a leaf::
109+
In case that there are multiple classes with the same and highest
110+
probability, the classifier will predict the class with the lowest index
111+
amongst those classes.
112+
113+
As an alternative to outputting a specific class, the probability of each class
114+
can be predicted, which is the fraction of training samples of the class in a
115+
leaf::
111116

112117
>>> clf.predict_proba([[2., 2.]])
113118
array([[0., 1.]])
@@ -377,7 +382,6 @@ Tips on practical use
377382
most of the samples.
378383

379384

380-
381385
.. _tree_algorithms:
382386

383387
Tree algorithms: ID3, C4.5, C5.0 and CART

sklearn/tree/_classes.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,11 @@ class DecisionTreeClassifier(ClassifierMixin, BaseDecisionTree):
783783
reduce memory consumption, the complexity and size of the trees should be
784784
controlled by setting those parameter values.
785785
786+
The :meth:`predict` method operates using the :func:`numpy.argmax`
787+
function on the outputs of :meth:`predict_proba`. This means that in
788+
case the highest predicted probabilities are tied, the classifier will
789+
predict the tied class with the lowest index in :term:`classes_`.
790+
786791
References
787792
----------
788793

0 commit comments

Comments
 (0)
0