[R] Neural Network resource
Tony Breyal
tony.breyal at googlemail.com
Wed May 27 17:47:00 CEST 2009
I haven't used the AMORE package before, but it sounds like you
haven't set linear output units or something. Here's an example using
the nnet package of what you're doing i think:
### R START###
> # set random seed to a cool number
> set.seed(42)
>
> # set up data
> x1<-rnorm(100); x2<-rnorm(100); x3<-rnorm(100)
> x4<-rnorm(100); x5<-rnorm(100); x6<-rnorm(100)
> b1<-1; b2<-2; b3<-3
> b4<-4; b5<-5; b6<-6
> y<-b1*x1 + b2*x2 + b3*x3 + b4*x4 + b5*x5 + b6*x6
> my.df <- data.frame(cbind(y, x1, x2, x3, x4, x5, x6))
>
> # 1. linear regression
> my.lm <- lm(y~., data=my.df)
>
> # look at correlation
> my.lm.predictions<-predict(my.lm)
> cor(my.df["y"], my.lm.predictions)
[,1]
y 1
>
> # 2. nnet
> library(nnet)
> my.nnet<-nnet(y~., data=my.df, size=3,
linout=TRUE, skip=TRUE,
trace=FALSE, maxit=1000)
>
> my.nnet.predictions<-predict(my.nnet, my.df)
> # look at correlation
> cor(my.df["y"], my.nnet.predictions)
[,1]
y 1
>
> # to look at the values side by side
> cbind(my.df["y"], my.nnet.predictions)
y my.nnet.predictions
1 10.60102566 10.59958907
2 6.70939465 6.70956529
3 2.28934732 2.28928930
4 14.51012458 14.51043732
5 -12.85845371 -12.85849345
[..etc]
### R END ###
Hope that helps a wee bit mate,
Tony Breyal
On 27 May, 15:36, Indrajit Sengupta <indra_cali... at yahoo.com> wrote:
> You are right there is a pdf file which describes the function. But let tell you where I am coming from.
>
> Just to test if a neural network will work better than a ordinary least square regression, I created a dataset with one dependent variable and 6 other independent variables. Now I had deliberately created the dataset in such manner that we have an excellent regression model. Eg: Y = b0 + b1*x1 + b2*x2 + b3*x3.. + b6*x6 + e
> where e is normal random variable. Naturally any statistical analysis system running regression would easily predict the values of b1, b2, b3, ..., b6 with around 30-40 observations.
>
> I fed this data into a Neural network (3 hidden layers with 6 neurons in each layer) and trained the network. When I passed the input dataset and tried to get the predictions, all the predicted values were identical! This confused me a bit and was wondering whether my understanding of the Neural Network was wrong.
>
> Have you ever faced anything like it?
>
> Regards,
> Indrajit
>
> ________________________________
> From: "markle... at verizon.net" <markle... at verizon.net>
>
> Sent: Wednesday, May 27, 2009 7:54:59 PM
> Subject: Re: [R] Neural Network resource
>
> Hi: I've never used that package but most likely there is a AMORE vignette that shows examples and describes the functions.
> it should be on the same cran web page where the package resides, in pdf form.
>
> Hi All,
>
> I am trying to learn Neural Networks. I found that R has packages which can help build Neural Nets - the popular one being AMORE package. Is there any book / resource available which guides us in this subject using the AMORE package?
>
> Any help will be much appreciated.
>
> Thanks,
> Indrajit
>
> ______________________________________________
> R-h... at r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-h... at r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list