The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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 ]

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.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)
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.
But this code is right with simplenar_dataset.
Please see and help me solve this problem.
Thank you very much

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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.