How to forecast using ANN
Show older comments
HI, please help me to forecast feature groundwater level using feed forward neural network with LM algorithm, i developed the feed forward neural network with LM algorithm with ANN architecture 3-5-1, my model is as follows, but i want to use this model for forecasting at least 3 to 6 point ahead, can any one please help me,
clear all;
clc;
load dannlm.txt;
t=dannlm(:,1);
rain=dannlm(:,2);
et=dannlm(:,3);
gwl=dannlm(:,4);
%[ACF, Lags, Bounds] = autocorr(gwl, [], 2);
%[PACF, Lags, Bounds] = parcorr(gwl, [], 2);
%[CCF, Lags, Bounds] = crosscorr(gwl,rain);
gwlmin=min(gwl);
gwlmax=max(gwl);
rain=(rain-min(rain))/(max(rain)-min(rain));
et=(et-min(et))/(max(et)-min(et));
gwl=(gwl-min(gwl))/(max(gwl)-min(gwl));
%*****Data Preparation****
for t=5:195
Data(t-4,:)=[rain(t-4) et(t-1) gwl(t-1) gwl(t)];
end
%Define Input patter for Training and Validation
INPTR=Data(1:150, 1:3);
TARTR=Data(1:150,4);
net=newff([0 1; 0 1; 0 1], [5 1], {'logsig', 'purelin'}, 'trainlm');
net.trainParam.epochs=500;
net.trainParam.goal=0.0001;
net.performFcn='mse';
net=init(net);
net=train(net, INPTR', TARTR');
a=sim(net, INPTR');
z=[a' TARTR];
INPVAL=Data(151:191, 1:3);
TARVAL=Data(151:191,4);
y=sim(net, INPVAL');
zv=[y' TARVAL];
%Converting back to Original Flow of gwl Validation
zv=zv*(gwlmax-gwlmin)+gwlmin;
save val1.txt zv -ascii;
z=z*(gwlmax-gwlmin)+gwlmin;
save cal1.txt z -ascii;
CORR_CAL=corrcoef(z)
CORR_VAL=corrcoef(zv)
COM_CAL=z(:,1);
OBS_CAL=z(:,2);
COM_VAL=zv(:,1);
OBS_VAL=zv(:,2);
Eff_ANN_CAL=1-(sumsqr(OBS_CAL-COM_CAL)/sumsqr(OBS_CAL-mean(OBS_CAL)))
Eff_ANN_VAL=1-(sumsqr(OBS_VAL-COM_VAL)/sumsqr(OBS_VAL-mean(OBS_VAL)))
RMSE_ANN_CAL=sqrt(sumsqr(OBS_CAL-COM_CAL)/length(OBS_CAL))
RMSE_ANN_VAL=sqrt(sumsqr(OBS_VAL-COM_VAL)/length(OBS_VAL))
Ex_Var_ANN_CAL=sqrt(sumsqr(COM_CAL-mean(OBS_CAL))/sumsqr(OBS_CAL-mean(OBS_CAL)))
%ERROR_CAL=100*(OBS_CAL-COM_CAL)/OBS_CAL;
%ERROR_VAL=100*(OBS_VAL-COM_VAL)/OBS_VAL;
ANN_PEAK_CAL=(1-max(COM_CAL)/max(OBS_CAL))*100
ANN_PEAK_VAL=(1-max(COM_VAL)/max(OBS_VAL))*100
1 Comment
Anand Kumar
on 8 May 2015
Accepted Answer
More Answers (0)
Categories
Find more on Get Started with MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!