<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>To add to Guillaume's answer: the native multiclass support for
      forests/trees is described here:
      <a class="moz-txt-link-freetext" href="https://scikit-learn.org/stable/modules/tree.html#multi-output-problems">https://scikit-learn.org/stable/modules/tree.html#multi-output-problems</a></p>
    <p>It's not a one-vs-rest strategy and can be summed up as:</p>
    <p>
      <blockquote type="cite">
        <blockquote>
          <div>
            <ul class="simple">
              <li>
                <p>Store n output values in leaves, instead of 1;</p>
              </li>
              <li>
                <p class="">Use splitting criteria that compute the
                  average reduction across all
                  n outputs.</p>
              </li>
            </ul>
          </div>
        </blockquote>
      </blockquote>
    </p>
    <p><br>
    </p>
    <p>Nicolas<br>
    </p>
    <div class="moz-cite-prefix">On 27/07/2021 10:22, Guillaume LemaĆ®tre
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:B3AF592B-2725-4DFF-BE06-718061AD1974@gmail.com">
      <pre class="moz-quote-pre" wrap="">
</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">On 27 Jul 2021, at 11:08, Sole Galli via scikit-learn <a class="moz-txt-link-rfc2396E" href="mailto:scikit-learn@python.org"><scikit-learn@python.org></a> wrote:

Hello community,

Do I understand correctly that Random Forests are trained as a 1 vs rest when the target has more than 2 classes? Say the target takes values 0, 1 and 2, then the model would train 3 estimators 1 per class under the hood?.
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
Each decision tree of the forest is natively supporting multi class.

</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">
The predict_proba output is an array with 3 columns, containing the probability of each class. If it is 1 vs rest. am I correct to assume that the sum of the probabilities for the 3 classes should not necessarily add up to 1? are they normalized? how is it done so that they do add up to 1?
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
According to the above answer, the sum for each row of the array given by `predict_proba` will sum to 1.
According to the documentation, the probabilities are computed as:

The predicted class probabilities of an input sample are computed as the mean predicted class probabilities of the trees in the forest. The class probability of a single tree is the fraction of samples of the same class in a leaf.

</pre>
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap="">
Thank you
Sole



_______________________________________________
scikit-learn mailing list
<a class="moz-txt-link-abbreviated" href="mailto:scikit-learn@python.org">scikit-learn@python.org</a>
<a class="moz-txt-link-freetext" href="https://mail.python.org/mailman/listinfo/scikit-learn">https://mail.python.org/mailman/listinfo/scikit-learn</a>
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
_______________________________________________
scikit-learn mailing list
<a class="moz-txt-link-abbreviated" href="mailto:scikit-learn@python.org">scikit-learn@python.org</a>
<a class="moz-txt-link-freetext" href="https://mail.python.org/mailman/listinfo/scikit-learn">https://mail.python.org/mailman/listinfo/scikit-learn</a>
</pre>
    </blockquote>
  </body>
</html>