# bestCriterion: Best clustering index In clusterCrit: Clustering Indices

## Description

`bestCriterion` returns the best index value according to a specified criterion.

## Usage

 `1` ``` bestCriterion(x, crit) ```

## Arguments

 `x` `[matrix]` : a numeric vector of quality index values. `crit` `[character]` : a string specifying the name of the criterion which was used to compute the quality indices.

## Details

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.

## Value

The index in vector `x` of the best value according to the criterion specified by the `crit` argument.

## Author

Bernard Desgraupes
bernard.desgraupes@u-paris10.fr
University of Paris Ouest - Nanterre
Lab Modal'X (EA 3454)

`getCriteriaNames`, `intCriteria`.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13``` ```# 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") ```

### Example output

```Best index value is 807.5421
```

clusterCrit documentation built on May 2, 2019, 3:22 p.m.