• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

LibSvm添加到Matlab

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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)

证明已经配置完成

  

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
自动创建数据库(DELPHI+SQLSERVER)发布时间:2022-07-18
下一篇:
matlabnormspec叠加图发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap