Dunn Index Calculator

Inputs

Dunn index1.4615
Separation margin (min inter - max intra)1.20
Compactness ratio (max intra / min inter)0.6842
How this was calculated
  1. Inputs: smallest distance between any two clusters 3.80, largest diameter within any single cluster 2.60.
  2. The Dunn index divides the worst separation by the worst spread: 3.80 / 2.60.
  3. Dunn index = 1.4615.
  4. Above 1, even the closest clusters are farther apart than the widest cluster is wide; below 1 the widest cluster spans more than the smallest gap. Larger is better, and the index is driven entirely by the two extreme cases.

The Dunn index, introduced by J. C. Dunn in 1974, is the sternest of the cluster validity indices. It ignores averages entirely and judges a clustering by its two worst numbers: the smallest distance between any two clusters, and the largest diameter within any single cluster. Enter those two extremes and the calculator returns the index with the separation margin and compactness ratio that compose it.

Because it is built from extremes, the index answers a deliberately narrow question: even in the worst case, are the closest clusters still farther apart than the widest cluster is wide? If yes, the ratio exceeds 1 and the partition is defensible on its weakest flank.

Worked examples

Separation beats spread

(3.8 · 2.6)

Dunn index1.4615
Separation margin (min inter - max intra)1.20
Compactness ratio (max intra / min inter)0.6842

One wide cluster overlaps

(2.4 · 3.1)

Dunn index0.7742
Separation margin (min inter - max intra)-0.70
Compactness ratio (max intra / min inter)1.2917

Widely separated clusters

(5.6 · 1.9)

Dunn index2.9474
Separation margin (min inter - max intra)3.70
Compactness ratio (max intra / min inter)0.3393

Two extremes and nothing else

The numerator of the Dunn index is the minimum intercluster distance: over every pair of clusters, take the closest approach between them - in the original formulation, the distance between their two nearest points - and keep the smallest. The denominator is the maximum intracluster diameter: over every cluster, take the distance between its two farthest points, and keep the largest.

Every other feature of the clustering - how many clusters there are, how the typical point sits, how the mass is distributed - is invisible to this index. That single-mindedness is both its appeal and its danger, and the worked examples below show the ratio responding to the extremes alone.

  • Numerator: the single smallest distance between any two clusters.
  • Denominator: the single largest diameter within any one cluster.
  • Larger is better, and a value above 1 means separation beats spread even in the worst case.

The ratio and its threshold at 1

The index is the plain ratio of the two extremes. In the first worked example the minimum intercluster distance of 3.8 divided by the maximum diameter of 2.6 gives 1.4615. The separation margin - the simple difference of the two inputs - is 1.20, and the compactness ratio, diameter over separation, is 0.6842.

The value 1 is the natural reading line. Above it, even the worst-separated pair of clusters is farther apart than the worst-spread cluster is wide, so no point's cluster assignment is embarrassed by the extremes. Below it, at least one cluster sprawls wider than at least one gap, and the partition has a weak point somewhere.

ExampleMin interMax intraDunn index
First3.82.61.4615
Second2.43.10.7742
Third5.61.92.9474

Worked examples

Example 1: Minimum intercluster distance 3.8; Maximum intracluster diameter 2.6. Dunn index = 1.4615. Supporting values: Separation margin (min inter - max intra) 1.20; Compactness ratio (max intra / min inter) 0.6842. Inputs: smallest distance between any two clusters 3.80, largest diameter within any single cluster 2.60. The Dunn index divides the worst separation by the worst spread: 3.80 / 2.60. Dunn index = 1.4615. Above 1, even the closest clusters are farther apart than the widest cluster is wide; below 1 the widest cluster spans more than the smallest gap. Larger is better, and the index is driven entirely by the two extreme cases.

Example 2: Minimum intercluster distance 2.4; Maximum intracluster diameter 3.1. Dunn index = 0.7742. Supporting values: Separation margin (min inter - max intra) -0.70; Compactness ratio (max intra / min inter) 1.2917. Inputs: smallest distance between any two clusters 2.40, largest diameter within any single cluster 3.10. The Dunn index divides the worst separation by the worst spread: 2.40 / 3.10. Dunn index = 0.7742. Above 1, even the closest clusters are farther apart than the widest cluster is wide; below 1 the widest cluster spans more than the smallest gap. Larger is better, and the index is driven entirely by the two extreme cases.

Example 3: Minimum intercluster distance 5.6; Maximum intracluster diameter 1.9. Dunn index = 2.9474. Supporting values: Separation margin (min inter - max intra) 3.70; Compactness ratio (max intra / min inter) 0.3393. Inputs: smallest distance between any two clusters 5.60, largest diameter within any single cluster 1.90. The Dunn index divides the worst separation by the worst spread: 5.60 / 1.90. Dunn index = 2.9474. Above 1, even the closest clusters are farther apart than the widest cluster is wide; below 1 the widest cluster spans more than the smallest gap. Larger is better, and the index is driven entirely by the two extreme cases.

When the worst case fails

