Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LIBSVM in MATLAB/Octave - what's the output of libsvmread?

The second output of the libsvmread command is a set of features for each given training example.

For example, in the following MATLAB command:

[heart_scale_label, heart_scale_inst] = libsvmread('../heart_scale');

This second variable (heart_scale_inst) holds content in a form that I don't understand, for example:

<1, 1> -> 0.70833

What is the meaning of it? How is it to be used (I can't plot it, the way it is)?

PS. If anyone could please recommend a good LIBSVM tutorial, I'd appreciate it. I haven't found anything useful and the README file isn't very clear... Thanks.

like image 515
Cheshie Avatar asked Mar 22 '23 16:03

Cheshie


1 Answers

The definitive tutorial for LIBSVM for beginners is called: A Practical Guide to SVM Classification it is available from the site of the authors of LIBSVM.

The second parameter returned is called the instance matrix. It is a matrix, let call it M, M(1,:) are the features of data point 1 and so on. The matrix is sparse that is why it prints out weirdly. If you want to see it fully print full(M).

[heart_scale_label, heart_scale_inst] = libsvmread('../heart_scale');

with heart_scale_label and heart_scale_inst you should be able to train an SVM by issuing:

mod = svmtrain(heart_scale_label,heart_scale_inst,'-c 1 -t 0');

I strong suggest you read the above linked guide to learn how to set the c parameter (and possibly, in case of RBF kernel the gamma parameter), but the above line is how you would train with that data.

like image 90
carlosdc Avatar answered Mar 31 '23 21:03

carlosdc