jaccardIndex: The Jaccard similarity coefficient is defined as: J =...

Description Usage Arguments Details Value Examples

J = \frac{n_{11}}{n_{11} + n_{10} + n_{01}}

.

Description

In the special case that the Jaccard coefficient results in 0/0, we define J = 0. For instance, this case can occur when both clusterings consist of all singleton clusters.

Usage

1
jaccardIndex(labels1, labels2)

Arguments

labels1

a vector of n clustering labels

labels2

a vector of n clustering labels

Details

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

Value

the Jaccard coefficient for the two sets of cluster labels (See' Details.)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Not run: 
# We generate K = 3 labels for each of n = 10 observations and compute the
# Jaccard similarity coefficient 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)
jaccardIndex(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 Jaccard similarity coefficient between the two
# clusterings.
iris_kmeans <- kmeans(iris[, -5], centers = 3)$cluster
iris_hclust <- cutree(hclust(dist(iris[, -5])), k = 3)
jaccardIndex(iris_kmeans, iris_hclust)

## End(Not run)

nguforche/UnsupRF documentation built on May 5, 2019, 4:51 p.m.