资源简介
SVM参数优化 网格搜索法

代码片段和文件信息
function [bestaccbestcbestg] = SVMcgForClass(train_labeltraincmincmaxgmingmaxvcstepgstepaccstep)
%SVMcg cross validation by faruto
%%
% by faruto
%Email:patrick.lee@foxmail.com QQ:516667408 http://blog.sina.com.cn/faruto BNU
%last modified 2010.01.17
%% 若转载请注明:
% faruto and liyang LIBSVM-farutoUltimateVersion
% a toolbox with implements for support vector machines based on libsvm 2009.
%
% Chih-Chung Chang and Chih-Jen Lin LIBSVM : a library for
% support vector machines 2001. Software available at
% http://www.csie.ntu.edu.tw/~cjlin/libsvm
%% about the parameters of SVMcg
if nargin < 10
accstep = 4.5;
end
if nargin < 8
cstep = 0.8;
gstep = 0.8;
end
if nargin < 7
v = 5;
end
if nargin < 5
gmax = 8;
gmin = -8;
end
if nargin < 3
cmax = 8;
cmin = -8;
end
%% X:c Y:g cg:CVaccuracy
[XY] = meshgrid(cmin:cstep:cmaxgmin:gstep:gmax);
[mn] = size(X);
cg = zeros(mn);
eps = 10^(-4);
%% record acc with different c & gand find the bestacc with the smallest c
bestc = 1;
bestg = 0.1;
bestacc = 0;
basenum = 2;
for i = 1:m
for j = 1:n
cmd = [‘-v ‘num2str(v)‘ -c ‘num2str( basenum^X(ij) )‘ -g ‘num2str( basenum^Y(ij) )];
cg(ij) = svmtrain(train_label train cmd);
if cg(ij) <= 55
continue;
end
if cg(ij) > bestacc
bestacc = cg(ij);
bestc = basenum^X(ij);
bestg = basenum^Y(ij);
end
if abs( cg(ij)-bestacc )<=eps && bestc > basenum^X(ij)
bestacc = cg(ij);
bestc = basenum^X(ij);
bestg = basenum^Y(ij);
end
end
end
%% to draw the acc with different c & g
figure;
[Ch] = contour(XYcg70:accstep:100);
clabel(Ch‘Color‘‘r‘);
xlabel(‘log2c‘‘FontSize‘12);
ylabel(‘log2g‘‘FontSize‘12);
firstline = ‘SVC参数选择结果图(等高线图)[GridSearchMethod]‘;
secondline = [‘Best c=‘num2str(bestc)‘ g=‘num2str(bestg) ...
‘ CVAccuracy=‘num2str(bestacc)‘%‘];
title({firstline;secondline}‘Fontsize‘12);
grid on;
figure;
meshc(XYcg);
% mesh(XYcg);
% surf(XYcg);
axis([cmincmaxgmingmax30100]);
xlabel(‘log2c‘‘FontSize‘12);
ylabel(‘log2g‘‘FontSize‘12);
zlabel(‘Accuracy(%)‘‘FontSize‘12);
firstline = ‘SVC参数选择结果图(3D视图)[GridSearchMethod]‘;
secondline = [‘Best c=‘num2str(bestc)‘ g=‘num2str(bestg) ...
‘ CVAccuracy=‘num2str(bestacc)‘%‘];
title({firstline;secondline}‘Fontsize‘12);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2506 2016-03-08 22:16 网格搜索法\网格搜索法.m
目录 0 2016-03-09 15:43 网格搜索法
----------- --------- ---------- ----- ----
2506 2
相关资源
- CNN-SVM模型在抽油机井故障诊断中的应
- 基于蚁群算法优化SVM的瓦斯涌出量预
- 基于模糊聚类和SVM的瓦斯涌出量预测
- 基于CAN总线与ZigBee的瓦斯实时监测及
- SVM-Light资料,使用说明
- 果蝇算法融合SVM的开采沉陷预测模型
- BoW|Pyramid BoW+SVM进行图像分类
- 基于libsvm的图像分割代码
- 基于SVM及两类运动想象的多通道特征
- 小波包和SVM在轴承故障识别中的应用
- 林智仁教授最新版本LibSVM工具箱
- 台湾林教授的支持向量机libsvm
- 新闻分类语料
- libsvm-3.20
- 7种支持向量机SVM工具包
- A Practical Guide to Support Vector Classifica
- libSVM的代码详细解析,注释非常详细
- 台湾林志恒的LIBSVM的中文简体说明文
- SVM算法-回归拟合程序.zip
- 基于Grid-Search_PSO优化SVM回归预测矿井
- 新冒落带高度算法FOA-SVM预计模型
- 官方最新版本libsvm-3.23
- 基于PCA和SVM的个性化睡眠分期研究
- 基于svm四种工具箱
- 自然语言处理之文本主题判别
- HOG+SVM实现数字识别
- opencv自带SVM分类器使用程序
- 基于HOG特征提取的svm行人头肩训练
- 遗传算法优化支持向量机算法
- 经典的行人检测算法,利用HOG和SVM实
评论
共有 条评论