Description Usage Arguments Details Value Author(s) Examples
Map new data to a fitted Self-Organising Map, i.e., compute the best matching unit for each given observation.
1 2 3 |
object |
an object of class |
newdata |
a matrix compatible with the fitted som (see details) |
newdatanorms |
a vector containing the squared norm in kernel space of the new data (see details) |
with.secondwinner |
switch to specify whether the second best matching unit should be computed and returned |
... |
not used |
The newdata
matrix must contain the values of the kernel used
to fit the SOM evaluated between the original data and the new
data. More precisely, newdata[i,j]
contains the value of
K(x_i,nx_j), where x_i is the i-th original data point and
nx_j is the j-th new data point.
While this is not needed to compute the best matching unit, this
function requires in addition the value of the squared norm in kernel
space of the new data, that is a vector newdatanorms
such that
newdatanorms[j]
contains K(nx_j,nx_j).
A list with components
classif |
a vector of integer indicating to which unit each observation has been assigned |
error |
the quantisation error of the observations by the
prototypes of this Self-Organising Map (see
|
rdist |
a matrix of squared dissimilarities between the new data and the prototypes (some values might be negative if the underlying kernel is not positive) |
winners |
if |
Fabrice Rossi
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | data(iris)
# scaling
data <- scale(iris[1:4])
# use only part of the data
train <- sample(1:nrow(data),100)
data.train <- data[train,]
K <- as.kernelmatrix(tcrossprod(data.train))
# a small hexagonal grid
sg <- somgrid(xdim=5,ydim=5,topo="hex")
# fit the SOM
som <- batchsom(K,sg)
# map remaining data
results <- predict(som,tcrossprod(data.train,data[-train,]),
diag(tcrossprod(data[-train,])))
print(paste("Learning quantisation error:",error.quantisation(som)))
print(paste("Test quantisation error:",results$error))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.