# load data
data("auto_mpg")
s = sample(1:392, 300)
train_set = auto_mpg[s,1:8]
# Train Gsom Model
gsom_object <- train_xy.gsom(train_set[,2:8], train_set[,1], spreadFactor = 0.9)
# Fixed Grid size
gsom_object <- train_xy.gsom(train_set[,2:8], train_set[,1], gridsize = 6)
# Train Gsom Model (hexagonal grid)
gsom_object <- train_xy.gsom(train_set[,2:8], train_set[,1], spreadFactor = 0.9, nhood="hex")
# Plot Predicted values for each node
plot(gsom_object)
par(mfrow=c(2,2))
plot(gsom_object, type = "property")
par(mfrow=c(1,1))
plot(gsom_object, type = "predict")
Run the code above in your browser using DataLab