using svm is it possible to assign a cost value to each class

29 views
Skip to first unread message

n.shayanfar

unread,
May 14, 2014, 7:00:37 AM5/14/14
to accor...@googlegroups.com
Hi
I'm using the svm in the package to do some machine learning. is it possible to assign a cost value to each class label? this would result to two cost values per sv machine. i'm asking this because i have a highly unbalanced dataset.

César

unread,
May 14, 2014, 9:34:00 AM5/14/14
to accor...@googlegroups.com
Hi there,

Yes, it should be possible! I would suggest taking a look at the WeightRatio property of the SequentialMinimalOptimization class. By setting this property to a value lesser than one, such as 1/10 (0.1) means 10% of C will be applied to the positive class, while 100% of C will be applied to the negative class. On the other hand, if the weight ratio is set to be greater than one, such as 10/1 (10), it will mean that 100% of C will be applied to the positive class, while 10% of C will be applied to the negative class. You can then proceed learning as normal.

If instead of setting the weight ratio between the two classes, you would like to set different C values for each of the classes manually, you can do so by setting the NegativeWeight and PositiveWeight properties of this same class. However, I would say that setting just the ratio directly could be regarded as more intuitive in this case.

Hope it helps!

Best regards,
Cesar

nshay...@gmail.com

unread,
May 17, 2014, 11:28:40 AM5/17/14
to accor...@googlegroups.com
Great answer cesar. helped a lot. thanks a lot
Reply all
Reply to author
Forward
0 new messages