predict.relationalsom: Map new data to a fitted Relational Self-Organising Map

Description Usage Arguments Details Value Author(s) Examples

View source: R/relational.R

Description

Map new data to a fitted Self-Organising Map, i.e., compute the best matching unit for each given observation.

Usage

1
2
3
## S3 method for class 'relationalsom'
predict(object, newdata,
        with.secondwinner=FALSE,...)

Arguments

object

an object of class "relationalsom"

newdata

an object of class "crossdist" compatible with the fitted som (see details)

with.secondwinner

switch to specify whether the second best matching unit should be computed and returned

...

not used

Details

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).

Value

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 error.quantisation.relationalsom for a definition of this value)

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 with.secondwinner=TRUE a two column matrix with a line per observation containing the index of the best matching unit and of the second best matching unit (in this order)

Author(s)

Fabrice Rossi

Examples

 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))

yasomi documentation built on May 21, 2017, 3:32 a.m.

Search within the yasomi package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs in the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.