liblinear icon indicating copy to clipboard operation
liblinear copied to clipboard

Subproblem negative class weight is always set to 1 in OVR classification

Open vbogach opened this issue 5 years ago • 1 comments

It's possible to set both negative and positive class weights in a binary classification scenario. However, when a multi-class classification model is trained using a OVR solver, it's possible to set weight only for the positive (i.e. One) class, but the weight for the negative (i.e. Rest) class is always set to 1.

The difference can be seen in https://github.com/cjlin1/liblinear/blob/master/linear.cpp#L2552 where train_one uses both weights and https://github.com/cjlin1/liblinear/blob/master/linear.cpp#L2578 where param->C is used. That corresponds to always using 1 as a weight.

That doesn't allow class weight normalization, and unnormalized weights bias the C term.

vbogach avatar Jun 16 '20 11:06 vbogach

I don't think we will add this as an option, but I think you can easily modify the code for your purpose.

On 2020-06-16 19:51, Vladimir Bogachev wrote:

It's possible to set both negative and positive class weights in a binary classification scenario. However, when a multi-class classification model is trained using a OVR solver, it's possible to set weight only for the positive (i.e. One) class, but the weight for the negative (i.e. Rest) class is always set to 1.

The difference can be seen in https://github.com/cjlin1/liblinear/blob/master/linear.cpp#L2552 where train_one uses both weights and https://github.com/cjlin1/liblinear/blob/master/linear.cpp#L2578 where param->C is used for the negative weight.

-- You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub [1], or unsubscribe [2]. [ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/cjlin1/liblinear/issues/64", "url": "https://github.com/cjlin1/liblinear/issues/64", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]

Links:

[1] https://github.com/cjlin1/liblinear/issues/64 [2] https://github.com/notifications/unsubscribe-auth/ABI3BHWBDKJ4QATKK2RRPTDRW5MDDANCNFSM4N7RINWA

cjlin1 avatar Jun 16 '20 12:06 cjlin1