[R] how to get actual value from predict in nnet?

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Jul 28 07:41:57 CEST 2005


Ask predict.nnet for a type other than "class", as described on its help 
page.

Please do read the help pages for yourself (as the posting guide asks).

On Wed, 27 Jul 2005, Baoqiang Cao wrote:

> Dear All,
>
> After followed the help of nnet, I could get the networks trained and, 
> excitedly, get the prediction for other samples. It is a two classes 
> data set, I used "N" and "P" to label the two. My question is, how do I 
> get the predicted numerical value for each sample? Not just give me the 
> label(either "N" or "P")?  Thanks!
>
> FYI: The nnet example I followed from help document is,
> ird <- data.frame(rbind(iris3[,,1], iris3[,,2], iris3[,,3]),
>             species = c(rep("s",50), rep("c", 50), rep("v", 50)))
>     ir.nn2 <- nnet(species ~ ., data = ird, subset = samp, size = 2, rang = 0.1,
>                    decay = 5e-4, maxit = 200)
>     table(ird$species[-samp], predict(ir.nn2, ird[-samp,], type = "class"))

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