somInit {aweSOM}R Documentation

Initialize SOM prototypes


Prototypes are the artificial points in data space that are used to cluster observations: each observation is assigned to the cluster of its closest prototype. In self-organizing maps, each cell of the map has its own prototype, and training is performed by iteratively adjusting the prototypes. This function creates an initial guess for the prototypes of a SOM grid, to be used as the init argument to the kohonen::som function (see example).


somInit(traindat, nrows, ncols, method = c("pca.sample", "pca", "random"))



Matrix of training data, that will also be used to train the SOM.


Number of rows on the map.


Number of columns on the map.


Method used, see Details. "pca" or "random"


The default method "pca.sample" takes as prototypes the observations that are closest to the nodes of a 2d grid placed along the first two components of a PCA. The "pca" method uses the nodes instead of the observations. The "random" method samples random observations.


A matrix of prototype coordinates.


dat <- iris[, c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width")]
### Scale training data
dat <- scale(dat)
## Train SOM
### Initialization (PCA grid)
init <- somInit(dat, 4, 4)
the.som <- kohonen::som(dat, grid = kohonen::somgrid(4, 4, 'hexagonal'), 
                        rlen = 100, alpha = c(0.05, 0.01), 
                        radius = c(2.65,-2.65), init = init, 
                        dist.fcts = 'sumofsquares')

[Package aweSOM version 1.2 Index]