Using Libsvm under Linux

  
 

I recently installed Ubuntu on my laptop, lamenting that the current Linux technology is developing too fast. Many operations are no different from Windows
, and many applications under Windows
have Corresponding Linux version. It should be said that using Ubuntu is quite convenient. So I changed my work platform to Ubuntu.


Change to the Ubuntu platform, I need to install a few applications, mainly my own work requires MATLAB and LIBSVM. Let's write down the problems and some experience that occurred during the installation of these two softwares. One is to facilitate your reference later, and the other is to provide a reference for others.

This article first talks about how to install and use Libsvm on the Ubuntu platform (I downloaded the version is 2.91).

1. Download: First download the version tar.gz under Linux from http://www.csie.ntu.edu.tw/~cjlin/libsvm/.

2. Unzip: Unzip to any directory, here I unzip to /home/xxxxxx/libsvm-2.91. /home/xxxxxx/is my user directory, xxxxxx is the username.

3. Compile: Go to /home/xxxxxx/libsvm-2.91, enter the command make (you can complete the installation, but sometimes the following error will occur)

g++ -Wall -Wconversion - O3 -fPIC -c svm.cpp

make: g++: Command not found

make: *** [svm.o] Error 127

4, error resolution: This error is not required for the compiler and needs to be installed. 5, install g++ compiler: enter the command apt-get install g++6 in the terminal, recompile: after installing g++ successfully, you can compile again, compile successfully, use libsvm7, Libsvm use A. Use svm-train training: Enter ./svm-train heart_scaleB in the terminal. Use svm-predict to predict: enter ./svm-predict heart_scale in the terminal. heart_scale.model outheart_scale is test file, heart_scale.model is trained by svm-train to model file, out is prediction Output file. 8. If you want to use easy.py and grid.py to perform the above steps 7 faster. Because python and gunplot are already installed in Ubuntu, these two softwares can be omitted for installation. After entering /home/xxxxxx/libsvm-2.91/tools to the directory, just enter it in the terminal:

python easy.py /home/xxxxxx/libsvm-2.91/SYN /home/xxxxxx/libsvm-2.91 /SYN2NMF

The SYN is used to build the model pair training file; SYN2NMF is the result of the need to predict the file: Best c=2.0, g=0.0078125 CV rate=77.45Training…Output model: SYN.modelScaling testing data&hellip ;Testing…Accuracy = 83.35% (1667/2000) (classification) Output prediction: SYN2NMF.predictPS: During the installation process, it is best to first enter sudo -i in the terminal to switch to the root user mode to avoid permission errors.

Copyright © Windows knowledge All Rights Reserved