1 简介 人工神经网络的最大缺点是训练时间太长从而限制其实时应用范围,近年来,极限学习机(Extreme Learning Machine, ELM)的提出使得前馈神经网络的训练时间大大缩短,然而当原始数据混杂入
1 简介
人工神经网络的最大缺点是训练时间太长从而限制其实时应用范围,近年来,极限学习机(Extreme Learning Machine, ELM)的提出使得前馈神经网络的训练时间大大缩短,然而当原始数据混杂入大量噪声变量时,或者当输入数据维度非常高时,极限学习机算法的综合性能会受到很大的影响.深度学习算法的核心是特征映射,它能够摒除原始数据中的噪声,并且当向低维度空间进行映射时,能够很好的起到对数据降维的作用,因此我们思考利用深度学习的优势特性来弥补极限学习机的弱势特性从而改善极限学习机的性能.为了进一步提升DELM预测精度,本文采用麻雀搜索算法进一步优化DELM超参数,仿真结果表明,改进算法的预测精度更高。
2 部分代码
clc;clear all;close all;[f p]=uigetfile('*');
X=importdata([p f]);
data=X.data;
data2=data(:,1:end-1);class=data(:,end);
data1=knnimpute(data2);
%%%%%%%%Feature selection
FSL=0;FSU=1;
D=size(data1,2);
for i=1:10
FS(i,:)=FSL+randi([0 1],[1 D])*(FSU-FSL);
try
fit(i)=fitness(data1,class,FS(i,:));
catch
fit(i)=1;
continue;
end
end
ind=find(fit==min(fit));
FSnew=FS(ind,:);
pdp=0.1;
row=1.204;V=5.25;S=0.0154;cd=0.6;CL=0.7;hg=1;sf=18;
Gc=1.9;
D1=1/(2*row*V.^2*S*cd);L=1/(2*row*V.^2*S*CL);
tanpi=D1/L;dg=hg/(tanpi*sf);aa=randi([1 length(ind)]);
iter=1;maxiter=2;
while(iter<maxiter)
for i=1:10
if(rand>=pdp)
FS(i,:)=round(FS(i,:)+(dg*Gc*abs(FSnew(1,:)-FS(i,:))));
else
FS(i,:)=FSL+randi([0 1],[1 D])*(FSU-FSL);
end
Fh=FS;
fit1(i)=fitness(data1,class,FS(i,:));
ind1=find(fit1==min(fit1));
FSnew1=FS(ind1,:);
if(rand>pdp)
FS(i,:)=round(FS(i,:)+(dg*Gc*abs(FSnew(aa,:)-FS(i,:))));
else
FS(i,:)=FSL+randi([0 1],[1 D])*(FSU-FSL);
end
Fa=FS;
fit2(i)=fitness(data1,class,FS(i,:));
ind2=find(fit2==min(fit2));
FSnew2=FS(ind2,:);
end
Sc=sqrt(sum(abs(Fh-Fa)).^2);
Smin=(10*exp(-6))/(365).^(iter/(maxiter/2.5));
if(Sc<Smin)
season=summer;
for i=1:10
FS(i,:)=FSL+levy(1,D,1.5)*(FSU-FSL);
end
else
season=winter;
break;
end
%%%Searching method
fit3(i)=fitness(data1,class,FS(i,:));
ind3=find(fit3==min(fit3));
final=abs(round([Fh(ind1,:);Fa(ind2,:);FS(ind3,:)]));
for i=1:size(final,1)
fitt(i)=fitness(data1,class,final(i,:));
end
best(iter)=min(fitt);
[ff inn]=min(fitt);
bestfeat(iter,:)=final(inn,:);pdp=best(iter);
iter=iter+1;
end
sel=find(bestfeat(end,:));
disp('Selected Features');disp(sel)
dataA =data2(:,sel); % some test data
p = .7 ; % proportion of rows to select for training
N = size(dataA,1); % total number of rows
tf = false(N,1); % create logical index vector
tf(1:round(p*N)) = true;
tf = tf(randperm(N)); % randomise order
dataTraining = dataA(tf,:);labeltraining=class(tf);
dataTesting = dataA(~tf,:);labeltesting=class(~tf);
disp('Training feature size');disp(length(dataTraining))
disp('Testing feature size');disp(length(dataTesting))
svt=svmtrain(dataTraining,labeltraining);
out1=svmclassify(svt,dataTesting);
mdl=fitcknn(dataTraining,labeltraining);
out2=predict(mdl,dataTesting);
%%%%%%% NB %%%%%%%%
mdl=fitcensemble(dataTraining,labeltraining);
out3=predict(mdl,dataTesting);
tp=length(find(out3==labeltesting));
msgbox([{['Out of ',num2str(length(out3))]},{[num2str(tp),'are correctly classified']}])
delete(gcp('nocreate'))
disp('%%%%%%%% KNN %%%%%%%%%%%%%%')
[EVAL CF] = Evaluate(out2,labeltesting);
disp('Accuracy (%)');disp(EVAL(1)*100);
disp('Precision (%)');disp(EVAL(4)*100);
disp('Recall (%)');disp(EVAL(5)*100);
disp('Fmeasure (%)');disp(EVAL(6)*100);
disp('True Positive');disp(CF(1))
disp('True Negative');disp(CF(2))
disp('False Positive');disp(CF(3))
disp('False Negative');disp(CF(4))
disp('%%%%%%%% SVM %%%%%%%%%%%%%%')
[EVAL3 CF] = Evaluate(out1,labeltesting);
disp('Accuracy (%)');disp(EVAL3(1)*100);
disp('Precision (%)');disp(EVAL3(4)*100);
disp('Recall (%)');disp(EVAL3(5)*100);
disp('Fmeasure (%)');disp(EVAL3(6)*100);
disp('True Positive');disp(CF(1))
disp('True Negative');disp(CF(2))
disp('False Positive');disp(CF(3))
disp('False Negative');disp(CF(4))
disp('%%%%%% NB %%%%%%%%%%%%%%')
[EVAL2 CF] = Evaluate(out3,labeltesting);
disp('Accuracy (%)');disp(EVAL2(1)*100);
disp('Precision (%)');disp(EVAL2(4)*100);
disp('Recall (%)');disp(EVAL2(5)*100);
disp('Fmeasure (%)');disp(EVAL2(6)*100);
disp('True Positive');disp(CF(1))
disp('True Negative');disp(CF(2))
disp('False Positive');disp(CF(3))
disp('False Negative');disp(CF(4))
3 仿真结果
4 参考文献
[1]马萌萌. 基于深度学习的极限学习机算法研究[D]. 中国海洋大学, 2015.
博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。
部分理论引用网络文献,若有侵权联系博主删除。