# rand_indep: Computes the Rand similarity index of two clusterings of the... In clusteval: Evaluation of Clustering Algorithms

### Description

For two clusterings of the same data set, this function calculates the Rand similarity coefficient of the clusterings from the comemberships of the observations. Basically, the comembership is defined as the pairs of observations that are clustered together.

### Usage

 1  rand_indep(labels1, labels2) 

### Arguments

 labels1 a vector of n clustering labels labels2 a vector of n clustering labels

### Details

To calculate the Rand index, we compute the 2x2 contingency table, consisting of the following four cells:

n_11

the number of observation pairs where both observations are comembers in both clusterings

n_10

the number of observation pairs where the observations are comembers in the first clustering but not the second

n_01

the number of observation pairs where the observations are comembers in the second clustering but not the first

n_00

the number of observation pairs where neither pair are comembers in either clustering

The Rand similarity index is defined as:

R = \frac{n_{11} + n_{00}}{n_{11} + n_{10} + n_{01} + n_{00}}

.

To compute the contingency table, we use the comembership_table function.

### Value

the Rand index for the two sets of cluster labels

### Examples

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ## Not run: # We generate K = 3 labels for each of n = 10 observations and compute the # Rand similarity index between the two clusterings. set.seed(42) K <- 3 n <- 10 labels1 <- sample.int(K, n, replace = TRUE) labels2 <- sample.int(K, n, replace = TRUE) rand_indep(labels1, labels2) # Here, we cluster the \code{\link{iris}} data set with the K-means and # hierarchical algorithms using the true number of clusters, K = 3. # Then, we compute the Rand similarity index between the two clusterings. iris_kmeans <- kmeans(iris[, -5], centers = 3)\$cluster iris_hclust <- cutree(hclust(dist(iris[, -5])), k = 3) rand_indep(iris_kmeans, iris_hclust) ## End(Not run) 

clusteval documentation built on May 19, 2017, 10:17 p.m.
Search within the clusteval package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs in the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.