Learn R Programming

aweSOM (version 1.1)

aweSOMsmoothdist: Smooth Distance Plot for SOM

Description

Plots a visualization of the distances between the SOM cells. Based on the U-Matrix, which is computed for each cell as the mean distance to its immediate neighbors.

Usage

aweSOMsmoothdist(
  som,
  pal = c("viridis", "grey", "rainbow", "heat", "terrain", "topo", "cm",
    rownames(RColorBrewer::brewer.pal.info)),
  reversePal = FALSE
)

Arguments

som

kohonen object, a SOM created by the kohonen::som function.

pal

character, the color palette. Default is "viridis". Can be "viridis", "grey", "rainbow", "heat", "terrain", "topo", "cm", or any palette name of the RColorBrewer package.

reversePal

logical, whether color palette should be reversed. Default is FALSE.

Value

No return value, called for side effects.

Details

Note: the resulting smooth distance plot is inexact for the hexagonal map layout.

Examples

Run this code
# NOT RUN {
## Build training data
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)
ok.som <- kohonen::som(dat, grid = kohonen::somgrid(4, 4, 'rectangular'),
                       rlen = 100, alpha = c(0.05, 0.01),
                       radius = c(2.65,-2.65), init = init,
                       dist.fcts = 'sumofsquares')
aweSOMsmoothdist(ok.som)
# }

Run the code above in your browser using DataLab