[R] R: nnet(): how number of weights are calculated, and what the output means

David Winsemius dwinsemius at comcast.net
Thu Jun 30 16:50:19 CEST 2011


On Jun 30, 2011, at 9:11 AM, Hafsa Hassan wrote:

> Dear list,
>
> I am new to programming in R, and am implementing my own neural  
> network code
> and trying to compare its output with that of nnet().
> I have tried the nnet CRAN help package, google and R-help mailing  
> list to
> find out what the nnet() output means, and what the training  
> algorithm is,
> but haven't found any help.

http://cran.r-project.org/src/contrib/nnet_7.3-1.tar.gz

  Not clear why you are asking for citations, They were in the help  
page.
References
Ripley, B. D. (1996) Pattern Recognition and Neural Networks. Cambridge.

Venables, W. N. and Ripley, B. D. (2002) Modern Applied Statistics  
with S. Fourth edition. Springer.



> Using the nnet() examples code:
> # use half the iris data
> ir <- rbind(iris3[,,1],iris3[,,2],iris3[,,3])
> targets <- class.ind( c(rep("s", 50), rep("c", 50), rep("v", 50)) )
> samp <- c(sample(1:50,25), sample(51:100,25), sample(101:150,25))
> ir1 <- nnet(ir[samp,], targets[samp,], size = 2, rang = 0.1,
> decay = 5e-4, maxit = 200)
> test.cl <- function(true, pred) {
> true <- max.col(true)
> cres <- max.col(pred)
> table(true, cres)
> }
> test.cl(targets[-samp,], predict(ir1, ir[-samp,]))
> #
> The code outputs number of weights, followed by value after each 10th
> iteration, and then finishes
> on converging to a final value or reaching maxit number of iterations.
> I need to know how the number of weights are calculated from the  
> size of the
> data and targets (x and y), and the size set in the arguments. Also,  
> can
> someone could guide me to a help link or book which can tell me what
> algorithm nnet uses, and what the components of the nnet object  
> returned
> mean, (e.g 'n', 'nconn', 'nsunits' etc. )?
> I need this information to program how to use the information in the  
> nnet
> object to predict results, without using the nnet predict function.
>
> Thanks,
> Hafsa
> P.S: If it helps, >attributes(ir1) #ir1 is the nnet object returned
> gives a list of 15 components of the nnet class - I want to ask how  
> the
> components 'n','nconn', 'conn', 'nsunits', 'nunits' mean.
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Inf-in-nnet-final-value-for-validation-data-tp893725p3635574.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org 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.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list