To normalize the data, the mean and standard deviations are obtained for all independent variables in the training data. Normalization is then carried out using the scale function:

For both the train and test data, the mean and standard deviations are based on the training data used.
# Normalizationm <- colMeans(training)sd <- apply(training, 2, sd)training <- scale(training, center = m, scale = sd)test <- scale(test, center = m, scale = sd)

This concludes the data preparation step for this data. It should be noted that different datasets may need extra steps that are unique to that dataset—for example, many large datasets may have very high amounts of missing data values, and they may require additional data preparation steps ...

Get Advanced Deep Learning with R now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.