predict.specproc_som: Map New Spectra onto a Self-Organizing Map

View source: R/som.R

predict.specproc_somR Documentation

Map New Spectra onto a Self-Organizing Map

Description

Places new spectra on the best-matching unit of a map fitted by som(), with their quantization error, and flags the spectra that fit no unit.

Usage

## S3 method for class 'specproc_som'
predict(object, newdata, ...)

Arguments

object

A map fitted by som().

newdata

A numeric matrix or data frame of spectra, with the variables of the training data.

...

Not used.

Value

A tibble with one row per spectrum: its best-matching unit, the coordinates x and y of the unit on the map, the quantization error qe, and novel, TRUE when the error exceeds the cut-off of the training spectra (the spectrum fits no known group).

See Also

som(), plot_som()

Examples

data(forageLIBS)
# the Na I and K I resonance lines
wl <- suppressWarnings(as.numeric(names(forageLIBS)))
spectra <- forageLIBS[which((wl > 585 & wl < 595) | (wl > 760 & wl < 780))]
fit <- som(spectra[1:300, ])
head(predict(fit, spectra[301:368, ]))

specProc documentation built on Nov. 20, 2026, 5:11 p.m.