Hi, I was trying to use the nnet library and am not sure of whats going on. I am calling the nnet function as: n <- nnet(x,y,size=3,subset=sets[[1]], maxit=200) Where x is a 272x4 matrix of observations (examples) and y is a 272x1 matrix of target values. However when I look at nnet$residuals they are off by two orders of magnitude (compared to the output from neural network code that I already have). Looking at nnet$fitted.values shows all the values to be 1 (whereas my target values range from 0 to 150). Am I making an obvious mistake in the way I'm calling the function? Is the fact that n$fitted.values is all 1's indicating that the NN is doing a classification? If so how can I make it do quantitation? The man page mentions that if the response is a factor then it defaults to quantitation. However my y matrix just contain numbers - so it should'nt be doing classification. Any pointers would be appreciated. Thanks, ------------------------------------------------------------------- Rajarshi Guha <rxg218 at psu.edu> <http://jijo.cjb.net> GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE ------------------------------------------------------------------- Psychology is merely producing habits out of rats.
Prof Brian Ripley
2003-Oct-21 06:43 UTC
[R] nnet behaves as documented (was nnet behaving oddly)
On 20 Oct 2003, Rajarshi Guha wrote:> Hi, > I was trying to use the nnet library and am not sure of whats going > on. I am calling the nnet function as: > > n <- nnet(x,y,size=3,subset=sets[[1]], maxit=200) > > Where x is a 272x4 matrix of observations (examples) and y is a 272x1 > matrix of target values. However when I look at nnet$residuals they are > off by two orders of magnitude (compared to the output from neural > network code that I already have). Looking at nnet$fitted.values shows > all the values to be 1 (whereas my target values range from 0 to 150). > > Am I making an obvious mistake in the way I'm calling the function? Is > the fact that n$fitted.values is all 1's indicating that the NN is doing > a classification? If so how can I make it do quantitation?Yes, so please do read the help page accurately.> The man page mentions that if the response is a factor then it defaults > to quantitation. However my y matrix just contain numbers - so it > should'nt be doing classification.That's incorrect reading of the help page, which actually says If the response in 'formula' is a factor, an appropriate classification network is constructed; this has one output and entropy fit if the number of levels is two, and a number of outputs equal to the number of classes and a softmax output stage for more levels. If the response is not a factor, it is passed on unchanged to 'nnet.default'. and you did not give a formula. As someone else said recently. those who write the manuals don't expect to either read them for you nor re-write them here, so please show more consideration for their work. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
> From: Rajarshi Guha [mailto:rxg218 at psu.edu] > > Hi, > I was trying to use the nnet library and am not sure of > whats going on. I am calling the nnet function as: > > n <- nnet(x,y,size=3,subset=sets[[1]], maxit=200)Please give us output of something like: str(x) summary(y) Also, I believe the subset argument is only meant for calls via formula; e.g., nnet(y ~ x, ...) and needs to be a vector of logicals the same length as the number of rows in x, indicating which rows to include in the fitting. Please also tell us what sets[[1]] is. Andy> Where x is a 272x4 matrix of observations (examples) and y is > a 272x1 matrix of target values. However when I look at > nnet$residuals they are off by two orders of magnitude > (compared to the output from neural network code that I > already have). Looking at nnet$fitted.values shows all the > values to be 1 (whereas my target values range from 0 to 150). > > Am I making an obvious mistake in the way I'm calling the > function? Is the fact that n$fitted.values is all 1's > indicating that the NN is doing a classification? If so how > can I make it do quantitation? > > The man page mentions that if the response is a factor then > it defaults to quantitation. However my y matrix just contain > numbers - so it should'nt be doing classification. > > Any pointers would be appreciated. > > Thanks, > > ------------------------------------------------------------------- > Rajarshi Guha <rxg218 at psu.edu> <http://jijo.cjb.net> > GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE > ------------------------------------------------------------------- > Psychology is merely producing habits out of rats. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo> /r-help >