资源简介
蚁群算法的特征选取matlab实现,是一种智能优化算法的应用
代码片段和文件信息
clc;
clear;
mydata=importdata(‘d:\matlab7\work\test3.dat‘);
RHO=corr(mydata);
R=abs(RHO);
n=30; % The number of features without class
m=3; % The number of selected features
CrossOverProb=0.9; % The Cross Over Probability
MutationProb=0.04; % The Mutation Probability
Population = 500; % The Size of popuation
GenerationNo = 300; % The Number of generation
%[N m TOWNS] = setup16;
%trail = N.*ones(N);
na = 200;
cc = 1;
for i=1:n
trail(i) = cc;
deltatrail(i) = 0;
end;
maxnoiteration = 20;
k = 50;
p = 1;
rho = 0.75;
alpha=1;
beta=1;
counter=1; % The First iteration
for j=1:na
Select = randperm(n);
s(j1:m)= Select(1:m);
end
data = dataset(mydata(:1:n)mydata(:n+1));
[TrainTest]=gendat(data0.6);
for j=1:na
A = [];
B = [];
for i=1:m
A = [ATrain(:s(ji))];
B = [BTest(:s(ji))];
end
W=knnc(A);
D=B*W;
E(j)=D*testc;
% scatterd(A);
% plotc({W});
end
[MinErrorMinErrorIndex]=min(E);
[SOIX]=sort(E);
for j=1:k
for l=1:m
for i=1:n
deltatrail(i)=0;
if (s(IX(j)l)==i)
Errorg = max(SO(1:k))-E(IX(j));
Errorhg=0;
for h=1:k
if ( (max(SO(1:k))-E(IX(h))) > Errorhg )
Errorhg = max(SO(1:k))-E(IX(h));
end
end
if (Errorhg ~= 0)
deltatrail(i)=Errorg/Errorhg;
else
deltatrail(i)=1;
end;
end;
trail(i)= rho * trail(i) + deltatrail(i);
end;
end;
end;
%for j=1:na
% temp1(1:m)= s(IX(round(rand*(k-1))+1)1:m);
% r=randperm(m);
% for l=1:m-p
% temp2(l)=temp1(r(l));
% end;
% s(j1:m-p)=temp2(1:m-p);
%end;
%tourlength = [];
%temp_length = [];
%rho = 0.5; % rho = 1 - (evaporation of trail)
%Q = N;
%avgtour = [];
%mintour = [];
while ( (counter < maxnoiteration) & (MinError > 0.001) )
counter = counter+1;
%for exit_tours = 1:40 %Loop back to here
%tabu = zeros(mN); %generate (N x m) matrix containing zeros
%set initial town for each ant randomly
%for i = 1:m
%tabu(i1) = ceil(N*rand);
%end
%Use function nexttown.m to determine next town based on visibility and
%trail
%for j = 1:length(TOWNS(1:))-1 %for each town
%for i = 1:m %for each ant
%sub_tabu = tabu(i:); %create tabu for each ant
%add new town to tabu using function nexttown.m
%tabu(ij+1) = nexttown(sub_tabu TOWNS trail);
%end
%end
for j=1:na
temp1(1:m)= s(IX(round(rand*(k-1))+1)1:m);
r=randperm(m);
for l=1:m-p
temp2(l)=temp1(r(l));
end;
s(j1:m-p)=temp2(1:m-p);
end;
for mm = m-p+1:m
for j=1:na
for i=1:n
flag=0;
for l=1:m-p
if (s(jl)==i)
flag=1;
end;
end;
if (flag==1)
USM(i)=0;
else
den=0
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 7290 2011-06-05 07:19 ACO_feature_selection.m
文件 1338 2011-06-05 07:19 license.txt
- 上一篇:单脉冲测向单目标
- 下一篇:几种Matlab的边缘分割处理代码
相关资源
- 几种Matlab的边缘分割处理代码
- 插值抽取实现分数阶延时的matlab程序
- matlab多机器人避障
- matlab蓄电池模型
- 感应电机矢量控制matlab仿真
- 相关干涉仪算法
-
matlabSimuli
nk仿真模型.doc - TF98的matlab程序代码
- matlab sar 图像检测的程序
- 标记分水岭分割算法的matlab实现
- 压缩感知图像MATLAB代码美国乔治亚理
- 跳跃式滑翔弹道仿真程序
- 高等光学仿真》matlab源程序
- 流形学习算法matlab
- 频域块LMS算法
- matlab7.1win764位破解版.rar
- 图像融合MATLAB程序
- 最大流MATLAB
- hdb3编译码 matlab
- arma模型_matlab源码
- MATLAB计算对极线程序
- matlab求取二维数组极大值与极小值
- MATLAB非线性优化fmincon详解
- 4CPM_matlab
- MATLAB获取neurosky专注度数据
- Matlab男女声在线识别系统
- 一维二维中值滤波均值滤波matlab编码
- matlab 2007
- matlab贝叶斯源码iris分类
- PSO粒子群算法万能matlab代码注释详细
评论
共有 条评论