[R] nnet behaves as documented (was nnet behaving oddly)
Prof Brian Ripley
ripley at stats.ox.ac.uk
Tue Oct 21 08:43:01 CEST 2003
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
More information about the R-help
mailing list