带有huber损失的python svm函数 [英] python svm function with huber loss

查看:314
本文介绍了带有huber损失的python svm函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要具有Huber损失功能的python的svm分类器。但是它的默认损失功能是铰链损失。您知道如何为Python svm分配损失函数吗?

  svc = svm.SVC(kernel ='linear',C = 1,gamma = 1)。fit(数据,标签)


解决方案

实际上,没有带有Huber损失的SVM之类的东西,因为SVM实际上是经过铰链损失训练的线性(或内核化)模型。如果您更改损失-它不再是SVM。因此,库没有损失参数,因为更改它不适用于SVM概念。



如果您想使用模型您可以使用 SGDClassiifier

如果您想做更复杂的事情,例如带有这种惩罚-sklearn不是一个好选择,您应该查看更多的低级库,例如TF,Keras等。


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)

解决方案

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.

这篇关于带有huber损失的python svm函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