I followed the post you referred to and I got the results without errors. For me, the cross validation accuracy for 'fisheriris' dataset is 96.6667%. For you, I think the error is that the error is from 'svmtrain' just as the first comment said. In the following, I will show how I ran the code.
1) download the libsvm from http://www.csie.ntu.edu.tw/~cjlin/libsvm/ and unzip it.
2) change the names of files svmtrain.c
and svmpredict.c
in \libsvm-3.16\matlab\
to be libsvmtrain.c
and libsvmpredict.c
. And then locate make.m
in the same folder and change line 16 and line 17 to be
mex CFLAGS="\$CFLAGS -std=c99" -largeArrayDims libsvmtrain.c ../svm.cpp svm_model_matlab.c
mex CFLAGS="\$CFLAGS -std=c99" -largeArrayDims libsvmpredict.c ../svm.cpp svm_model_matlab.c
3) run make.m you just changed to mex *.c files.
4) following the accepted answer of the post 10 fold cross-validation in one-against-all SVM (using LibSVM) , you create four .m files for each function, crossvalidation.m
, libsvmcrossval_ova.m
, libsvmpredict_ova.m
, libsvmtrain_ova.m
and run the main function provided by that answerer, which is as follows:
clear;clc;
%# laod dataset
S = load('fisheriris');
data = zscore(S.meas);
labels = grp2idx(S.species);
%# cross-validate using one-vs-all approach
opts = '-s 0 -t 2 -c 1 -g 0.25'; %# libsvm training options
nfold = 10;
acc = libsvmcrossval_ova(labels, data, opts, nfold);
fprintf('Cross Validation Accuracy = %.4f%%\n', 100*mean(acc));
%# compute final model over the entire dataset
mdl = libsvmtrain_ova(labels, data, opts);
acc = libsvmtrain(labels, data, sprintf('%s -v %d -q',opts,nfold));
model = libsvmtrain(labels, data, strcat(opts,' -q'));
svmtrain
and the libsvmsvmtrain
? LIBSVM FAQ – Mariannamariannesvmtrain
. – Mariannamarianne