Data prediction with Neural network (Closed loop)

2 views (last 30 days)
Rakibul Islam Rony
Rakibul Islam Rony on 28 Dec 2019
Edited: Rakibul Islam Rony on 28 Dec 2019
Hi all, i am at the beggining of learning Machine learnig tool with Matlab. I am using neural network (closed loop) to predict future (beyod the target value) data after training the netwrok with some target data. It is a time series data.
However, My code is working for a simplelinear data set. Soon i put my data as Target, it does not work as supposed to althoug my data aslo has a clear pattern.
Pasted the Figures. Figure 1 shows the figure where predicted data follows the previous pattern of linear data set (T2 in the code). Figure 2 shows the figure with my data set (IP in the code).
The only problem i can think of, my data set is more gradual and hence, closed loop is not the right way for me. But what can i do predict for my data set? Any suggestion/ comments will be highly appritiated.
Data set is attached.
%T = tonndata((IP/1000),true,false); %IP is my data
T = tonndata((T2),true,false); % T2 is a simplelinear data set
trainFcn = 'trainbr';
feedbackDelays = 1:2;
hiddenLayerSize = 10;
net = narnet(feedbackDelays,hiddenLayerSize,'open',trainFcn);
[x,xi,ai,t] = preparets(net,{},{},T);
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
[net,tr] = train(net,x,t,xi,ai);
y = net(x,xi,ai);
e = gsubtract(t,y);
performance = perform(net,t,y);
netc = closeloop(net); = [ ' - Closed Loop'];
[xc,xic,aic,tc] = preparets(netc,{},{},T);
yc = netc(xc,xic,aic);
closedLoopPerformance = perform(net,tc,yc)
Yc = cell2mat (yc);
%Multistep prediction with closed loop
[x1, xio, aio, t] = preparets(net, {}, {}, T);
[y1, xfo, afo] = net (x1, xio, aio);
[netc, xic, aic] = closeloop (net, xfo, afo);
[y2, xfc, afc] = netc (cell(0,100),xic, aic);
y1_1 = cell2mat (y1);
y2_1 = cell2mat (y2);
tt = cell2mat (T);
plot (tt);
hold on
plot (Yc, '*r');
hold on
plot (1:numel (y1_1),y1_1, '-b');
hold on
plot (numel (y1_1)+1:numel (y1_1)+100, y2_1, '-k');

Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by