libsvm 其中的matlab使用
2016-02-29 16:03
489 查看
首先libsvm确实是非常的好用,有各种语言的版本还有可视化窗口可以查看效果
那么接下来就是libsvm其中matlab文件包的使用(当然其中有可视化版本)
1.matlab工具包安装
首先输入mex -setup安装一下
Would you like mex to locate installed compilers [y]/n? y
Select a compiler:
[1] Microsoft Visual C/C++ version 7.1 in C:\Program Files\Microsoft Visual Studio
[0] None
Compiler: 1
Please verify your choices:
Compiler: Microsoft Visual C/C++ 7.1
Location: C:\Program Files\Microsoft Visual Studio
Are these correct?([y]/n): y
然后呢,就是输入make,成功以后,既可以使用啦!
2.工具包使用(matlab代码)
[a1,a2,a3,a4,a5] = textread('C:\Users\Administrator\Desktop\ceshi\ceshi.txt','%f%f%f%f%f','headerlines',0)
train_data = [a1,a2,a3,a4];
train_label = a5;
model = svmtrain(train_label,train_data);
patchname='C:\Users\Administrator\Desktop\ceshi\ceshi\asd\TK664\';
dirs=dir('C:\Users\Administrator\Desktop\ceshi\ceshi\asd\TK664\*.txt');%这里呢,主要就是做一个循环输入求解,毕竟训练模型不变
dircell=struct2cell(dirs);
for i=1:length(dircell)
filenames=dircell(1,i);
fullname=strcat(patchname,filenames);
fullname = fullname{1};
[a1,a2,a3,a4,a5] = textread(fullname,'%f%f%f%f%f','headerlines',0);
test_data = [a1,a2,a3,a4];
test_label = a5;
[predict_label,accuracy] = svmpredict(test_label,test_data,model);
end
最后结果就会显示出来,肯定是没有可视化显示的那么详细,不过胜在比可视化速度快,更加自动化!
那么接下来就是libsvm其中matlab文件包的使用(当然其中有可视化版本)
1.matlab工具包安装
首先输入mex -setup安装一下
Would you like mex to locate installed compilers [y]/n? y
Select a compiler:
[1] Microsoft Visual C/C++ version 7.1 in C:\Program Files\Microsoft Visual Studio
[0] None
Compiler: 1
Please verify your choices:
Compiler: Microsoft Visual C/C++ 7.1
Location: C:\Program Files\Microsoft Visual Studio
Are these correct?([y]/n): y
然后呢,就是输入make,成功以后,既可以使用啦!
2.工具包使用(matlab代码)
[a1,a2,a3,a4,a5] = textread('C:\Users\Administrator\Desktop\ceshi\ceshi.txt','%f%f%f%f%f','headerlines',0)
train_data = [a1,a2,a3,a4];
train_label = a5;
model = svmtrain(train_label,train_data);
patchname='C:\Users\Administrator\Desktop\ceshi\ceshi\asd\TK664\';
dirs=dir('C:\Users\Administrator\Desktop\ceshi\ceshi\asd\TK664\*.txt');%这里呢,主要就是做一个循环输入求解,毕竟训练模型不变
dircell=struct2cell(dirs);
for i=1:length(dircell)
filenames=dircell(1,i);
fullname=strcat(patchname,filenames);
fullname = fullname{1};
[a1,a2,a3,a4,a5] = textread(fullname,'%f%f%f%f%f','headerlines',0);
test_data = [a1,a2,a3,a4];
test_label = a5;
[predict_label,accuracy] = svmpredict(test_label,test_data,model);
end
最后结果就会显示出来,肯定是没有可视化显示的那么详细,不过胜在比可视化速度快,更加自动化!
相关文章推荐
- Matlab读入的图像缘何和OpenCv的不一样?
- m文件转dll
- MATLAB数据类型
- matlab中repmat函数的用法
- matlab重采样
- Matlab 模块库建立 S函数心得 小记
- R2014年号称流行,是否会在2016体现,give-up matlab,可视化
- MATLAB运算符
- VLFeat库matlab API接口
- Matlab melband的计算
- matlab-code folding功能 将某些行的代码折叠起来方便查看
- MATLAB图像处理:平面卫星图转换成立体球形图
- 最小二乘法拟合非线性函数及其Matlab/Excel 实现(转)
- 【转】三种方式在C++中调用matlab
- 基于数学建模的数学实验学习笔记一 MATLAB软件基础
- 【转】C++调用Matlab的.m文件
- matlab安装配置VLFeat库
- MATLAB的crack安装小曲
- [matlab]copy image
- MATLAB信号处理仿真-基带脉冲成形的数字滤波器