I am new to modeling with neural networks, but I managed to establish a neural network with all available data points that fits the observed data well. The neural network was done in R with the nnet package:
require(nnet)
##33.8 is the highest value
mynnet.fit <- nnet(DOC/33.80 ~ ., data = MyData, size = 6, decay = 0.1, maxit = 1000)
mynnet.predict <- predict(mynnet.fit)*33.80
mean((mynnet.predict - MyData$DOC)^2) ## mean squared error was 16.5
The data I am analyzing looks as follows, where the DOC is the variable that has to be modeled (there are about 17,000 observations):
Q GW_level Temp t_sum DOC
1 0.045 0.070 12.50 0.2 11.17
2 0.046 0.070 12.61 0.4 11.09
3 0.046 0.068 12.66 2.8 11.16
4 0.047 0.050 12.66 0.4 11.28
5 0.049 0.050 12.55 0.6 11.45
6 0.050 0.048 12.45 0.4 11.48
Now, I have read that the model should be trained with 70% of the data points, and validated with the remaing 30% of the data points. How do I do this? Which functions do I have to use?
I used the train function from the caret package to calculate the parameters for size and decay.
require(caret)
my.grid <- expand.grid(.decay = c(0.5, 0.1), .size = c(5, 6, 7))
mynnetfit <- train(DOC/33.80 ~ ., data = MyData, method = "nnet", maxit = 100, tuneGrid = my.grid, trace = f)
Any direct help or linkage to other websites/posts is greatly appreciated.