<div dir="ltr"><div><div><div>The ClassificationCriterion and RegressionCriterion are now exposed in the _criterion.pxd. It will allow you to create your own criterion.<br></div>So you can write your own Criterion with a given loss by implementing the methods which are required in the trees.<br></div>Then you can pass an instance of this criterion to the tree and it should work.<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 15 February 2018 at 18:37, Thomas Evangelidis <span dir="ltr"><<a href="mailto:tevang3@gmail.com" target="_blank">tevang3@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-size:large;color:rgb(0,0,0)">Greetings,<br><br></div><div class="gmail_default" style="font-size:large;color:rgb(0,0,0)">The feature importance calculated by the RandomForest implementation is a very useful feature. I personally use it to select the best features because it is simple and fast, and then I train MLPRegressors. The limitation of this approach is that although I can control the loss function of the MLPRegressor (I have modified scikit-learn's implementation to accept an arbitrary loss function), I cannot do the same with RandomForestRegressor, and hence I have to rely on 'mse' which is not in accordance with the loss functions I use in MLPs. Today I was looking at the _criterion.pyx file:<br><br><a href="https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/tree/_criterion.pyx" target="_blank">https://github.com/scikit-<wbr>learn/scikit-learn/blob/<wbr>master/sklearn/tree/_<wbr>criterion.pyx</a><br><br></div><div class="gmail_default" style="font-size:large;color:rgb(0,0,0)">However, the code is in Cython and I find it hard to follow. I know that for Regression the relevant class are Criterion(), RegressionCriterion(Criterion)<wbr>, and MSE(RegressionCriterion). My question is: is it possible to write a class that takes an arbitrary function "loss(predictions, targets)" to calculate the loss and impurity of the nodes? <br><br></div><div class="gmail_default" style="font-size:large;color:rgb(0,0,0)">thanks,<br></div><div class="gmail_default" style="font-size:large;color:rgb(0,0,0)">Thomas<br clear="all"></div><br><br>-- <br><div class="m_1470307982150462589gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div> <p style="margin-bottom:0cm" align="LEFT"><span style="color:rgb(0,0,0)"><span style="font-family:arial,helvetica,sans-serif"><font size="2">==============================<wbr>==============================<wbr>==========</font></span></span></p>
<p style="margin-bottom:0cm" align="LEFT"><span style="color:rgb(0,0,0)"><span style="font-family:arial,helvetica,sans-serif"><font size="2">Dr Thomas Evangelidis</font></span></span></p>
<p style="margin-bottom:0cm" align="LEFT"><span style="color:rgb(0,0,0)"><span style="font-family:arial,helvetica,sans-serif"><font size="2">Post-doctoral Researcher<br></font></span></span></p><span style="color:rgb(0,0,0)"><span style="font-family:arial,helvetica,sans-serif"><font size="2">CEITEC - Central European Institute of Technology<br>Masaryk University<br>Kamenice 5/A35/2S049, <br>62500 Brno, Czech Republic <br></font></span></span></div><div dir="ltr"><span style="color:rgb(0,0,0)"><br></span><p style="margin-bottom:0cm" align="LEFT"><span style="color:rgb(0,0,0)"><span style="font-family:arial,helvetica,sans-serif"><font size="2">email: <a href="mailto:tevang@pharm.uoa.gr" target="_blank">tevang@pharm.uoa.gr</a></font></span></span></p>
<p style="margin-bottom:0cm" align="LEFT"><span style="color:rgb(0,0,0)"><span style="font-family:arial,helvetica,sans-serif"><font size="2"> <a href="mailto:tevang3@gmail.com" target="_blank">tevang3@gmail.com</a></font></span></span></p>
<p style="margin-bottom:0cm" align="LEFT"><span style="color:rgb(0,0,0)"><span style="font-family:arial,helvetica,sans-serif"><font size="2"><br>website: <a href="https://sites.google.com/site/thomasevangelidishomepage/" target="_blank">https://sites.google.com/site/<wbr>thomasevangelidishomepage/</a></font></span></span></p><span style="color:rgb(0,0,0)"><br></span><p style="margin-bottom:0cm" align="LEFT">
</p>
</div></div></div></div></div></div></div></div>
</div>
<br>______________________________<wbr>_________________<br>
scikit-learn mailing list<br>
<a href="mailto:scikit-learn@python.org">scikit-learn@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/scikit-learn" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/scikit-learn</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>Guillaume Lemaitre<br>INRIA Saclay - Parietal team<br>Center for Data Science Paris-Saclay<br><a href="https://glemaitre.github.io/" target="_blank">https://glemaitre.github.io/</a></div></div></div></div></div></div></div>
</div>