Matlab中的支持向量机 [英] support vector machines in matlab
本文介绍了Matlab中的支持向量机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您能否举一个使用matlab中的支持向量机(SVM)进行4类分类的示例:
Could you give an example of classification of 4 classes using Support Vector Machines (SVM) in matlab something like:
atribute_1 atribute_2 atribute_3 atribute_4 class
1 2 3 4 0
1 2 3 5 0
0 2 6 4 1
0 3 3 8 1
7 2 6 4 2
9 1 7 10 3
推荐答案
MATLAB目前不支持多类SVM.您可以使用 svmtrain
(两类)来实现这样,但是使用标准的SVM软件包会容易得多.
MATLAB does not support multiclass SVM at the moment. You could use svmtrain
(2-classes) to achieve this, but it would be much easier to use a standard SVM package.
我使用了 LIBSVM 和可以确认它非常易于使用.
I have used LIBSVM and can confirm that it's very easy to use.
%%# Your data
D = [
1 2 3 4 0
1 2 3 5 0
0 2 6 4 1
0 3 3 8 1
7 2 6 4 2
9 1 7 10 3];
%%# For clarity
Attributes = D(:,1:4);
Classes = D(:,5);
train = [1 3 5 6];
test = [2 4];
%%# Train
model = svmtrain(Classes(train),Attributes(train,:),'-s 0 -t 2');
%%# Test
[predict_label, accuracy, prob_estimates] = svmpredict(Classes(test), Attributes(test,:), model);
这篇关于Matlab中的支持向量机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文