LibSVM3.21 Matlab 安装

1、下载libsvm 3.21,下载地址http://www.csie.ntu.edu.tw/~cjlin/libsvm/
2、将工具包放到任何地方均可,将工具包添加到Matlab的搜索路径。Set Path->add with subfolders->save !!一定是subfolders
3、编译。mex -setup 注意:mex后要有空格,然后再是-。会有以下提示
mex -setup

MEX configured to use 'Microsoft Visual C++ 2010 (C)' for C language compilation.
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/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.
To choose a different language, select one from the following:
 mex -setup C++ 
 mex -setup FORTRAN

这时你需要用鼠标点击 mex -setup C++.或者输入mex -setup C++,之后会出现

MEX configured to use 'Microsoft Visual C++ 2010' for C++ language compilation.
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/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.

4、编译文件 make
Matlab工作目录进入到libsvm-3.21/matlab,输入make

Building with 'Microsoft Visual C++ 2010 (C)'.
MEX completed successfully.
Building with 'Microsoft Visual C++ 2010 (C)'.
MEX completed successfully.
Building with 'Microsoft Visual C++ 2010'.
MEX completed successfully.
Building with 'Microsoft Visual C++ 2010'.
MEX completed successfully.

看到这个结果说明编译成功。

5、检查SVM是否安装成功
在libsvm-3.21可以看到hear_scale 文件,在命令行输入下面几行代码

clear;
[label_vector, instance_matrix] =libsvmread('heart_scale');
model = svmtrain(label_vector, instance_matrix);
[predicted_label, accuracy, prob_estimates] = svmpredict(label_vector, instance_matrix, model, 'b');

运行成功之后的结果

optimization finished, #iter = 162
nu = 0.431029
obj = -100.877288, rho = 0.424462
nSV = 132, nBSV = 107
Total nSV = 132
Accuracy = 86.6667% (234/270) (classification)

如有问题看readme.md文档

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值