There are two things going on here:
- Training your model, i.e. setting the internal coefficients in the neural network. You use both the inputs and output for this.
- Using the model, i.e. getting predictions with fixed internal coefficients.
For part 1, you've decided to normalize your data. So the neural net works on normalized data. So you have trained the neural net
- on the inputs fX(X) rather than X, where fX is the transform you used to the matrix of original inputs to produce the normalized inputs.
- on the outputs fy(y) rather than y, where fy is the transform you applied to the vector of outputs to get the normalized outputs.
In terms of your original inputs and outputs your trained machine now looks like this:
- Apply the normalization function fX to inputs to get normalized inputs fX(X).
- Run neural net with normalized inputs to produce normalized outputs fy(y).
- Apply the denormalization function fy-1 to the normalized outputs fy(y) to get y.
Note that fX(X) and fy, and hence fy-1, are defined on the training set.
So in R you might write something like this to get training data and normalize it, the first 100 rows
tx <- x[1:100,]
ntx <- normalizeData(tx, type='0_1')
ty <- y[1:100]
nty <- normalizeData(ty, type='0_1')
and something like this to denormalize the predicted results
pred.y <- denormalizeData(pred.ny, getNormParameters(nty))
# nty (or ny) not nx here
The slight concern I have is that I'd prefer to normalize the features used in prediction using the same transform fX that I used for training, but looking at the RSNNS documentation this facility doesn't appear to be present (it would be easy to write it yourself, however). It would probably be OK to normalize the prediction features using the whole X matrix, i.e. including the training data. (I can also see it might be preferable to use the default, normalization to z-score that RSNNS provides rather than the "0_1" choice you have used.)