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: how to train the network for stock data
Replies: 3   Last Post: Dec 13, 2012 10:06 AM

Advanced Search

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

Posts: 5,923
Registered: 12/7/04
Re: how to train the network for stock data
Posted: Nov 29, 2012 1:30 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Murugan Solaiyappan" wrote in message <k945lb$4lr$1@newscl01ah.mathworks.com>...
> Dear matlab friends,
> Greetings to all.
>
> I have trouble with train the stock data.
> here my code is,
>
> load ti_out_t.data;
> P=ti_out_t(1:189,1:12);
> T=ti_out_t(1:189,13:24);
> [pn,minp,maxp,tn,mint,maxt]=premnmx(P',T');


[ I N ] =size(pn) % [ 12 189 ]
[ O N ] = size(tn) % [ 12 189]
Neq = N*O % 2268 No. of training equations

For a nnet with I-H-O node topology there will be
Nw = (I+1)*H+(H+1)*O unknown weights. For training
without a validation set or regularization need Neq >= Nw.
The resulting upperbound for H is

Hub = floor( (Neq-O)/(I+O+1) ) = floor(2267/25) = 90

However, to mitigate noise and measurement error desire
Neq >> Nw or equivalently H << 90. Try Ntrials = 10
designs with H = Hub/10 = 9. If none of them are satisfactory,
increase H.

rng(0) % Initialize the RNG

% Using as many defaults as reasonable:

net=newff(minmax(pn),[ H O ],{'tansig','tansig'});
net.trainParam.goal = 0.01*mean(var(tn'));
net.trainParam.show = 10;
[ net tr yn en ] = train(net,pn,tn); % tr contains all training info

% Unnormalize yn to get y from mint and maxt

> ti_out_t.data contains 271 rows and 24 columns.

2*189 = 378 ??

> P is input data and t is output data.
>
> When I execute the above code in matlab, the following error displayed,
>
> ??? Error using ==> network.train at 145
> Targets are incorrectly sized for network.
> Matrix must have 1 rows.


You used O = 1 instead of 12.

Hope this helps.

Greg



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.