Re: [scikit-learn] custom loss function in RandomForestRegressor

2018-03-01 Thread Sebastian Raschka
Unfortunately (or maybe fortunately :)) no, maximizing variance reduction & minimizing MSE are just special cases :) Best, Sebastian > On Mar 1, 2018, at 9:59 AM, Thomas Evangelidis wrote: > > Does this generalize to any loss function? For example I also want to > implement Kendall's tau corr

Re: [scikit-learn] custom loss function in RandomForestRegressor

2018-03-01 Thread Thomas Evangelidis
Does this generalize to any loss function? For example I also want to implement Kendall's tau correlation coefficient and a combination of R, tau and RMSE. :) On Mar 1, 2018 15:49, "Sebastian Raschka" wrote: > Hi, Thomas, > > as far as I know, it's all the same and doesn't matter, and you would

Re: [scikit-learn] custom loss function in RandomForestRegressor

2018-03-01 Thread Sebastian Raschka
Hi, Thomas, as far as I know, it's all the same and doesn't matter, and you would get the same splits, since R^2 is just a rescaled MSE. Best, Sebastian > On Mar 1, 2018, at 9:39 AM, Thomas Evangelidis wrote: > > Hi Sebastian, > > Going back to Pearson's R loss function, does this imply th

Re: [scikit-learn] custom loss function in RandomForestRegressor

2018-03-01 Thread Thomas Evangelidis
Hi Sebastian, Going back to Pearson's R loss function, does this imply that I must add an abstract "init2" method to RegressionCriterion (that's where MSE class inherits from) where I will add the target values X as extra argument? And then the node impurity will be 1-R (the lowest the best)? What

Re: [scikit-learn] custom loss function in RandomForestRegressor

2018-03-01 Thread Sebastian Raschka
Hi, Thomas, in regression trees, minimizing the variance among the target values is equivalent to minimizing the MSE between targets and predicted values. This is also called variance reduction: https://en.wikipedia.org/wiki/Decision_tree_learning#Variance_reduction Best, Sebastian > On Mar 1

Re: [scikit-learn] custom loss function in RandomForestRegressor

2018-03-01 Thread Thomas Evangelidis
Hi again, I am currently revisiting this problem after familiarizing myself with Cython and Scikit-Learn's code and I have a very important query: Looking at the class MSE(RegressionCriterion), the node impurity is defined as the variance of the target values Y on that node. The predictions X are

Re: [scikit-learn] custom loss function in RandomForestRegressor

2018-02-15 Thread Guillaume Lemaître
> 10 times means that we could write something in the doc :) On 15 February 2018 at 21:27, Andreas Mueller wrote: > > > On 02/15/2018 01:28 PM, Guillaume Lemaitre wrote: > > Yes you are right pxd are the header and pyx the definition. You need to > write a class as MSE. Criterion is an abstract

Re: [scikit-learn] custom loss function in RandomForestRegressor

2018-02-15 Thread Guillaume Lemaître
ARIETAL > guillaume.lemai...@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 > RandomFo

Re: [scikit-learn] custom loss function in RandomForestRegressor

2018-02-15 Thread Andreas Mueller
On 02/15/2018 01:28 PM, Guillaume Lemaitre wrote: 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

Re: [scikit-learn] custom loss function in RandomForestRegressor

2018-02-15 Thread Thomas Evangelidis
vangelidis *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 c

Re: [scikit-learn] custom loss function in RandomForestRegressor

2018-02-15 Thread Guillaume Lemaitre
homas EvangelidisSent: Thursday, 15 February 2018 19:15To: Scikit-learn mailing listReply To: Scikit-learn mailing listSubject: Re: [scikit-learn] custom loss function in RandomForestRegressorSorry I don't know Cython at all. _criterion.pxd is like the header file in C++? I see that it cont

Re: [scikit-learn] custom loss function in RandomForestRegressor

2018-02-15 Thread Thomas Evangelidis
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"

Re: [scikit-learn] custom loss function in RandomForestRegressor

2018-02-15 Thread Andreas Mueller
I wonder whether this (together with the caveat about it being slow if doing python) should go into the FAQ. On 02/15/2018 12:50 PM, Guillaume Lemaître wrote: The ClassificationCriterion and RegressionCriterion are now exposed in the _criterion.pxd. It will allow you to create your own criterio

Re: [scikit-learn] custom loss function in RandomForestRegressor

2018-02-15 Thread Guillaume Lemaître
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 criteri

Re: [scikit-learn] custom loss function in RandomForestRegressor

