LibSvm添加到Matlab

1.下载libSVM工具包

http://pan.baidu.com/s/1bnGNTBT或者下载最新版的到http://www.csie.ntu.edu.tw/~cjlin/libsvm/

2.解压缩后放在matlab的toolbox目录下

如我的目录C:\Program Files\MATLAB\R2012a\toolbox\libsvm

3.打开matlab,matlab的菜单 File->Set Path->add with subfolders(可直接用Add Folder)里,把C:\Program Files\MATLAB\R2011a\toolbox\libsvm\matlab目录也添加进去

4.在matlab中输入mex –setup

>> mex -setup
 
Welcome to mex -setup.  This utility will help you set up  
a default compiler.  For a list of supported compilers, see  
http://www.mathworks.com/support/compilers/R2012a/win64.html 
 
Please choose your compiler for building MEX-files: 
 
Would you like mex to locate installed compilers [y]/n? y
 
Select a compiler: 
[1] Microsoft Visual C++ 2008 SP1 in C:\Program Files (x86)\Microsoft Visual Studio 9.0 
 
[0] None 
 
Compiler: 1
 
Please verify your choices: 
 
Compiler: Microsoft Visual C++ 2008 SP1  
Location: C:\Program Files (x86)\Microsoft Visual Studio 9.0 
 
Are these correct [y]/n? y
 
*************************************************************************** 
  Warning: MEX-files generated using Microsoft Visual C++ 2008 require 
           that Microsoft Visual Studio 2008 run-time libraries be  
           available on the computer they are run on. 
           If you plan to redistribute your MEX-files to other MATLAB 
           users, be sure that they have the run-time libraries. 
*************************************************************************** 
 
 
Trying to update options file: C:\Users\Wind\AppData\Roaming\MathWorks\MATLAB\R2012a\mexopts.bat 
From template:              C:\PROGRA~1\MATLAB\R2012a\bin\win64\mexopts\msvc90opts.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: 
           http://www.mathworks.com/help/techdoc/matlab_external/bsflnue-1.html 
           Building with the -largeArrayDims option enables the new API. 
************************************************************************** 

不同的电脑因为安装的vc版本不同可能会出现不同的结果

5.在matlab current Floder中进入libSVM下的matlab路径

在matlab中输入make

如果顺利的话,可以正确编译

6.测试是否安装

>>[heart_scale_label,heart_scale_inst] =libsvmread('heart_scale');
>>model = svmtrain(heart_scale_label, heart_scale_inst, '-c 1 -g 0.07');

  *
  optimization finished, #iter = 134
  nu = 0.433785
  obj = -101.855060, rho = 0.426412
  nSV = 130, nBSV = 107
  Total nSV = 130

>>[predict_label, accuracy, dec_values] = svmpredict(heart_scale_label, heart_scale_inst, model); %

输出

Accuracy = 86.6667% (234/270) (classification)

证明已经配置完成

  

 

转载于:https://www.cnblogs.com/keithmoring/p/3719070.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值