资源简介
特征选择是常用的预处理任务之一,其目的是减少智能算法和模型的输入量。这有助于简化模型,降低模型训练的计算成本,提高模型的泛化能力和防止过度训练。用于前馈人工神经网络(ANNs)训练的进化特征选择的MATLAB实现。
代码片段和文件信息
%
% Copyright (c) 2015 Yarpiz (www.yarpiz.com)
% All rights reserved. Please read the “license.txt“ for license terms.
%
% Project Code: YPML122
% Project title: Feature selection using GA (Variable Number of Features)
% Publisher: Yarpiz (www.yarpiz.com)
%
% Developer: S. Mostapha Kalami Heris (Member of Yarpiz Team)
%
% Contact Info: sm.kalami@gmail.com info@yarpiz.com
%
function results=CreateAndTrainANN(xt)
if ~isempty(x)
% Choose a Training Function
% For a list of all training functions type: help nntrain
% ‘trainlm‘ is usually fastest.
% ‘trainbr‘ takes longer but may be better for challenging problems.
% ‘trainscg‘ uses less memory. NFTOOL falls back to this in low memory situations.
trainFcn = ‘trainlm‘; % Levenberg-Marquardt
% Create a Fitting Network
hiddenlayerSize = 10;
net = fitnet(hiddenlayerSizetrainFcn);
% Choose Input and Output Pre/Post-Processing Functions
% For a list of all processing functions type: help nnprocess
net.input.processFcns = {‘removeconstantrows‘‘mapminmax‘};
net.output.processFcns = {‘removeconstantrows‘‘mapminmax‘};
% Setup Division of Data for Training Validation Testing
% For a list of all data division functions type: help nndivide
net.divideFcn = ‘dividerand‘; % Divide data randomly
net.divideMode = ‘sample‘; % Divide up every sample
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
% Choose a Performance Function
% For a list of all performance functions type: help nnperformance
net.performFcn = ‘mse‘; % Mean squared error
% Choose Plot Functions
% For a list of all plot functions type: help nnplot
net.plotFcns = {};
% net.plotFcns = {‘plotperform‘‘plottrainstate‘‘ploterrhist‘ ‘plotregression‘ ‘plotfit‘};
net.trainParam.showWindow=false;
net.trainParam.epochs=50;
% Train the Network
[nettr] = train(netxt);
% Test the Network
y = net(x);
e = gsubtract(ty);
E = perform(netty);
else
y=inf(size(t));
e=inf(size(t));
E=inf;
tr.trainInd=[];
tr.valInd=[];
tr.testInd=[];
end
% All Data
Data.x=x;
Data.t=t;
Data.y=y;
Data.e=e;
Data.E=E;
% Train Data
TrainData.x=x(:tr.trainInd);
TrainData.t=t(:tr.trainInd);
TrainData.y=y(:tr.trainInd);
TrainData.e=e(:tr.trainInd);
if ~isempty(x)
TrainData.E=perform(netTrainData.tTrainData.y);
else
TrainData.E=inf;
end
% Validation and Test Data
TestData.x=x(:[tr.testInd tr.valInd]);
TestData.t=t(:[tr.testIn
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2020-03-26 13:18 YPML122 Evolutionary Feature Selection\
目录 0 2020-03-26 13:18 YPML122 Evolutionary Feature Selection\01 Binary Feature Selection using GA\
文件 3489 2015-09-11 21:08 YPML122 Evolutionary Feature Selection\01 Binary Feature Selection using GA\CreateAndTrainANN.m
文件 881 2015-09-11 21:08 YPML122 Evolutionary Feature Selection\01 Binary Feature Selection using GA\Crossover.m
文件 635 2015-09-11 21:09 YPML122 Evolutionary Feature Selection\01 Binary Feature Selection using GA\DoublePointCrossover.m
文件 1444 2015-09-11 21:09 YPML122 Evolutionary Feature Selection\01 Binary Feature Selection using GA\FeatureSelectionCost.m
文件 617 2015-09-11 21:09 YPML122 Evolutionary Feature Selection\01 Binary Feature Selection using GA\LoadData.m
文件 545 2015-09-11 21:09 YPML122 Evolutionary Feature Selection\01 Binary Feature Selection using GA\Mutate.m
文件 511 2015-09-11 21:09 YPML122 Evolutionary Feature Selection\01 Binary Feature Selection using GA\RouletteWheelSelection.m
文件 569 2015-09-11 21:09 YPML122 Evolutionary Feature Selection\01 Binary Feature Selection using GA\SinglePointCrossover.m
文件 554 2015-09-11 21:09 YPML122 Evolutionary Feature Selection\01 Binary Feature Selection using GA\UniformCrossover.m
文件 8631 2015-09-11 20:28 YPML122 Evolutionary Feature Selection\01 Binary Feature Selection using GA\bodyfat_data.mat
文件 3492 2015-09-11 21:09 YPML122 Evolutionary Feature Selection\01 Binary Feature Selection using GA\ga.m
文件 1350 2015-08-23 04:39 YPML122 Evolutionary Feature Selection\01 Binary Feature Selection using GA\license.txt
文件 121 2015-08-23 04:35 YPML122 Evolutionary Feature Selection\01 Binary Feature Selection using GA\www.yarpiz.com.url
目录 0 2020-03-26 13:20 YPML122 Evolutionary Feature Selection\02 Fixed Feature Selection using SA and ACO\
文件 676 2015-09-11 21:09 YPML122 Evolutionary Feature Selection\02 Fixed Feature Selection using SA and ACO\ApplyInsertion.m
文件 596 2015-09-11 21:09 YPML122 Evolutionary Feature Selection\02 Fixed Feature Selection using SA and ACO\ApplyReversion.m
文件 588 2015-09-11 21:09 YPML122 Evolutionary Feature Selection\02 Fixed Feature Selection using SA and ACO\ApplySwap.m
文件 3459 2015-09-11 21:09 YPML122 Evolutionary Feature Selection\02 Fixed Feature Selection using SA and ACO\CreateAndTrainANN.m
文件 921 2015-09-11 21:09 YPML122 Evolutionary Feature Selection\02 Fixed Feature Selection using SA and ACO\CreateNeighbor.m
文件 493 2015-09-11 21:09 YPML122 Evolutionary Feature Selection\02 Fixed Feature Selection using SA and ACO\CreateRandomSolution.m
文件 1363 2015-09-11 21:09 YPML122 Evolutionary Feature Selection\02 Fixed Feature Selection using SA and ACO\FeatureSelectionCost.m
文件 622 2015-09-11 21:09 YPML122 Evolutionary Feature Selection\02 Fixed Feature Selection using SA and ACO\LoadData.m
文件 504 2015-09-11 21:09 YPML122 Evolutionary Feature Selection\02 Fixed Feature Selection using SA and ACO\RouletteWheelSelection.m
文件 2606 2015-09-11 21:09 YPML122 Evolutionary Feature Selection\02 Fixed Feature Selection using SA and ACO\aco.m
文件 8631 2015-09-11 20:28 YPML122 Evolutionary Feature Selection\02 Fixed Feature Selection using SA and ACO\bodyfat_data.mat
文件 1350 2015-08-23 04:39 YPML122 Evolutionary Feature Selection\02 Fixed Feature Selection using SA and ACO\license.txt
文件 2196 2015-09-11 21:09 YPML122 Evolutionary Feature Selection\02 Fixed Feature Selection using SA and ACO\sa.m
目录 0 2020-03-26 13:20 YPML122 Evolutionary Feature Selection\03 Fixed Feature Selection using PSO\
文件 3452 2015-09-11 21:10 YPML122 Evolutionary Feature Selection\03 Fixed Feature Selection using PSO\CreateAndTrainANN.m
............此处省略25个文件信息
- 上一篇:bsc信道的2/3卷积码matlab仿真
- 下一篇:轴承油膜温度场程序
评论
共有 条评论