Last data update: 2014.03.03

R: Map data to a supervised or unsupervised SOM
map.kohonenR Documentation

Map data to a supervised or unsupervised SOM

Description

Map a data matrix onto a trained SOM.

Usage

## S3 method for class 'kohonen'
map(x, newdata, whatmap = NULL, weights,
            scale.distances = (nmaps > 1), ...)

Arguments

x

A trained supervised or unsupervised SOM obtained from functions som, xyf, or bdk.

newdata

Data matrix, with rows corresponding to objects.

whatmap

For supersom maps: the layers to take into account.

weights

For supersom maps: weights of the layers that are used for mapping.

scale.distances

whether to rescale distances per layer in the case of supersom maps (default): if TRUE the maximal distance of each layer equals one. If the absolute values of the distances per layer should be used, this argument should be set to FALSE. Note that in that case, when mapping the training data, the result returned by map.kohonen will differ from the mapping present in the map.

...

Currently ignored.

Value

A list with elements

unit.classif

a vector of units that are closest to the objects in the data matrix.

dists

distances (currently only Euclidean distances) of the objects to the units.

whatmap,weights,scale.distances

Values used for these arguments.

Author(s)

Ron Wehrens

See Also

predict.kohonen

Examples

data(wines)
set.seed(7)

training <- sample(nrow(wines), 120)
Xtraining <- scale(wines[training, ])
somnet <- som(Xtraining, somgrid(5, 5, "hexagonal"))

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

Results