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

Hafsa Hassan Hafsa.Hassan at trgworld.com
Thu Jun 30 15:11:34 CEST 2011


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.
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.



More information about the R-help mailing list