Description Usage Arguments Details Value Examples
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).
1 |
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" |
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.
1 2 3 4 5 6 7 8 9 10 | 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(6.08,-6.08), init = init,
dist.fcts = 'sumofsquares')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.