Search All of the Math Forum:

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

Topic: how to train the network for stock data
Replies: 3   Last Post: Dec 13, 2012 10:06 AM

 Messages: [ Previous | Next ]
 Greg Heath Posts: 6,319 Registered: 12/7/04
Re: how to train the network for stock data
Posted: Nov 29, 2012 1:30 PM

"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,
>
> 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

Date Subject Author
11/27/12 Murugan Solaiyappan
11/29/12 Greg Heath
12/12/12 Murugan Solaiyappan
12/13/12 Greg Heath