<html><head><meta http-equiv="content-type" content="text/html; charset=us-ascii"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div>Hi Sole,</div><div><br></div>You can use `apply` on the training `X` to get the leaf where the sample will fall in. Then a groupby should allow you to get the statistic that you want.<div><br></div><div>Cheers,<br><div>
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div>--</div><div>Guillaume Lemaitre<br>Scikit-learn @ Inria Foundation<br>https://glemaitre.github.io/</div></div>

</div>
<div><br><blockquote type="cite"><div>On 7 Mar 2023, at 15:53, Sole Galli via scikit-learn <scikit-learn@python.org> wrote:</div><br class="Apple-interchange-newline"><div><div style="font-family: Arial, sans-serif; font-size: 14px;">Hello,</div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px;">I would like to obtain final intervals from the decision tree structure. I am not interested in every node, just the limits that take a sample to a final decision /leaf.</div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px;">For example, if the tree structure is this one:</div><div style="font-family: Arial, sans-serif; font-size: 14px;"><pre><code>|--- feature_0 <= 0.08
|   |--- class: 0
|--- feature_0 >  0.08
|   |--- feature_0 <= 8.50
|   |   |--- feature_0 <= 1.50
|   |   |   |--- class: 1
|   |   |--- feature_0 >  1.50
|   |   |   |--- class: 1
|   |--- feature_0 >  8.50
|   |   |--- feature_0 <= 60.25
|   |   |   |--- class: 0
|   |   |--- feature_0 >  60.25
|   |   |   |--- class: 0</code></pre>Then, I would like to obtain these limits:</div><div style="font-family: Arial, sans-serif; font-size: 14px;"><p>0-0.08 ; 0.08-1.50; 1.50-8.50 ; 8.50-60; >60</p>Potentially as the following numpy array:</div><div style="font-family: Arial, sans-serif; font-size: 14px;"><pre><code>[-np.inf, 0.08, 1.5, 8.5, 60, np.inf]</code></pre><br></div><div style="font-family: Arial, sans-serif; font-size: 14px;">Is it possible?</div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px;">I have a stackoverflow question here for more details and code<br></div><div style="font-family: Arial, sans-serif; font-size: 14px;"><span><a target="_blank" rel="noreferrer nofollow noopener" href="https://stackoverflow.com/questions/75663472/how-to-obtain-the-interval-limits-from-a-decision-tree-with-scikit-learn">https://stackoverflow.com/questions/75663472/how-to-obtain-the-interval-limits-from-a-decision-tree-with-scikit-learn</a><br></span></div><div><br></div><div>Thank you<span>!</span></div><div style="font-family: Arial, sans-serif; font-size: 14px;"><span>Sole<br></span></div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div><div class="protonmail_signature_block" style="font-family: Arial, sans-serif; font-size: 14px;"><div class="protonmail_signature_block-proton">
        Sent with <a target="_blank" href="https://proton.me/" rel="noopener noreferrer">Proton Mail</a> secure email.
    </div>
</div>
_______________________________________________<br>scikit-learn mailing list<br>scikit-learn@python.org<br>https://mail.python.org/mailman/listinfo/scikit-learn<br></div></blockquote></div><br></div></body></html>