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 |
an object of class |
with.secondwinner |
switch to specify whether the second best matching unit should be computed and returned |
... |
not used |
The newdata
object must be of class
"crossdist"
as returned by dist
and must
contain the dissimilarities between the original data (used to fit the
SOM) and the new data (for which the quantisation error is to be
computed).
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, as obtained by the relational formula (with possible negative values preserved) |
winners |
if |
Fabrice Rossi
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | data(iris)
# scaling
data <- scale(iris[1:4])
# use only part of the data
train <- sample(1:nrow(data),100)
data.train <- data[train,]
d <- dist(data.train)
# a small hexagonal grid
sg <- somgrid(xdim=5,ydim=5,topo="hex")
# fit the SOM
som <- batchsom(d,sg)
# map remaining data
results <- predict(som,dist(data.train,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.