[R] Help for using nnet in R for NN training and testing
kgorahava
kgorahava at gmail.com
Mon Aug 16 06:18:27 CEST 2010
Hello,
I want to use nnet package in R, to train and simulate a NN and get the
value of MSE.
I am reading in a file which has 19 input variables and one output variable
and has a total of 2000 observations. The first column in the file is a
column just for giving the serial numbers of the observations.
I have already read in the file and also extracted the different values into
the matrices to use. Please refer to the code below. I want to use 'xtrain'
and 'ytrain' to train the data (the 60% of the observations) and I want to
simulate the NN with 'xtest' and then compare the predicted Y values from
the NN with the 'ytest' to get a value of MSE.
*****************************************************************************
data<-read.table(file="C:/data.dat",sep=",")
headings<-
c("Class","x1","x2","x3","x4","x5","x6","x7","x8","x9","x10","x11","x12","x13","x14","x15","x16","x17","x18","x19","y")
colnames (data ) <− headings
xtrain<-data[1:1200,2:20]
ytrain<-data[1:1200,21]
xtest<-data[1201:2000,2:20]
ytest<-data[1201:2000,21]
xtrainytrain<-data[1:1200,1:20]
sample.int(1200, size=1200, replace = FALSE, prob = NULL)
ir.nn3<-nnet(xtrain[samp,], xtrainytrain[samp,], size =10, rang =
0.1,decay=5e-4,maxit=1000)
*******************************************************************
I am not sure if the sample.int function I used is correct. On running the
above code I get a following results in R :
%# weights: 420
%initial value 20006516456619.242187
%final value 20006423707287.324219
%converged
Can someone please guide me, what are these values? Are they the MSE values
? What should be the correct way of passing 'xtrain' and 'ytrain' to the
nnet function ? What can be the function to simulate the trained NN to get
the predicted Y values from the NN. Is there a command to get the MSE value
?
Please guide me.
--
View this message in context: http://r.789695.n4.nabble.com/Help-for-using-nnet-in-R-for-NN-training-and-testing-tp2326386p2326386.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list