0
点赞
收藏
分享

微信扫一扫

基于遗传算法和布谷鸟搜索优化算法的特征选择(Matlab代码实现)


 📝个人主页:​​研学社的博客​​ 

💥💥💞💞欢迎来到本博客❤️❤️💥💥



🏆博主优势:🌞🌞🌞博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。



⛳️座右铭:行百里者,半于九十。

目录

​​💥1 概述​​

​​📚2 运行结果​​

​​🎉3 参考文献​​

​​🌈4 Matlab代码实现​​


💥1 概述

本文遗传算法 (GA) 和布谷鸟搜索优化 (CSO) 的组合,用于分类精度最大化的特征选择。

没有使用Levy飞行,而是使用GA品种和突变来更新杜鹃,在代码中使用了朴素贝叶斯分类,但可以将其替换为任何其他分类器。

📚2 运行结果

基于遗传算法和布谷鸟搜索优化算法的特征选择(Matlab代码实现)_遗传算法

主函数代码:

clear all;
close all;
clc;
%%
load data.mat
n=5; % # of nests
c=5; % # of cuckoos
Pa=0.25; % a fraction of worst solutions
Nf=size(data,2); % # of features
worstN=round(Pa*n);
for i=1:n
solutions{i}=make_solution(Nf);
end
max_generation=100;
for i=1:c
cuckoo_solution{i}=make_solution(Nf);
end
for t=1:max_generation
clc
disp(['Searching...',num2str(t/max_generation*100),'%']);
index=randsrc(1,c,1:n);
for i=1:c
if fitf(cuckoo_solution{i})>fitf(solutions{index(i)})
solutions{index(i)}=cuckoo_solution{i};
end
end
for i=1:n
fitness(i)=fitf(solutions{i});
end
[~,idx]=sort(fitness);
plot(t,fitness(idx(end)),'o');
hold on
xlim([1 max_generation]);
ylim([1 100]);
pause(0.00001);
best_solution=solutions{idx(end)};
best_solution2=solutions{idx(end-1)};
wrst=idx(1:worstN);
for i=1:length(wrst)
solutions{wrst(i)}=make_solution(Nf);
end
for i=1:c
cuckoo_solution{i}=GASearch(best_solution,best_solution2,Nf); % Genetic Algorithm Search
end
end

🎉3 参考文献

[1]Majid Farzaneh (2022). A combination of GA and CSO for feature selection 

​​🌈​​4 Matlab代码实现

举报

相关推荐

布谷鸟搜索算法

0 条评论