
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, > > 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 IHO 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( (NeqO)/(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