2018-02-15 Thread Andreas Mueller
Yes, but if you write it in Python, not Cython, it will be unbearably slow. On 02/15/2018 12:37 PM, Thomas Evangelidis wrote: Greetings, 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

[scikit-learn] custom loss function in RandomForestRegressor

2018-02-15 Thread Thomas Evangelidis
Greetings, 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

Re: [scikit-learn] custom loss function

2017-09-14 Thread Andreas Mueller
On 09/13/2017 05:31 PM, Thomas Evangelidis wrote: What about the SVM? I use an SVR at the end to combine multiple MLPRegressor predictions using the rbf kernel (linear kernel is not good for this problem). Can I also implement an SVR with rbf kernel in Tensorflow using my own loss function? S

Re: [scikit-learn] custom loss function

2017-09-13 Thread federico vaggi
My bad, I looked at your question in the context of your 2nd e-mail in this topic where you talked about custom loss functions and SVR. On Wed, 13 Sep 2017 at 15:20 Thomas Evangelidis wrote: > I said that I want to make a Support Vector Regressor using the rbf kernel > to minimize my own loss fu

Re: [scikit-learn] custom loss function

2017-09-13 Thread Thomas Evangelidis
I said that I want to make a Support Vector Regressor using the rbf kernel to minimize my own loss function. Never mentioned about classification and hinge loss. On 13 September 2017 at 23:51, federico vaggi wrote: > You are confusing the kernel with the loss function. SVM minimize a well > def

Re: [scikit-learn] custom loss function

2017-09-13 Thread federico vaggi
You are confusing the kernel with the loss function. SVM minimize a well defined hinge loss on a space that's implicitly defined by a kernel mapping (or, in feature space if you use a linear kernel). On Wed, 13 Sep 2017 at 14:31 Thomas Evangelidis wrote: > What about the SVM? I use an SVR at th

Re: [scikit-learn] custom loss function

2017-09-13 Thread Thomas Evangelidis
What about the SVM? I use an SVR at the end to combine multiple MLPRegressor predictions using the rbf kernel (linear kernel is not good for this problem). Can I also implement an SVR with rbf kernel in Tensorflow using my own loss function? So far I found an example of an SVC with linear kernel in

Re: [scikit-learn] custom loss function

2017-09-13 Thread Andreas Mueller
On 09/13/2017 01:18 PM, Thomas Evangelidis wrote: ​​ Thanks again for the clarifications Sebastian! Keras has a Scikit-learn API with the KeraRegressor which implements the Scikit-Learn MLPRegressor interface: https://keras.io/scikit-learn-api/ Is it possible to change the loss function in

Re: [scikit-learn] custom loss function

2017-09-13 Thread Sebastian Raschka
> Is it possible to change the loss function in KerasRegressor? I don't have > time right now to experiment with hyperparameters of new ANN architectures. I > am in urgent need to reproduce in Keras the results obtained with > MLPRegressor and the set of hyperparameters that I have optimized for

Re: [scikit-learn] custom loss function

2017-09-13 Thread Thomas Evangelidis
​​ Thanks again for the clarifications Sebastian! Keras has a Scikit-learn API with the KeraRegressor which implements the Scikit-Learn MLPRegressor interface: https://keras.io/scikit-learn-api/ Is it possible to change the loss function in KerasRegressor? I don't have time right now to experime

Re: [scikit-learn] custom loss function

2017-09-13 Thread Sebastian Raschka
> What about the SVR? Is it possible to change the loss function there? Here you would have the same problem; SVR is a constrained optimization problem and you would have to change the calculation of the loss gradient then. Since SVR is a "1-layer" neural net, if you change the cost function to

Re: [scikit-learn] custom loss function

2017-09-13 Thread Thomas Evangelidis
Thanks Sebastian. Exploring Tensorflow capabilities was in my TODO list, but now it's in my immediate plans. What about the SVR? Is it possible to change the loss function there? Could you please clarify what the "x" and "x'" parameters in the default Kernel functions mean? Is "x" a NxM array, wher

Re: [scikit-learn] custom loss function

2017-09-11 Thread Sebastian Raschka
Hi Thomas, > For the MLPRegressor case so far my conclusion was that it is not possible > unless you modify the source code. Also, I suspect that this would be non-trivial. I haven't looked to closely at how the MLPClassifier/MLPRegressor are implemented but since you perform the weight update

[scikit-learn] custom loss function

2017-09-11 Thread Thomas Evangelidis
Greetings, I know this is a recurrent question, but I would like to use my own loss function either in a MLPRegressor or in an SVR. For the MLPRegressor case so far my conclusion was that it is not possible unless you modify the source code. On the other hand, for the SVR I was looking at setting