Hi Neural Network users,
I had written a code to predict the last week of my data set, the result is as shown in the plot below Please let me know where I made a mistake :(
clear;
%%1. Importing data
load ('Metdata.mat'); % Import file
load('Rdate.mat');
Metdata(:,1)=[];
Rdate(:,1)=[];
Inputs = Metdata'; %Convert to row
Target = Rdate'; %Convert to row
X = con2seq(Inputs); %Convert to cell
T = con2seq(Target); %Convert to cell
%%2. Data preparation
N = 168; % Multi-step ahead prediction
% Input and target series are divided in two groups of data:
% 1st group: used to train the network
inputSeries = X(1:end-N);
targetSeries = T(1:end-N);
% 2nd group: this is the new data used for simulation. inputSeriesVal will
% be used for predicting new targets. targetSeriesVal will be used for
% network validation after prediction
inputSeriesVal = X(end-N+1:end);
targetSeriesVal = T(end-N+1:end);
%%3. Network Architecture
delay = 2;
neuronsHiddenLayer = 15;
% Create a Nonlinear Autoregressive Network with External Input
% net = narxnet(inputDelays,feedbackDelays,hiddenLayerSize);
net = narxnet(1:delay,1:delay,neuronsHiddenLayer);
%%4. Training the network
[Xs,Xi,Ai,Ts] = preparets(net,inputSeries,{},targetSeries);
net = train(net,Xs,Ts,Xi,Ai);
view(net)
Y = net(Xs,Xi,Ai);
% Performance for the series-parallel implementation, only
% one-step-ahead prediction
perf = perform(net,Ts,Y);
%%5. Multi-step ahead prediction
[Xs1,Xio,Aio] = preparets(net,inputSeries(1:end-delay),{},targetSeries(1:end-delay));
[Y1,Xfo,Afo] = net(Xs1,Xio,Aio);
[netc,Xic,Aic] = closeloop(net,Xfo,Afo);
[yPred,Xfc,Afc] = netc(inputSeriesVal,Xic,Aic);
multiStepPerformance = perform(net,yPred,targetSeriesVal);
view(netc)
figure;
plot([cell2mat(targetSeries),nan(1,N);
nan(1,length(targetSeries)),cell2mat(yPred);
nan(1,length(targetSeries)),cell2mat(targetSeriesVal)]')
legend('Original Targets','Network Predictions','Expected Outputs')

 채택된 답변

Greg Heath
Greg Heath 2015년 11월 27일

0 개 추천

Your complete data set does not appear to be stationary (e.g., constant mean, variance and correlations.
Divide the data into stationary subsets and design a model for each.
Hope this helps.
Greg

댓글 수: 4

Lilya
Lilya 2015년 11월 29일
The matrix dimensions are: metadata (8761 row*4 column) And for Rdate (8761*1) should I take the mean of all then I import it in NN app? for 3 sets trainig, testing and predicting?
Thank Dr. for your respond
Greg Heath
Greg Heath 2015년 11월 29일
Perhaps you did not understand:
There appear to be 5 distinct regions that have different statistics. I doubt if there is a single model that will even work on 2 of them, much less 5.
I suggest separating the five regions and looking for the physical reason why the statistics are different.
In addition to comparing means and variances, you need to compare the significant lags of the target autocorrelation function and the target/input cross-correlation functions.
You may have to design 5 separate models along with some logic to indicate which model to use.
As far as predicting beyond the target region, it looks like you only need to use the model obtained from the last region startng around time = 8000.
Hope this helps.
Greg
Lilya
Lilya 2015년 11월 29일
편집: Lilya 2015년 11월 30일
ok, I will take your advice in mind. I have a question in the choosing of the number of hidden layer neurons when I change it to 50 neurons the plot looks as shown in attachment the figure looks better. And excuse me Dr. What do you mean by "5 separate models"? Is it by taking each input individually? Finally, is it necessary for normalizing data with (mapstd)?
Thank you
Greg Heath
Greg Heath 2015년 12월 1일
Look at the plot! There are 5 separate regions, each with a separate set of summary statistics.
MAPSTD is not necessary. I prefer using the function ZSCORE before training to detect outliers for removal or modification. Then I use the default MAPMINMAX. An alternative would be to replace the the default with MAPSTD or '' (i.e., nothing).
You can refer to any of my zillions of postings in the NEWSGROUP or ANSWERS.
Greg

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

질문:

2015년 11월 25일

댓글:

2015년 12월 1일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by