Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
794 views
in Technique[技术] by (71.8m points)

windows - How to run libsvm in MATLAB?

How to get started with libsvm under MATLAB?

I've downloaded the library, and extracted it in C:Program FilesMATLABR2012aoolbox, but then I don't know how to use it in MATLAB.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Download and extract libsvm in a directory of your choosing, say C:libsvm

As described in the C:libsvmmatlabREADME file, first you have to make sure a supported C/C++ compiler is installed. Note that on 64-bit systems, you need the correct 64-bit version of the compiler (e.g. Windows SDK is needed for Visual Studio Express edition)

>> mex -setup

Once you have selected a compiler, you need to compile the MEX-files:

>> cd('C:libsvmmatlab')
>> make

Finally add the folder with the generated binaries to the MATLAB search path:

>> addpath('C:libsvmmatlab')

Test the library with a simple example (fake data):

>> labels = double(rand(10,1)>0.5);
>> data = rand(10,5);
>> model = svmtrain(labels, data, '-s 0 -t 2 -c 1 -g 0.1')

Note that the current version of libsvm includes pre-compiled 64-bit MEX-files for Windows. The binaries are located in C:libsvmwindows*.mexw64 (copy those to the matlab subfolder from above)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...