资源简介
程序可用,自带训练和测试数据集,每个模块是单独编,可读性强,利用率高。
代码片段和文件信息
function [BestCVaccuracyBestcBestgga_optionmodelfit_gen] = gaSVMcgForClass(train_labeltrain_data)
% gaSVMcgForClass
%%
% 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
%% 参数初始化
if nargin == 2
ga_option = struct(‘maxgen‘20‘sizepop‘20‘ggap‘0.9...
‘cbound‘[0100]‘gbound‘[01000]‘v‘5);
end
% maxgen:最大的进化代数默认为200一般取值范围为[100500]
% sizepop:种群最大数量默认为20一般取值范围为[20100]
% cbound = [cmincmax]参数c的变化范围默认为(0100]
% gbound = [gmingmax]参数g的变化范围默认为[01000]
% v:SVM Cross Validation参数默认为5
%%
MAXGEN = ga_option.maxgen;
NIND = ga_option.sizepop;
NVAR = 2;
PRECI = 20;
GGAP = ga_option.ggap;
trace = zeros(MAXGEN2);
FieldID = ...
[rep([PRECI][1NVAR]);[ga_option.cbound(1)ga_option.gbound(1);ga_option.cbound(2)ga_option.gbound(2)]; ...
[11;00;01;11]];
Chrom = crtbp(NINDNVAR*PRECI);
v = ga_option.v;
%%
cg = bs2rv(ChromFieldID);
for nind = 1:NIND
cmd = [‘-v ‘num2str(v)‘ -c ‘num2str(cg(nind1))‘ -g ‘num2str(cg(nind2))];
ObjV(nind1) = svmtrain(train_labeltrain_datacmd);
end
[BestCVaccuracyI] = max(ObjV);
Bestc = cg(I1);
Bestg = cg(I2);
fit_gen(1MAXGEN)=0;
%%
%while 1
for gen = 1:MAXGEN
FitnV = ranking(-ObjV);
SelCh = select(‘sus‘ChromFitnVGGAP);
SelCh = recombin(‘xovsp‘SelCh0.7);
SelCh = mut(SelCh);
cg = bs2rv(SelChFieldID);
for nind = 1:size(SelCh1)
cmd = [‘-v ‘num2str(v)‘ -c ‘num2str(cg(nind1))‘ -g ‘num2str(cg(nind2))];
ObjVSel(nind1) = svmtrain(train_labeltrain_datacmd);
end
[ChromObjV] = reins(ChromSelCh11ObjVObjVSel);
if max(ObjV) <= 50
continue;
end
[NewBestCVaccuracyI] = max(ObjV);
cg_temp = bs2rv(ChromFieldID);
temp_NewBestCVaccuracy = NewBestCVaccuracy;
if NewBestCVaccuracy > BestCVaccuracy
BestCVaccuracy = NewBestCVaccuracy;
Bestc = cg_temp(I1);
Bestg = cg_temp(I2);
end
if abs( NewBestCVaccuracy-BestCVaccuracy ) <= 10^(-2) && ...
cg_temp(I1) < Bestc
BestCVaccuracy = NewBestCVaccuracy;
Bestc = cg_temp(I1);
Bestg = cg_temp(I2);
end
trace(gen1) = max(ObjV);
trace(gen2) = sum(ObjV)/length(ObjV);
fit_gen(gen)=BestCVaccuracy;
% if gen <= MAXGEN/2
% continue;
% end
% if BestCVaccuracy >=80 && ...
% ( temp_NewBestCVaccuracy-BestCVaccuracy ) <= 10^(-2)
% break;
% end
if gen == MAXGEN
break;
end
end
cmd_temp = [‘-c ‘num2
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-07-30 20:16 GA_SVM\
文件 3165 2018-08-02 11:24 GA_SVM\gaSVMcgForClass.m
文件 1506 2018-08-02 11:24 GA_SVM\GA_SVM.m
文件 39985 2018-04-08 09:31 GA_SVM\Td.mat
- 上一篇:PSO_SVM.zip
- 下一篇:labview带通滤波
相关资源
- PSO_SVM.zip
- SVPWM算法详解_已标注重点_
- 操作系统课程设计页面置换算法
- Gabor小波+PCA+LDA特征提取方法的人脸表
- gaussian09安装
- 一种基于FPGA的数字秒表设计方法
- 五点三次平滑算法
- FPGA常用通信总线IIC Verilog代码
- 梯度迭代算法
- 谢菲尔德Sheffield遗传算法工具箱
- 匿名姿态解算算法带注释
- 强化学习精要:核心算法与TensorFlow实
- present加密算法
- FPGA USB 2.0 IP核工程
- AES加密解密文档.doc
- FPGA 键盘实现
- 简单乘法器和除法器的FPGA设计
- GAMS IEEE14节点潮流程序
- 遗传算法Fortran程序
- garch-toolbox
- 西电软件学院算法导论上机代码
- 改进的Booth算法单精度浮点乘法器源码
- DMD驱动板设计/FPGA
- 语音信号处理-论文翻译-语音信号声学
- 实数编码和二进制编码遗传算法的源
- GalleryScreenshot
- 遗传算法选择策略比较
- 融合改进的ASM和AAM的人脸形状特征点
- 光线跟踪算法源码
- 互补滤波算法
评论
共有 条评论