Kernlab中的类权重语法? [英] Class Weight Syntax in Kernlab?
问题描述
我正在尝试使用kernlab
包对R中的不平衡数据集进行分类,因为类分布不是1:1,所以我在ksvm()
函数调用中使用了class.weights选项,但是我没有得到添加权重或删除权重时,分类方案有何不同?因此,问题是声明类权重的正确语法是什么?
Hi I am trying out classification for imbalanced dataset in R using kernlab
package, as the class distribution is not 1:1 I am using the option of class.weights in the ksvm()
function call however I do not get any difference in the classification scenario when I add weights or remove weights? So the question is what is the correct syntax for declaring the class weights?
我正在使用以下函数调用:
I am using the following function calls:
model = ksvm(dummy[1:466], lab_tr,type='C-svc',kernel=pre,cross=10,C=10,prob.model=F,class.weights=c("Negative"=0.7,"Positive"=0.3))
#this is the function call with class weights
model = ksvm(dummy[1:466], lab_tr,type='C-svc',kernel=pre,cross=10,C=10,prob.model=F)
任何人都可以对此发表评论,我是否遵循增加权重的正确语法?我还发现,如果我们将权重与prob.model=T
一起使用,则ksvm
函数将返回错误!
Can anyone please comment on this, am I following the right syntax of adding weights? Also I discovered that if we use the weights with prob.model=T
the ksvm
function returns a error!
推荐答案
您的语法还可以,但是在机器学习中,不平衡类的问题相当普遍.从某种意义上说,从较大的类中删除某些对象是保证工作的唯一方法,但它仍然可能是错误增加的根源,并且必须谨慎地以智能方式进行操作(在SVM中,潜在的支持向量应该具有优先权-当然,现在有一个问题如何定位它们.)
您还可以尝试通过简单的长度比率来增加权重,比如说十倍,然后检查它是否甚至稍微或幸运地帮助了另一侧的不平衡.
Your syntax is ok, but the problem of not-working-class-balance is fairly common in machine learning; in a way, the removal of some objects from the bigger class is an only method guaranteed to work, still it may be a source of error increase, and one must be careful to do it in an intelligent way (in SVM the potential support vectors should have the priority - of course now there is a question how to locate them).
You may also try to boost the weights over simple length ratio, lets say ten-fold, and check if it helped even a little or luckily rather overshoot the imbalance to the other side.
这篇关于Kernlab中的类权重语法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!