compare.jaccard: Comparison of two sets of clusters, using Jaccard index

compare.jaccardR Documentation

Comparison of two sets of clusters, using Jaccard index

Description

Comparison of two sets of clusters, using Jaccard index

Usage

compare.jaccard(clus, gt, comp = c("max", "pairwise", "cluster"))

Arguments

clus

The extracted clusters.

gt

The real clusters.

comp

How the two partitions are compared. "max" matches each extracted cluster with the class it agrees with most and averages the per-cluster scores, weighted by cluster size; "cluster" returns those scores instead of averaging them; "pairwise" ignores the labels and looks at every pair of observations, asking whether the two partitions agree on grouping it or separating it. In "pairwise" mode this function is the Rand index: the proportion of pairs the two partitions agree on, counting both those they group and those they keep apart. See compare.jaccard and compare.kappa for the two other readings of the same pair counts.

Value

A numeric value indicating how much the two sets of clusters are similar.

The pairwise index

the Jaccard index on pairs – the pairs both partitions group together, over the pairs at least one of them groups. Unlike the Rand index of compare.accuracy it ignores the pairs both keep apart, a cell that dominates as soon as there are many clusters: 150 singletons out of 150 observations score 0.67 with the Rand index and 0 here.

See Also

compare.accuracy, compare.kappa, compare

Examples

require (datasets)
data (iris)
km = KMEANS (iris [, -5], k = 3)
compare.jaccard (km$cluster, iris [, 5])

fdm2id documentation built on Aug. 28, 2026, 9:07 a.m.