python svm function with huber loss

假装没事ソ 提交于 2019-12-11 15:30:10

问题


I need a svm classifier of python with huber loss function. But its default loss function is hinge loss. Do you know how can I assign loss function to python svm?

svc = svm.SVC(kernel='linear', C=1, gamma=1).fit(data, label)

回答1:


There is really no such thing as "SVM with huber loss", as SVM is literally a linear (or kernelized) model trained with hinge loss. If you change the loss - it stops being SVM. Consequently libraries do not have a loss parameter, as changing it does not apply to the SVM concept.

If you want to train a model with huber loss you can use SGDClassiifier from sklearn, which will train a linear model with this (and many other) loss.

If you want to do something more complex, like non-linear model with this kind of penalty - then sklearn is not the good choice and you should look at more "low-level" libraries such us TF, Keras and so on.



来源:https://stackoverflow.com/questions/45698160/python-svm-function-with-huber-loss

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!