[scikit-learn] custom loss function in RandomForestRegressor

Thomas Evangelidis tevang3 at gmail.com
Thu Feb 15 14:46:31 EST 2018

Is it possible to compile just _criterion.pyx and _criterion.pxd files by
using "importpyx" or any alternative way instead of compiling the whole
sklearn library every time I introduce a change?

Dne 15. 2. 2018 19:29 napsal uživatel "Guillaume Lemaitre" <
g.lemaitre58 at gmail.com>:

Yes you are right pxd are the header and pyx the definition. You need to
write a class as MSE. Criterion is an abstract class or base class (I don't
have it under the eye)

@Andy: if I recall the PR, we made the classes public to enable such custom
criterion. However, ‎it is not documented since we were not officially
supporting it. So this is an hidden feature. We could always discuss to
make this feature more visible and document it.

Guillaume Lemaitre
INRIA Saclay Ile-de-France / Equipe PARIETAL
guillaume.lemaitre at inria.fr - https://glemaitre.github.io/
*From: *Thomas Evangelidis
*Sent: *Thursday, 15 February 2018 19:15
*To: *Scikit-learn mailing list
*Reply To: *Scikit-learn mailing list
*Subject: *Re: [scikit-learn] custom loss function in RandomForestRegressor

Sorry I don't know Cython at all. _criterion.pxd is like the header file in
C++? I see that it contains class, function and variable definitions and
their description in comments.

class Criterion is an Interface, doesn't have function definitions. By
"writing your own criterion with a given loss" you mean writing a class
like MSE(RegressionCriterion)?

On 15 February 2018 at 18:50, Guillaume Lemaître <g.lemaitre58 at gmail.com>

> The ClassificationCriterion and RegressionCriterion are now exposed in the
> _criterion.pxd. It will allow you to create your own criterion.
> So you can write your own Criterion with a given loss by implementing the
> methods which are required in the trees.
> Then you can pass an instance of this criterion to the tree and it should
> work.
> --
> Guillaume Lemaitre
> INRIA Saclay - Parietal team
> Center for Data Science Paris-Saclay
> https://glemaitre.github.io/
> _______________________________________________
> scikit-learn mailing list
> scikit-learn at python.org
> https://mail.python.org/mailman/listinfo/scikit-learn



Dr Thomas Evangelidis

Post-doctoral Researcher
CEITEC - Central European Institute of Technology
Masaryk University
Kamenice 5/A35/2S049,
62500 Brno, Czech Republic

email: tevang at pharm.uoa.gr

          tevang3 at gmail.com

website: https://sites.google.com/site/thomasevangelidishomepage/

scikit-learn mailing list
scikit-learn at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-learn/attachments/20180215/1108a73d/attachment.html>

More information about the scikit-learn mailing list