I am trying to implement multiclass classification vs rest using LIBSVM.
This link was useful http://www.csie.ntu.edu.tw/~cjlin/libsvmtools/ovr_multiclass/
but I get an error in the function "ovrpredict ()".
The function is as follows:
function [pred, ac, decv] = ovrpredict(y, x, model)
labelSet = model.labelSet;
labelSetSize = length(labelSet);
models = model.models;
decv= zeros(size(y, 1), labelSetSize);
for i=1:labelSetSize
[l,a,d] = svmpredict(double(y == labelSet(i)), x, models{i});
decv(:, i) = d * (2 * models{i}.Label(1) - 1); % ERROR IN THIS LINE
end
[tmp,pred] = max(decv, [], 2);
pred = labelSet(pred);
ac = sum(y==pred) / size(x, 1);
The error message I get is this Reference to non-existent field 'Label'.
Any suggestions would be really helpful.
EDIT 1
Code used to call functions: \
[trainY trainX]=libsvmread('libfacecombine.train');
[testY testX]=libsvmread('libfacetest.train');
model=ovrtrain(trainY,trainX,'-c 8 -g 4');
[~,accuracy,~]=ovrpredict(testY,testX,model);
The training and testing data with "libfacecombine.train" and "libfacetest.train" are written from CSV files:
f1=createdabase(f); % where createdatabase is a function to read various images from a folder and arrange into 1D array
[sig1 mn1]=pcam(f1); % where pcam is a function to find 'pca'(sig1) and 'mean'(mn1) of the data
%labelling is done this way:
%Positive class
label=[];
for i=1:length(sig1)
for j=1:1
label(i,j)=+1;
end
end
csvwrite('face1.csv',[label sig1]);
%Negative class
label1=[];
for i=1:length(sig2) % sig2 obtained in same way as sig1
for j=1:1
label1(i,j)=-1;
end
end
csvwrite('face2.csv',[label sig2]);
Using the append mode, both of these files are combined and converted to .train files. The same is done for test data.
EDIT 2
5 . :
1: +1 4 Face 1 -1 4 Face 1 ( 2,3,4 5). 2: +2 4 Face 2 -2 4 Face 2 ( 1,3,4 5).... 5: +5 4 5 -5 4 Face 5 ( 1,2,3 4). .csv , .train. .
1 i.e +1 CSV , .train. , . , , :
Accuracy=92%(12/13)classification;
Accuracy=61%(8/13)classification;
Accuracy=100%(13/13)classification;
Accuracy=100%(13/13)classification;
Accuracy=100%(13/13)classification;
Accuracy=100%(13/13)classification;
6 , 5 ?