computeCKmeans: Constrained K-means clustering

View source: R/sampleCompute.R

computeCKmeansR Documentation

Constrained K-means clustering

Description

Perform Constrained K-means clustering, dealing with the number of clusters K, automatically or not.

Usage

computeCKmeans(
  x,
  K = 0,
  K.max = 20,
  mustLink = NULL,
  cantLink = NULL,
  maxIter = 2,
  kmeans.variance.min = 0.95
)

Arguments

x

matrix of raw data (point by line).

K

number of clusters. If K=0 (default), this number is automatically computed thanks to the Elbow method.

K.max

maximal number of clusters (K.Max=20 by default).

mustLink

list of ML (must-link) constrained pairs.

cantLink

list of CNL (cannot-link) constrained pairs.

maxIter

number of iterations for mpckm algorithm.

kmeans.variance.min

elbow method cumulative explained variance > criteria to stop K-search.

Details

computeCKmeans performs Constrained K-means clustering, dealing with the number of clusters K, automatically or not

Value

res.ckmeans results obtained from mpckm algorithm.

See Also

computeSemiSupervised, KwaySSSC

Examples

dat <- rbind(matrix(rnorm(100, mean = 0, sd = 0.3), ncol = 2), 
             matrix(rnorm(100, mean = 2, sd = 0.3), ncol = 2), 
             matrix(rnorm(100, mean = 4, sd = 0.3), ncol = 2))
tf <- tempfile()
write.table(dat, tf, sep=",", dec=".")
x <- importSample(file.features=tf)

ML=list(c(sel="10",mem="20"))
CNL=list(c(sel="1",mem="140"))

res.ckmeans <- computeCKmeans(x$features$initial$x, K=0, mustLink=ML, cantLink=CNL)

plot(dat[,1], dat[,2], type = "p", xlab = "x", ylab = "y", 
col = res.ckmeans$label, main = "Constrained K-means clustering")



RclusTool documentation built on May 29, 2024, 5:23 a.m.