首先libsvm确实是非常的好用,有各种语言的版本还有可视化窗口可以查看效果
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
那么接下来就是libsvm其中matlab文件包的使用(当然其中有可视化版本)
1.matlab工具包安装
首先输入mex -setup安装一下
然后呢,就是输入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
最后结果就会显示出来,肯定是没有可视化显示的那么详细,不过胜在比可视化速度快,更加自动化!