How to do multiple label classification using libSVM

I am a beginner of MATLAB and to be honest, quite weak in mathematics. I am trying to use libSVM to classify data between multiple classes. I am reading the data from `xlsx` file and following this code but *the issue is that svmpredict function takes two double vectors and I need to process one text vector (labels) and one double matrix (data)*. Basically I want to convert the following SVM code to libSVM (for multiple classes)
*SVM Code:*
%%Read the .xlsx file and build SVM model for English and Urdu data
name = strcat(fileName,'.xlsx');
[English] = xlsread(name,1,'C:H');
[Urdu] = xlsread(name,2,'C:H');
[Test_data] = xlsread(name,3,'C:H');
[~, labels1]=xlsread(name,3,'I:I');
test_labels=labels1(2:end);
labels=[1*ones(size(English,1),1) ; 2*ones(size(Urdu,1),1)];
data = [English ; Urdu];
SVMStruct = svmtrain(data,labels);
%%Generate the output file
% result will be an array containing 0 for the points
% detected as Urdu ones and 1 for the English detected
% points.
result = svmclassify(SVMStruct,Test_data);
The above code works fine for two classes and now I want to classify between multiple classes. Someone please guide me about any function/tutorial etc to classify data between multiple classes.

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Statistics and Machine Learning Toolbox 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by