The second worked example fails the test: a minimum separation of 2.4 against a maximum diameter of 3.1 gives 0.7742, with a negative separation margin of -0.70 and a compactness ratio of 1.2917. Somewhere in that clustering, one cluster is wider than the smallest gap between clusters - the classic signature of two groups that should perhaps be merged, or of one group that has swallowed an outlier and stretched.

The third example shows the opposite extreme: separation 5.6 against diameter 1.9 gives 2.9474 and a margin of 3.70. Clusters that tight and that far apart pass the Dunn test with room to spare, and most other validity indices will agree with the verdict.

One stray outlier can double a cluster's diameter and halve the Dunn index. Read a sudden drop as a prompt to hunt for the offending point before condemning the whole clustering.

Sensitivity: the price of pessimism

Because a single pair of points sets each input, the Dunn index is the most outlier-sensitive of the common validity measures. One distant point inflates its cluster's diameter; one bridge point between two clusters collapses the minimum separation. Average-based indices such as the silhouette barely notice either event.

Later variants soften this by replacing the nearest-point separation with centroid distances, or the diameter with an average intracluster distance, and those variants are stabler - but they also stop answering the worst-case question that makes the original useful. The practical approach is to report the Dunn index alongside an average-based index and treat disagreement between them as information: it localises the problem to the extremes.

Computing the two inputs

Both inputs come from the pairwise distance matrix of the clustered points. The maximum diameter is the largest distance between two points assigned to the same cluster, checked cluster by cluster. The minimum intercluster distance is the smallest distance between two points assigned to different clusters, which can be read from the same matrix by masking the within-cluster pairs.

The computation is quadratic in the number of points, so for very large datasets the extremes are usually estimated from samples or from cluster representatives. That is acceptable for screening, but the reported index should then be described as approximate - an estimated worst case is not the worst case.

The Dunn index also has a constructive use beyond scoring finished clusterings: it names the exact pair of points responsible for the verdict. The minimum separation is achieved by a specific pair of points in different clusters, and the maximum diameter by a specific pair inside one cluster, and inspecting those four points is often the fastest diagnostic in cluster analysis. If the diameter pair includes an obvious outlier, the remedy is data cleaning; if the separation pair are genuine border cases, the remedy is merging or accepting the overlap - two very different responses that the bare ratio of 0.7742 cannot distinguish but the responsible points can.

For large datasets the exact extremes are expensive, and a common compromise computes the index on a sample or on cluster representatives. That changes the estimand: sampled extremes are optimistic, because the true worst pair is probably not in the sample, so a sampled Dunn index should be reported as an upper bound on the real one. The third example's 2.9474, if it came from a sample, would promise only that the true index is no better - a subtlety that matters when the index is used to certify a clustering rather than merely to rank candidates.

It is also worth distinguishing the Dunn index's pessimism from mere conservatism in reporting. A silhouette average can be dragged down by many mediocre points; the Dunn index can be destroyed by exactly two, and that fragility is information about a different failure mode - the existence of a single bad neighbourhood in an otherwise sound partition. Remedies differ accordingly: broad mediocrity calls for a different algorithm or feature set, while a single bad neighbourhood calls for a look at the four responsible points. The index's refusal to average is what keeps those two situations distinguishable.

FAQs

What Dunn index does the first example give?

The first example gives a Dunn index of 1.4615: the minimum intercluster distance of 3.8 divided by the maximum intracluster diameter of 2.6. Above 1, even the closest clusters are farther apart than the widest cluster is wide.

What separation margin does the first example have?

The first example has a separation margin of 1.20, the plain difference 3.80 - 2.60 between the closest approach of two clusters and the widest spread inside one cluster.

What compactness ratio does the first example have?

The first example has a compactness ratio of 0.6842, which is the maximum diameter over the minimum separation, 2.60 / 3.80 - the Dunn index's denominator-to-numerator view of the same two extremes.

What Dunn index does the overlapping second example give?

The overlapping second example gives a Dunn index of 0.7742. Its widest cluster, at 3.1 across, spans more than the smallest gap of 2.4 between clusters, so the worst case fails and the partition has a weak flank.

What Dunn index does the well-separated third example give?

The well-separated third example gives a Dunn index of 2.9474: a minimum separation of 5.6 against a maximum diameter of only 1.9. Clusters that compact and that far apart pass the worst-case test easily.

What separation margin does the second example have?

The second example has a separation margin of -0.70, from 2.40 - 3.10. The negative sign records that the widest cluster exceeds the smallest intercluster gap - exactly the configuration the Dunn index exists to flag.

Sources

Related calculators

Silhouette Coefficient Calculator
The silhouette coefficient of a point or cluster from its mean intra-cluster distance and its mean distance to the nearest other cluster.
Calinski-Harabasz Index Calculator
The Calinski-Harabasz variance-ratio criterion for clustering quality from between- and within-cluster dispersion, cluster count and sample size.
Jaccard Similarity Calculator
The Jaccard index of two sets: the size of the overlap divided by the size of the union, with the matching Jaccard distance.