使用LIBSVM的多类 [英] MultiClass using LIBSVM

查看:203
本文介绍了使用LIBSVM的多类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个多类svm分类(6类)。我想使用LIBSVM对它进行分类。以下是我试过的,我有一些问题,他们。



Method1(一个对一个):

  model = svmtrain TrainLabel,TrainVec,'-c 1 -g 0.00154 -b 0.9'); 
[predict_label,accuracy,dec_values] = svmpredict(TestLabel,TestVec,model);

有关此方法的两个问题:1)是我需要做的多类问题
2)对于n in'-b n'应该有什么值。我不确定



方法2(一个vs休息):

  u = unique(TrainLabel); 
N = length(u);
if(N> 2)
itr = 1;
classes = 0;
while((classes〜= 1)&&(itr< = length(u)))
c1 =(TrainLabel == u(itr));
newClass = double(c1);
tst = double((TestLabel == itr));
model = svmtrain(newClass,TrainVec,'-c 1 -g 0.00154');
[predict_label,accuracy,dec_values] = svmpredict(tst,TestVec,model);
itr = itr + 1;
end
itr = itr-1;
end

对于第二种方法,如何附加分类分数。我不能投票。



此外,这是我尝试的两种方法。哪种方法更好?



想听听一些评论。

解决方案

关于'-b'参数,在LIBSVM自述文件中, p>

-b probability_estimates:是否为概率估计训练SVC或SVR模型,0或1(默认为0)



因此,如果你想要训练的模型返回类概率,你应该指定'-b 1';如果你没有返回类概率,你应该指定'-b 0'。您只需调用 svmtrain 一次。此外,如果为训练指定-b 1,则还必须指定它进行预测。


I have a multiclass svm classification(6 class). I would like to classify it using LIBSVM. The following are the ones that i have tried and i have some questions regarding them.

Method1( one vs one):

model = svmtrain(TrainLabel, TrainVec, '-c 1 -g 0.00154 -b 0.9');
[predict_label, accuracy, dec_values] = svmpredict(TestLabel, TestVec, model);

Two questions about this method: 1) is that all i need to do for multiclass problem 2) what value should it be for n in '-b n'. I m not sure

Method 2( one vs rest):

u=unique(TrainLabel); 
N=length(u); 
if(N>2)    
    itr=1;    
    classes=0;   
    while((classes~=1)&&(itr<=length(u)))   
        c1=(TrainLabel==u(itr));    
        newClass=double(c1); 
        tst = double((TestLabel == itr));
        model = svmtrain(newClass, TrainVec, '-c 1 -g 0.00154');  
        [predict_label, accuracy, dec_values] = svmpredict(tst, TestVec, model);    
        itr=itr+1;   
    end
    itr=itr-1;
end

For the second method,how do I attach classification scores. I am not able to do voting.

Besides that,these are the two methods I have tried. Which method is better?

Would like to hear some comments. Please correct me if I am wrong.

解决方案

Regarding the '-b' parameter, in the LIBSVM README it says:

-b probability_estimates: whether to train a SVC or SVR model for probability estimates, 0 or 1 (default 0)

Therefore, you should specify '-b 1' if you want the trained model to return class probabilities, and '-b 0' if you don't. You only need to call svmtrain once. Also, if you specify '-b 1' for training, you must also specify it for prediction.

这篇关于使用LIBSVM的多类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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