登录论坛

查看完整版本 : Matlab中的支持向量机


poster
2019-12-14, 20:13
您能否在Matlab中使用支持向量机(SVM)给出4类分类的示例,例如:

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 (http://www.mathworks.com/help/toolbox/bioinfo/ref/svmtrain.html) (2类)实现此目的,但是使用标准SVM软件包会容易得多。

我使用过LIBSVM (http://www.csie.ntu.edu.tw/~cjlin/libsvm/) ,可以确认它非常易于使用。

%%# 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);

更多&回答... (https://stackoverflow.com/questions/4976539)