Best clustering index
bestCriterion
returns the best index value according to a specified criterion.
bestCriterion(x, crit)
x |
|
crit |
|
Given a vector of several clustering quality index values computed
with a given criterion, the function bestCriterion
returns the
index of the "best" one in the sense of the specified criterion.
Typically, a set of data has been clusterized several times (using
different algorithms or specifying a different number of clusters) and
a clustering index has been calculated each time : the
bestCriterion
function tells which value is considered the best
according to the given clustering index. For instance, if one uses
the Calinski_Harabasz index, the best value is the largest one.
A list of all the supported criteria can be obtained with the
getCriteriaNames
function. The criterion name
(crit
argument) is case insensitive and can be abbreviated.
The index in vector x
of the best value according to the criterion
specified by the crit
argument.
Bernard Desgraupes
bernard.desgraupes@u-paris10.fr
University of Paris Ouest - Nanterre
Lab Modal'X (EA 3454)
# Create some spheric data around three distinct centers x <- rbind(matrix(rnorm(100, mean = 0, sd = 0.5), ncol = 2), matrix(rnorm(100, mean = 2, sd = 0.5), ncol = 2), matrix(rnorm(100, mean = 4, sd = 0.5), ncol = 2)) vals <- vector() for (k in 2:6) { # Perform the kmeans algorithm cl <- kmeans(x, k) # Compute the Calinski_Harabasz index vals <- c(vals,as.numeric(intCriteria(x,cl$cluster,"Calinski_Harabasz"))) } idx <- bestCriterion(vals,"Calinski_Harabasz") cat("Best index value is",vals[idx],"\n")
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.