# NOT RUN {
data(wines)
set.seed(7)
SOM.map <- imputeSOM(scale(wines), grid = somgrid(5, 5, "hexagonal"), rlen=100)
plot(SOM.map, type="changes")
counts <- plot(SOM.map, type="counts", shape = "straight")
## show both sets of codebook vectors in the map
plot(SOM.map, type="codes", main = c("Codes X"))
oldpar <- par(mfrow = c(1,2))
similarities <- plot(SOM.map, type="quality", palette.name = terrain.colors)
plot(SOM.map, type="mapping",
labels = as.integer(vintages), col = as.integer(vintages),
main = "mapping plot")
par(oldpar)
## Show 'component planes'
set.seed(7)
sommap <- imputeSOM(scale(wines), grid = somgrid(6, 4, "hexagonal"))
plot(sommap, type = "property", property = sommap$codes[,1],
main = colnames(sommap$codes)[1])
## Show the U matrix
Umat <- plot(sommap, type="dist.neighbours", main = "SOM neighbour distances")
## use hierarchical clustering to cluster the codebook vectors
som.hc <- cutree(hclust(object.distances(sommap, "codes")), 5)
add.cluster.boundaries(sommap, som.hc)
## and the same for rectangular maps
set.seed(7)
sommap <- imputeSOM(scale(wines),grid = somgrid(6, 4, "rectangular"))
plot(sommap, type="dist.neighbours", main = "SOM neighbour distances")
## use hierarchical clustering to cluster the codebook vectors
som.hc <- cutree(hclust(object.distances(sommap, "codes")), 5)
add.cluster.boundaries(sommap, som.hc)
# }
Run the code above in your browser using DataLab