zoukankan      html  css  js  c++  java
  • LibSvm添加到Matlab

    1.下载libSVM工具包

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

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

    如我的目录C:Program FilesMATLABR2012a oolboxlibsvm

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

    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:UsersWindAppDataRoamingMathWorksMATLABR2012amexopts.bat 
    From template:              C:PROGRA~1MATLABR2012ainwin64mexoptsmsvc90opts.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)

    证明已经配置完成

      

     


    作者:KeithMorning
    出处:http://www.cnblogs.com/keithmoring/
    关于作者:欢迎转载,且在文章页面明显位置给出原文链接
    如有问题,可以通过keith@keithmorning.com 联系我,非常感谢。

  • 相关阅读:
    java与C#区别1
    简单解决Linq多条件组合问题<转>
    散列表(哈希表)工作原理<转>
    在Eclipse中设置中文JavaDOC<转>
    Cucumber入门之_argument
    Cucumber入门之Gherkin
    网上常用免费WebServices集合
    watir学习baidu搜索示例
    使用Cucumber的15个建议
    Cucumber入门之_World
  • 原文地址:https://www.cnblogs.com/keithmoring/p/3719070.html
Copyright © 2011-2022 走看看