kMeansMap: Create a map from k-Means clusters

View source: R/coords.R

kMeansMapR Documentation

Create a map from k-Means clusters

Description

May give better results than 'RandomMap' on data where random sampling is complicated. This does not use actual kMeans clustering, but re-uses the batch version of SOM() with tiny radius (which makes it work the same as kMeans). In consequence, the speedup of SOM function is applied here as well. Additionally, because we don't need that amount of clustering precision, parameters ‘batch=F, rlen=1’ may give a satisfactory result very quickly.

Usage

kMeansMap(data, k, coordsFn, batch = T, ...)

Arguments

data

Input data matrix, with individual data points in rows

k

How many points to sample

coordsFn

a function to generate embedding coordinates (default none)

batch

Use batch-SOM training (effectively kMeans, default TRUE)

...

Passed to SOM(), useful e.g. for 'parallel=T' or 'rlen=5'

Value

map object (without the grid, if coordsFn was not specified)

Examples

d <- iris[,1:4]
EmbedSOM::PlotEmbed(
  EmbedSOM::EmbedSOM(
    data = d,
    map = EmbedSOM::kMeansMap(d, 10, EmbedSOM::GraphCoords())),
  pch=19, clust=iris[,5]
)

EmbedSOM documentation built on July 5, 2022, 5:14 p.m.