LIBSVM is an external Support Vector Machine software package that is used by the Libsvm_CL classifier object. In order use the Libsvm_CL classifier, the LIBSVM software package must be installed to work with Matlab. Below are instructions giving a few different ways to get the LIBSVM working with the libsvm_CL classifier object.

Use a precompiled version of LIBSVM

We have created a precompiled version of LIBSVM that should work with 32 bit (.mexw32) and 64 bit (.mexw64) windows operating systems, and with 64 bit Linux (.mexa64). To use the precompiled LIBSVM code, download the zip the files by clicking the link below, upzip the files, and put the directory libsvm-3.11/ in the ndt.1.0.0/external_libraries/ directory. Run the add_ndt_paths_and_init_rand_generator helper function to add the code to Matlab’s path and it should work.

Download precompiled LIBSVM 3.11

Download and compile LIBSVM on your system

If you are running an operating system not supported (or the above precompiled version of LIBSVM is not working), then you can compile LIBSVM into a MEX file on your own computer using the following instructions.

  1. Download either the zip file or the tar.gz file.
  2. Unzip the compressed files and put the directory libsvm-3.1.x/ into the directory ndt.1.0.0/external_libraries/.
  3. Compile the libsvm mex files. To do this, in Matlab go to the directory external_libraries/libsvm-3.1.x/matlab/’ and type the command >> make.
  4. Rename the compiled svmtrain mex file, to svmtrain2 (e.g., rename svmtrain.mexa64 to svmtrain2.mexa64). Note that depending on the operating system used, the extension of the svmtrain mex file will be slightly different (e.g., if you are using a 32 bit version of Windows, the file will be named svmtrain.w32 and one should rename it svmtrain2.w32). The reason that svmtrain needs to be renamed is because the matlab bioinformatics toolbox has a function that is also named svmtrain, thus creating a naming conflict with LIBSVM.

Suppressing LIBSVM command line output

If you compile LIBSVM yourself, a lot of output strings will printed to the Matlab command window when LIBSVM is run. This output can be suppressed by taking the following steps.

  1. Open the file svm.cpp, and change the line

    #if 1
    static void info(const char *fmt, ...)


    #if 0
    static void info(const char *fmt, ...)
  2. Open the file matlab/svmpredict.c and change (comment out) the following lines:

            mexPrintf("Accuracy = %g%% (%d/%d) (classification)\n", 


         // mexPrintf("Accuracy = %g%% (%d/%d) (classification)\n",
         //       (double)correct/total*100,correct,total);
  3. Recompile the mex file and rename it to svmtrain2 as described in steps 3 and 4 above.