som {kohonen}R Documentation

Kohonen's self-organising maps

Description

Self-organising maps for mapping high-dimensional spectra or patterns to 2D; the Euclidean distance is used. Modelled after the SOM function in package class.

Usage

som(data, grid=somgrid(), rlen = 100, alpha = c(0.05, 0.01),
    radius = quantile(nhbrdist, 0.67), init,
    toroidal = FALSE, FineTune = TRUE, keep.data = TRUE)

Arguments

data a matrix, with each row representing an object.
grid a grid for the representatives: see 'somgrid'.
rlen the number of times the complete data set will be presented to the network.
alpha learning rate, a vector of two numbers indicating the amount of change. Default is to decline linearly from 0.05 to 0.01 over rlen updates.
radius the initial radius of the neighbourhood to be used for each update: it decreases linearly to 1 over rlen updates. The default is to start with a value that covers 2/3 of all units.
init the initial representatives, represented as a matrix. If missing, chosen (without replacement) randomly from 'data'.
toroidal if TRUE, the edges of the map are joined. Note that in a hexagonal toroidal map, the number of rows must be even.
FineTune apply kmeans for fine-tuning the codebook vectors.
keep.data save data in return value.

Value

an object of class "kohonen" with components

grid the grid, an object of class "somgrid".
changes vector of mean average deviations from code vectors.
codes a matrix of code vectors.
classif winning units for all data objects.
toroidal whether a toroidal map is used.
data data matrix, only if keep.data is TRUE.
type the type of som, here "som"

Author(s)

Ron Wehrens

References

W.J. Melssen, R. Wehrens, and L.M.C. Buydens. Chemom. Intell. Lab. Syst., 83, 99-113 (2006)..

See Also

xyf, bdk, plot.kohonen

Examples

data(wines)
set.seed(7)

training <- sample(length(wine.classes), 120)
Xtraining <- scale(wines[training,])
som.wines <- som(Xtraining, grid = somgrid(5, 5, "hexagonal"))

Xtest <- scale(wines[-training,],
               center = attr(Xtraining, "scaled:center"),
               scale = attr(Xtraining, "scaled:scale"))

som.prediction <-
  predict(som.wines, newdata = Xtest,
          trainX = Xtraining,
          trainY = classvec2classmat(wine.classes[training]))
table(wine.classes[-training], som.prediction$classif)

[Package kohonen version 1.1.1 Index]