[R] nnet learning

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Oct 18 14:48:55 CEST 2004


On Mon, 18 Oct 2004, Samuel Kemp wrote:

> I am trying to make a neural network learning a "noisy sine wave". 
> Suppose I generate my data like so..
> 
> x <- seq(-2*pi, 2*pi, length=500)
> y <- sin(x) + rnorm(500, sd=sqrt(0.075))
> 
> I then train the neural net on the first 400 points using
> 
> c <- nnet(as.matrix(x[1:400]),as.matrix(y[1:400]), size=3, maxit=10000, 
> abstol=0.075, decay=0.007)
> 
> Inspecting the fit of the training set against the actual values using:
> 
> pmat<- plot(y[1:400])
> lines(c$fitted.values, col="blue", lwd=2)
> 
> It seems as though neural net is not learning the negative values. I 
> have tried running nnet several times, but each time I get the same 
> problem. I have also tried upsampling, but no joy.
> 
> I suspect that I am not using nnet correctly. Can anyone provide any 
> hints/solutions?

Yes, please read the documentation, as the posting guide asks you to.
Hint: it's on p. 246.  Compare your example with that given there.

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