somInit {aweSOM}R Documentation

Initialize SOM prototypes

Description

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).

Usage

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

Arguments

traindat

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

nrows

Number of rows on the map.

ncols

Number of columns on the map.

method

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

Details

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.

Value

A matrix of prototype coordinates.

Examples

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]