91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 10KB
    文件類型: .m
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2021-05-16
  • 語言: Matlab
  • 標(biāo)簽: DE算法??特征選擇??

資源簡介

差分進化算法解決特征選擇問題,差分進化算法解決特征選擇問題,Differential evolution algorithm to solve the problem of feature selection,Differential evolution algorithm to solve the problem of feature selection,

資源截圖

代碼片段和文件信息

function?[ErrSubset]?=?DEFS(data_trdata_tsDNFPSIZELdclassifGEN)
%%
%????Differential?Evolution?based?Feature?Selection
%????Inputs
%????------
%??????????data_tr:?training?dataset?(with?NP1?patterns?x?NF+1?features?with?last?column?being?the?training?class?label)
%??????????data_ts:?testing?dataset?(with?NP1?patterns?x?NF+1?features?with?last?column?being?the?testing?class?label)
%??????????NP:???number?of?patterns?(NP1?and?NP2?used?for?example)
%??????????NF:???number?of?features
%??????????DNF:??desired?number?of?features?to?be?selected
%??????????PSIZE:population?size
%??????????Ld:???either?load?initial?population?(Ld=1)?or?simply?initialize?a?new?population?(Ld=0)
%??????????classif:??takes?text?value?as:?‘LDA‘?or?‘KNN‘?or?‘NB‘?or?‘RegTree‘?
%??????????GEN:?????number?of?generations?or?iterations
%
%????OutPuts
%????-------
%??????????Err:?Achieved?error?rate?across?the?different?itreations
%??????????Subset:?selected?feature?subset?(feature?indices)
%
%????Example:
%????-------
%??????????load?IRIS.txt
%??????????[ErrSubset]?=?DEFS(iris(1:2:end1:end)iris(2:2:end:)3500‘KNN‘100)
%?CONTROL?PARAMETERS?%
D?=?DNF;?%?dimension?of?problem
NP?=?PSIZE;?%?size?of?population
CR?=?0.5;?%?crossover?constant
L?=?1;?%?low?boundary?constraint
H?=?size(data_tr2)-1;?%?high?boundary?constraint
NF?=?H;
NE?=?5;
%?Ld
if?nargin?????Ld?=?0;
end
if?nargin?????classif?=?0;
end
if?nargin?????GEN?=?400;?%?number?of?generations=iterations
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%?This?section?can?be?used?to?replace?the?factor?F?in?the?paper
w_start?=?0.95;??????????????????????????%Initial?inertia?weight‘s?value
w_end?=?0.35;????????????????????????????%Final?inertia?weight
w_varyfor?=?1;
w_varyfor?=?floor(w_varyfor*GEN);???????%Weight?change?step.?Defines?total?number?of?iterations?for?which?weight?is?changed.
w_now?=?w_start;
inertdec?=?(.95-.35)/w_varyfor;???????????%Inertia?weight‘s?change?per?iteration
w_start?=?0.35;??????????????????????????%Initial?inertia?weight‘s?value
w_end?=?0.95;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%?***************************?%
%?**?ALGORITHM?VARIABLES?**?%
%?***************************?%
X?=?zeros(D1);?%?trial?vector
Pop?=?zeros(DNP);?%?population
Fit?=?zeros(1NP);?%?fitness?of?the?population
r?=?zeros(31);?%?randomly?selected?indices
%?***********************?%
%?**?CREATE?POPULATION?**?%
%?***********************?%
%?initialize?random?number?generator
rand(‘state‘sum(100*clock));
if?Ld
????load?TabK?Pop
????%Pop?=?Tab‘;
else
????for?j=1:NP
????????FF?=?randperm(H);
????????Pop(:j)?=?FF(1:D)‘;?%?within?b.constraints
????end
end
for?j?=?1:NP?%?initialize?each?individual
????val?=round(Pop(:j))‘;
????switch?classif
????????case?‘LDA‘
????????????%LDA?classifier
????????????Ac1?=?classify(data_ts(:val)data_tr(:val)data_tr(:

評論

共有 條評論