[scikit-learn] custom loss function

Andreas Mueller t3kcit at gmail.com
Thu Sep 14 16:41:42 EDT 2017



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? So far I found an example of an 
> SVC with linear kernel in Tensorflow and nothing in Keras. My 
> alternative option would be to train multiple SVRs and find through 
> cross validation the one that minimizes my custom loss function, but 
> as I said in a previous message, that would be a suboptimal solution 
> because in scikit-learn the SVR minimizes the default loss function.
>
Depends on what algorithm you want to use. As Frederico said, SVMs are 
usually solved as convex optimization problem on an infinite dimensional 
kernel space.
There is no straight-forward way to extend this to arbitrary losses afaik.
You can always make the kernel transformation explicit with Nystroem and 
solve a linear regression problem with custom loss on that.


More information about the scikit-learn mailing list