Wednesday, November 19, 2014

Run LibSVM in Octave on Ubuntu 14.04 LTS

If you do not have octave installed, run the following command in the terminal:
$sudo apt-get upgrade
$sudo apt-get update
$sudo apt-get install octave
$sudo apt-get install liboctave-dev

 After this, download the LibSVM from the following link:

unzip by running the tar xfz [libsvm tar file] command

create a working directory under your $HOME directory with a name, said, "OctaveProjects". now copy the unzipped libsvm-3.20 folder into the OctaveProjects folder.

Now type "octave" in the search box of Ubuntu to launch it, in the octave program, type the following command to goto the libsvm's matlab folder:
$cd $HOME/OctaveProjects/libsvm-3.20/matlab

type the following command to invoke the make.m in the libsvm's matlab folder:


Once the matlab interface for libsvm has been built, go back to the OctaveProjects folder by typing the following command:
$cd $HOME/OctaveProjects

Now run the following command to add the libsvm path:
$addpath './libsvm3.20/matlab';

You can now run the libsvm, below is the usage from README in libsvm:


octave> model = svmtrain(training_label_vector, training_instance_matrix [, 'libsvm_options']);

            An m by 1 vector of training labels (type must be double).
            An m by n matrix of m training instances with n features.
            It can be dense or sparse (type must be double).
            A string of training options in the same format as that of LIBSVM.

octave> [predicted_label, accuracy, decision_values/prob_estimates] = svmpredict(testing_label_vector, testing_instance_matrix, model [, 'libsvm_options']);
octave> [predicted_label] = svmpredict(testing_label_vector, testing_instance_matrix, model [, 'libsvm_options']);

No comments:

Post a Comment