LIBSVM installation under MATLAB

Source: Internet
Author: User

1) Download the latest version of LIBSVM from LIBSVM's official website http://www.csie.ntu.edu.tw/~cjlin/libsvm/, the current version is Libsvm-3.18.zip

2) Unzip the package to a location on your computer, such as: C:\Program files\libsvm-3.18

3) Assume that you are using a 64-bit operating system and MATLAB. The Windows directory under the libsvm-3.18 folder is now added to the MATLAB directory. In the MATLAB directory, add: C:\ProgramFiles\libsvm-3.18\windows. Because Windows contains a binary file that MATLAB can perform libsvmread.mexw64/libsvmwrite.mexw64/svmpredict.mexw64/svmtrain.mexw64

4) Assuming you are using a 32-bit operating system and MATLAB, you will need to compile the appropriate binaries yourself.

In the MATLAB command window, enter

>>mex–setup

At this point, Matlab will prompt you to choose the C/C + + compiler to compile the Mex file (first enter n, then select the corresponding compiler).

Select one of the C + + compilers installed on your PC, such as Microsoft Visual C + + 2010

Set matlab current directory to: CD ' C:\Program Files\libsvm-3.18\matlab '

Enter command make

At this point you will see that the current directory generates binary files (4):

Libsvmread.mexw32

Libsvmwrite.mexw32

Svmpredict.mexw32

Svmtrain.mexw32

Add the current directory to the MATLAB path.

5) Example a test

Notice that there is a data file under libsvm-3.18 with the name Heart_scale. This is a data file in LIBSVM format. You can use the Libsvmread function to convert it to MATLAB format.

Use the following command to test:

[Heart_scale_label,heart_scale_inst]=libsvmread (' Heart_scale ');

Model = Svmtrain (Heart_scale_label,heart_scale_inst, '-C 1-g 0.07 ');

[Predict_label, accuracy, dec_values] =svmpredict (Heart_scale_label, heart_scale_inst, model); % test the Trainingdata

If one line appears: accuracy = 86.6667% (234/270) (classification). That means it's a success. You can use SVM in MATLAB.

6) since Svmtrain and original MATLAB have conflicting functions, the following command shows which version of the Svmtrain function is being used

Which Svmtrain

7) because the Svmtrain function in LIBSVM has the same name as the Svmtrain function in MATLAB, when you install LIBSVM and want to use the Svmtrain function that comes with MATLAB, you can put the path that you added in 3) to the end.

LIBSVM installation under MATLAB

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.