I am trying to predict the times table training a neural network. However, I couldn't really get how preProcess argument works in train function in Caret.

In the docs, it says:

The preProcess class can be used for many operations on predictors, including centering and scaling.

When we set preProcess like below,

tt.cv <- train(product ~ .,
               data = tt.train,
               method = 'neuralnet',
               tuneGrid = tune.grid,
               trControl = train.control,
               linear.output = TRUE,
               algorithm = 'backprop',
               preProcess = 'range',
               learningrate = 0.01)
  1. Does it mean that the train function preprocesses (normalizes) the training data passed, in this case tt.train?
  2. After the training is done, when we are trying to predict, do we pass normalized inputs to the predict function or are inputs normalized in the function because we set the preProcess parameter?
# Do we do
predict(tt.cv, tt.test)
# or
predict(tt.cv, tt.normalized.test)
  1. And from the quote above, it seems that when we use preProcess, outputs are not normalized this way in training, how do we go about normalizing outputs? Or do we just normalize the training data beforehand like below and then pass it to the train function?
preProc <- preProcess(tt, method = 'range')
tt.preProcessed <- predict(preProc, tt)
tt.preProcessed.train <- tt.preProcessed[indexes,]
tt.preProcessed.test <- tt.preProcessed[-indexes,]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.