[R] nnet question
Wensui Liu
liuwensui at gmail.com
Mon Jan 29 02:38:52 CET 2007
AM,
Don't worry. It is correct to get different correlation each time.
Unless you are very lucky, you will get different prediction for each
different training process, depending on your initial random state.
Take a look at Dr Ripley's MASS book, there are several excellent
examples on how to use nnet.
On 1/28/07, Aimin Yan <aiminy at iastate.edu> wrote:
> Hello,
> I use nnet to do prediction for a continuous variable.
> after that, I calculate correlation coefficient between predicted value and
> real observation.
>
> I run my code(see following) several time, but I get different correlation
> coefficient each time.
>
> Anyone know why?
>
> In addition, How to calculate prediction accuracy for prediction of
> continuous variable?
>
> Aimin
> thanks,
>
>
> > m.nn.omega <- nnet(omega~aa_three+bas+bcu+aa_ss, data=training, size=2,
> linout=TRUE)
> # weights: 57
> initial value 89153525.582093
> iter 10 value 15036439.951888
> iter 20 value 15010796.121891
> iter 30 value 15000761.804392
> iter 40 value 14955839.294531
> iter 50 value 14934746.564215
> iter 60 value 14933978.758615
> iter 70 value 14555668.381007
> iter 80 value 14553072.231507
> iter 90 value 14031071.223996
> iter 100 value 13709055.312482
> final value 13709055.312482
> stopped after 100 iterations
> > pr.nn.train<-predict(m.nn.omega,training)
> > corr.pr.nn.train<-round(cor(pr.nn.train,training$omega),2)
> > pr.nn.test<-predict(m.nn.omega,test)
> > corr.pr.nn.test<-round(cor(pr.nn.test,test$omega),2)
> > cat("correlation coefficient for train using neural
> network:",corr.pr.nn.train,"\n")
> correlation coefficient for train using neural network: 0.32
> > cat("correlation coefficient for test using neural
> network:",corr.pr.nn.test,"\n")
> correlation coefficient for test using neural network: 0.39
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
WenSui Liu
A lousy statistician who happens to know a little programming
(http://spaces.msn.com/statcompute/blog)
More information about the R-help
mailing list