MATLAB-LIBSVM安装及测试过程
一、matlab的安装过程
我安装的是matlab.R2010b.ISO-TBE版本(经过多次试验,为了使其能成功作为LIBSVM
工具箱的加强版libsvm-3.1-[FarutoUltimate3.1Mcode]的开发平台,最终还是MATLAB2010
版本即matlab.R2010b.ISO-TBE最好),安装时注意问
题
快递公司问题件快递公司问题件货款处理关于圆的周长面积重点题型关于解方程组的题及答案关于南海问题
如下几点:
1、完全按照《matlab2010b的安装说明》来操作,只不过我选择里面的“典型”安装,
激活部分,我选择第一个问题且
答案
八年级地理上册填图题岩土工程勘察试题省略号的作用及举例应急救援安全知识车间5s试题及答案
是添加license file文件路径,如
……\matlab.R2010b.ISO-TBE\crack\ license_standalone.dat
2、尽量安装在C盘,尽管网上说可以安装在其他盘,但我经过多次失败后,最终觉得
还是安装在C盘好,可以避免很多麻烦。
3、在安装matlab.R2010b.ISO-TBE版本前,我先安装了MATLABA7.0版本,发现自己
电脑的桌面主题必须为windows经典或windows xp,否则又会有问题出现。但是后来我卸载
了MATLAB7.0,安装matlab.R2010b.ISO-TBE版本时由于电脑桌面主题已经是windows xp,
所以很顺利,不知道如果不是,会不会出问题。
二、libsvm的安装过程
我选择的是libsvm-3.1-[FarutoUltimate3.1Mcode]版本,据说此版本是libsvm-3.1的加强
版,安装是注意问题有以下几点:
1、设置路径。具体操作为打开matlab.R2010b.ISO-TBE,在File->SetPath->Add with
Subfolders…下添加libsvm-3.1-[FarutoUltimate3.1Mcode]的存放位置,然后点击Save,再然
后点击Close。
2、输入mex –setup,连接合适的编译器。具体情况如下:
>> mex -setup
Please choose your compiler for building external interface (MEX) files:
Would you like mex to locate installed compilers [y]/n? y
Select a compiler:
[1] Lcc-win32 C 2.4.1 in C:\PROGRA~1\MATLAB\R2010b\sys\lcc
[2] Microsoft Visual C++ 2010 in C:\Program Files\Microsoft Visual Studio 10.0
[3] Microsoft Visual C++ 6.0 in C:\Program Files\Microsoft Visual Studio
[0] None
Compiler: 3
Please verify your choices:
Compiler: Microsoft Visual C++ 6.0
Location: C:\Program Files\Microsoft Visual Studio
Are these correct [y]/n? y
Trying to update options file: C:\Documents and
Settings\Administrator\Application Data\MathWorks\MATLAB\R2010b\mexopts.bat
From template:
C:\PROGRA~1\MATLAB\R2010b\bin\win32\mexopts\msvc60opts.bat
Done . . .
*********************************************************************
Warning: The MATLAB C and Fortran API has changed to support MATLAB
variables with more than 2^32-1 elements. In the near future
you will be required to update your code to utilize the new
API. You can find more information about this at:
9
Building with the -largeArrayDims option enables the new API.
********************************************************************* 说明:蓝色部分为运行过程,红色字体为我自己的输入;Done . . .表示编译器连接成功。
3、修改当前文件路径。将Current Folder的内容由当前的C:\Program Files\MATLAB改为:……\libsvm-3.1-[FarutoUltimate3.1Mcode]\matlab
说明:修改后的文件路径是libsvm-3.1-[FarutoUltimate3.1Mcode]的位置,记得要具体到libsvm-3.1-[FarutoUltimate3.1Mcode]下面的matlab(不能忘记了)。
4、输入make进行测试。运行正确的话,会如下所示:
>> make
>>
到这一步,表示整个matlab和libsvm安装成功~
结果是生成下图中文件
特别是生成svmpredict.mexw32和svmtrain.mexw32 三、在matlab里测试libsvm是否能用。
具体测试(简单测试)如下所示:
>> load heart_scale
>> model=svmtrain(heart_scale_label,heart_scale_inst)
model =
Parameters: [5x1 double]
nr_class: 2
totalSV: 132
rho: 0.4245
Label: [2x1 double]
ProbA: []
ProbB: []
nSV: [2x1 double]
sv_coef: [132x1 double]
SVs: [132x13 double]
>> [predict_label,accuracy]=svmpredict(heart_scale_label,heart_scale_inst,model)
Accuracy = 86.6667% (234/270) (classification)
predict_label =
1
-1
-1
1
-1
-1
1
1
1
1
1
1
-1
-1
-1
-1
1
1
-1
-1
1
-1
-1
-1
-1
-1
-1
-1
1
-1
1
1
-1
1
1
1
1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1
-1
1
1
1
-1
-1
-1
-1
-1
1
-1
-1
1
-1
1
-1
-1
-1
1
-1
-1
-1
-1
1
-1
-1
-1
-1
1
1
-1
-1
-1
1
1
1
-1
1
-1
-1
-1
-1
1
-1
-1
1
1
1
1
-1
1
-1
-1
-1
-1
-1
1
1
1
-1
1
1
-1
1
-1
-1
-1
-1
-1
1
1
-1
1
1
1
1
-1
-1
-1
1
-1
-1
1
1
1
-1
1
1
-1
-1
1
-1
1
1
-1
1
-1
1
1
-1
1
1
-1
-1
-1
-1
-1
-1
-1
1
-1
-1
1
-1
-1
-1
1
-1
-1
-1
-1
-1
-1
-1
1
1
-1
-1
1
1
-1
1
-1
-1
1
1
-1
-1
-1
1
1
-1
1
-1
1
-1
1
-1
-1
-1
-1
-1
1
-1
1
1
1
1
-1
-1
1
1
-1
-1
-1
-1
1
-1
-1
-1
1
1
-1
1
1
-1
1
-1
-1
1
1
-1
-1
1
1
-1
1
1
1
-1
1
-1
-1
1
-1
-1
1
-1
1
1
-1
-1
1
1
-1
-1
-1
-1
-1
-1
1
-1
-1
-1
1
-1
-1
-1
-1
-1
-1
-1
1
accuracy =
86.6667
0.5333
0.5326
>>
到这一步表示测试成功~ 另外,测试结果如下图所示: