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:
# 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 ...