March 2019
Beginner to intermediate
250 pages
6h 6m
English
It's now time to train the SOM using R. For that, we will use the kohonen package. The name of the package comes from Teuvo Kohonen, who first introduced this algorithm.
As SOM is mainly based on Euclidean distances, it is recommended to standardize your variables. We will use the caret package for this, as follows:
library(kohonen)library(caret)preprocess <- preProcess(macroeconomic_data[,4:13], method=c("center", "scale"))print(preprocess) ## Created from 224 samples and 10 variables ## ## Pre-processing: ## - centered (10) ## - ignored (0) ## - scaled (10)
This will create a data frame with the transformed variables. Then, we will add the country name and ratings to this transformed data frame, as follows:
macroeconomic_data_trn ...
Read now
Unlock full access