predict.somnum: Map new data to a fitted Self-Organising Map for vector data

Description Usage Arguments Value Author(s) Examples

Description

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

Usage

1
2
## S3 method for class 'somnum'
predict(object, newdata, ...)

Arguments

object

an object of class "somnum"

newdata

a matrix or a data frame of data compatible with the data used to fit the object Self-Organising Map (that is with identical dimension)

...

not used

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

Author(s)

Fabrice Rossi

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
data(iris)
# scaling
data <- scale(iris[1:4])

# use only part of the data
train <- sample(1:nrow(data),100)
data.train <- data[train,]

# a small hexagonal grid
sg <- somgrid(xdim=5,ydim=5,topo="hex")

# fit the SOM
som <- batchsom(data,sg)

# map remaining data
results <- predict(som,data[-train,])
print(paste("Quantisation error:",results$error))

yasomi documentation built on May 2, 2019, 5:59 p.m.