Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: help me. NaR not working
Replies: 5   Last Post: Oct 10, 2013 1:14 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
phuong

Posts: 20
Registered: 8/23/13
help me. NaR not working
Posted: Oct 7, 2013 9:16 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I used a simple data set for Neural. It's the linear 1:1500. But when I use NaR for this, I don't get exact resulr. Somtime it fits, some times it different target very much.
Here's my code:

%%
clear;close all;clc;
% [X T] = abalone_dataset;
T = 1:1500;
T = tonndata(T,true,false);
%%
N = 200; %

% Input and target series are divided in two groups of data:
% 1st group: used to train the network

inputSeries = T(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 = T(end-N+1:end);

%% Network Architecture
lag = 2;
hidden = 4;
delay = 3;
net = narnet(lag:delay+lag-1,hidden);
% view(net);
%% Trainning network
[Xs,Xi,Ai,Ts] = preparets(net,{},{},inputSeries);
net.divideFcn='divideblock';
net.divideParam.trainRatio = 0.85;
net.divideParam.valRatio = 0.15;
net.divideParam.testRatio = 0;
net.trainFcn = 'trainlm';
net = train(net,Xs,Ts,Xi,Ai);
%% Predict
inputSeriesPred = [inputSeries(end-delay-lag+2:end),inputSeriesVal(1:end)];
[Xs,Xi,Ai,Ts] = preparets(net,{},{},inputSeriesPred);
yPred = net(Xs,Xi);
perf = perform(net,yPred,inputSeriesVal)
%%
plot(cell2mat(yPred),'r');
hold all;
plot( cell2mat(inputSeriesVal),'b');
legend('Predict', 'target');

And here is the one of result when i run code. It create a strange line compare to target line.
https://www.dropbox.com/s/6p57eqraqjgf1ry/example2.jpg
But this code is right with simplenar_dataset.
Please see and help me solve this problem.
Thank you very much
Phuong.



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.