predict.kohonen {kohonen}R Documentation

Classify using a trained Kohonen map

Description

Map objects to a trained Kohonen map. The map may be obtained by supervised methods (xyf, bdk), but only the X-space is considered in prediction. If the classification is already known, the function returns the similarity for each object to the unit it is mapped to.

Usage

predict.kohonen(object, ...)

Arguments

object trained network.
... optional arguments. Two arguments in particular are important: if a data argument is given (a data matrix with the same number of variables as the codebook vectors of the network), predictions for these objects are returned, both the units at which the objects are mapped and the distance to these units. If a classification vector is given (argument classif), the distances to the corresponding codebook vectors are calculated.

Value

Returns a list with components

unit.classif unit numbers to which objects in the data matrix are mapped.
classif classes associated with the units (only for the supervised bdk and xyf networks).
distances similarities, expressed as distances, of objects to codebook vectors.

Author(s)

Ron Wehrens

See Also

som,xyf,bdk

Examples

### Simulated example
library(MASS)

csize <- 15
c1 <- mvrnorm(csize, mu=c(5,3,4),
              Sigma=matrix(c(2, 0,0,0, 2, 1, 0, 1, 2),3,3))
c2 <- mvrnorm(csize, mu=c(5.5, 3.5, 4.5),
              Sigma=matrix(c(2, 0,0,0, 2, 1, 0, 1, 2),3,3))
c3 <- mvrnorm(csize, mu=c(0,0,0),
              Sigma=matrix(c(2, 0,0,0, 2, 1, 0, 1, 2),3,3))

X <- rbind(c1, c2, c3)
classes <- c(rep(1, csize), rep(2, csize), rep(3, csize))

bdkmod <- bdk(X, classvec2classmat(classes), somgrid(4, 4, "hexagonal"))

predict(bdkmod)

[Package kohonen version 1.0.0 Index]