kmeansruns {fpc}R Documentation

k-means clustering with several random initializations

Description

This calls the function kmeans to perform a k-means clustering, but initializes the k-means algorithm several times with random points from the data set as means. Furthermore, it is more robust against the occurrence of empty clusters in the algorithm.

Usage

kmeansruns(data,k,iter.max=100,runs=100,scaledata=FALSE,plot=FALSE)

Arguments

data A numeric matrix of data, or an object that can be coerced to such a matrix (such as a numeric vector or a data frame with all numeric columns).
k integer. The number of clusters.
iter.max integer. The maximum number of iterations allowed.
runs integer. Number of starts of the k-means algorithm.
scaledata logical. If TRUE, the variables are centered and scaled to unit variance before execution.
plot logical. If TRUE, every clustering resulting from a run of the algorithm is plotted.

Value

The output of the optimal run of the kmeans-function. A list with components

cluster A vector of integers indicating the cluster to which each point is allocated.
centers A matrix of cluster centers.
withinss The within-cluster sum of squares for each cluster.
size The number of points in each cluster.

Author(s)

Christian Hennig chrish@stats.ucl.ac.uk http://www.homepages.ucl.ac.uk/~ucakche/

See Also

kmeans

Examples

  
  set.seed(20000)
  face <- rFace(50,dMoNo=2,dNoEy=0,p=2)
  kmr1 <- kmeansruns(face,k=5,runs=1)
  kmr5 <- kmeansruns(face,k=5,runs=5)

[Package fpc version 1.2-3 Index]