On 29 May 2017 at 08:27, Tiramisu Ling <saberge...@gmail.com> wrote: > Hi, I have a question about the difference between CBinaryLabels > and CMultilabelLabels. Why we need to make CBinaryLabels as {-1, 1} but > CMultilabelLabels define as {0,1...num_classs-1}? What about define > something like 'DigitalLabels' which can accept {-1, 0, 1, ...num_classes}, > or just use CBinaryLabels as {0, 1}. >
> Because we are going to Add global fixture with binary label data(issue > 3812 <https://github.com/shogun-toolbox/shogun/pull/3812/files>), and I > add some code(the for loop part > <https://github.com/shogun-toolbox/shogun/pull/3812/files#diff-9739eb22131152d61edc04fe3812921bR64>) > to make it could work with multilclass data(comment > <https://github.com/shogun-toolbox/shogun/pull/3812/files#r118416713>). > But the problem is CBinaryLabels can only accept -1 or 1 but > CMultilabelLabels have 0,1.... So I don't know how to generate two > different labels by *one *uniform process(don't need to distinguish or > specify which kind of label we want). And it seems like I can't cast from > one label to another directly. > I think the CBinaryLabels constructor with a threshold can help you to create them from a vector of 0s and 1s: https://github.com/shogun-toolbox/shogun/blob/develop/src/shogun/labels/BinaryLabels.cpp#L52 For your understanding, the reason why binary labels take values on {-1, 1} has probably to do with the fact that some binary classification algorithms are formulated succinctly exploiting these values. For example, consider a linear model with weight vector is w, bias b, the feature vector of data sample i is x_i and its label l_i. Note that l_i can be either -1 or 1. Learning could be expressed as, find awesome w and b subject to for all i, (w*x_i+b)l_i >= 0 > > Please give me some help about that. Thank you very much! > > Best Regards, > MikeLing > > >