Dunn Index Calculator

The Dunn Index Calculator assesses clustering quality by comparing minimum distance between clusters to maximum diameter within clusters.

Dunn Index Calculator
Must be greater than 0. This is the smallest distance between any two clusters.
Must be greater than 0. This is the largest diameter across all clusters.
This calculator uses your δ and Δ inputs directly; metric is informational for reporting.
Dunn Index is unitless; δ and Δ should share the same units/scale.
Example Presets (fills inputs only)

Report an issue

Spotted a wrong result, broken field, or typo? Tell us below and we’ll fix it fast.


Dunn Index Calculator Explained

The Dunn index measures the ratio between the tightness of clusters and the distance between them. In simple terms, it rewards small cluster diameters and large gaps between clusters. A higher value signals better clustering quality: compact groups that are well separated.

This metric belongs to internal validation methods. It uses only your feature data and cluster labels, not external truth labels. It is useful when you lack ground truth or want to compare different settings like number of clusters, distance metric, or linkage strategy.

The Dunn index depends on how you define distances and diameters. Different choices—Euclidean vs. Manhattan distance, single-link vs. centroid distance—can change the score. You should align these choices with the structure of your data and the assumptions behind your model.

Dunn Index Calculator
Crunch the math for dunn index.

Equations Used by the Dunn Index Calculator

The Dunn index D is defined as the smallest separation between any two clusters divided by the largest diameter of any cluster. The exact value depends on your distance metric and diameter definition.

  • D = min inter-cluster distance / max intra-cluster diameter.
  • Inter-cluster distance: δ(Ci, Cj) = distance between clusters Ci and Cj. Common choices: minimum pairwise distance (single-link), distance between centroids, or average linkage.
  • Intra-cluster diameter: Δ(Ck) = maximum distance between any two points within cluster Ck; or sometimes average pairwise distance within Ck.
  • Pairwise point distance: d(x, y), often Euclidean or Manhattan. Your choice must match your data scale and assumptions.
  • Overall formula: D = min over i≠j of δ(Ci, Cj) divided by max over k of Δ(Ck). Larger values are better.

D is nonnegative. If clusters overlap heavily, D approaches 0. If clusters are far apart and tight, D grows. Because δ and Δ share the same units, D is unitless, which helps when comparing intervals of parameter values across experiments.

How to Use Dunn Index (Step by Step)

Apply the Dunn index to compare clustering results, detect poorly separated groups, and guide parameter tuning. The steps below outline a repeatable process that fits most datasets and workflows.

  • Select a distance metric that suits your features and scaling routine (for example, Euclidean on standardized data).
  • Choose how to measure cluster separation (single-link, centroid, or average linkage) and how to define diameter.
  • Compute pairwise distances within each cluster to obtain diameters.
  • Compute distances between all cluster pairs to obtain separations.
  • Take the minimum inter-cluster distance and divide by the maximum cluster diameter to get D.
  • Repeat for different runs or parameter sets (e.g., k values) and compare the index values.

Use the index to rank models and filter candidates. Then inspect edge cases where D is unexpectedly low or high, and verify that the assumptions behind your metric choices match the data distribution.

Inputs, Assumptions & Parameters

The calculator needs your data and labels plus a few settings for distance and diameter. These inputs determine how separation and compactness are measured and how the final score is scaled.

  • Data matrix: numeric features for each observation; standardized if features vary in scale.
  • Cluster labels: an integer or categorical label for each observation.
  • Distance metric: Euclidean, Manhattan, cosine, or custom; must align with your data structure.
  • Inter-cluster definition: minimum pairwise (single-link), centroid-to-centroid, or average linkage.
  • Diameter definition: maximum pairwise distance within a cluster or average pairwise distance.
  • Outlier handling: optional rules for trimming or winsorizing distances that distort diameters.

Typical ranges: D ≥ 0, often between 0 and 3 for many practical datasets. Watch edge cases: tiny clusters with two nearly identical points can produce very small diameters, inflating D. When comparing parameter intervals, ensure consistent distance and diameter choices, and confirm your assumptions about scale and distribution.

Using the Dunn Index Calculator: A Walkthrough

Here’s a concise overview before we dive into the key points:

  1. Load your dataset and cluster labels from your chosen algorithm.
  2. Select a distance metric and standardize features if needed.
  3. Pick inter-cluster and diameter definitions that reflect your clustering approach.
  4. Compute diameters for each cluster using your chosen intra-cluster rule.
  5. Compute inter-cluster distances for every pair of clusters.
  6. Identify the minimum inter-cluster distance and the maximum cluster diameter.

These points provide quick orientation—use them alongside the full explanations in this page.

Case Studies

A retailer segments customers into three clusters using k-means with standardized spending features. With Euclidean distance, the largest diameter among clusters is 1.6. The minimum centroid-to-centroid distance between any two clusters is 2.4. The Dunn index is D = 2.4 / 1.6 = 1.5. This indicates reasonably compact, well-separated groups for targeting. What this means: the segmentation is stable enough for campaign testing and resource allocation.

An IoT team clusters sensor events in 2D (temperature, vibration). Using single-link separation and maximum pairwise diameter, the largest cluster diameter is 5.0, while the smallest inter-cluster distance is 3.0, yielding D = 3.0 / 5.0 = 0.6. This low value flags overlapping groups, suggesting either more clusters or different features are needed. What this means: the team should revisit feature scaling and evaluate k+1 to improve separation.

Accuracy & Limitations

The Dunn index is simple and informative, but its accuracy depends on design choices and data properties. Consider the following before relying on a single score.

  • Sensitivity to definition: single-link separation can overemphasize narrow bridges; centroid distance may ignore boundary overlap.
  • Outliers inflate diameters and depress D; trimming or robust distances may help.
  • Scale matters: unscaled features can distort distances and mislead the result.
  • High-dimensional data can make distances less informative; consider dimensionality reduction.
  • Small clusters can produce very small diameters, artificially boosting D.

Always pair the Dunn index with visual checks and complementary indices, like Silhouette or Davies–Bouldin. Use consistent settings when comparing parameter intervals or algorithms so differences reflect clustering quality, not metric definitions.

Units and Symbols

Distances inherit the units of your features, while the index itself is unitless. Understanding units ensures you read separation and diameter correctly, especially when mixing features with different scales.

Symbols and units used in Dunn index calculations
Symbol Meaning Units
D Overall Dunn index value Unitless
d(x, y) Distance between two points x and y Same as feature units after scaling
δ(Ci, Cj) Distance between clusters Ci and Cj Same as d(x, y)
Δ(Ck) Diameter of cluster Ck Same as d(x, y)
k Count of clusters Count
n Count of data points Count

Read the table as a quick reference: d, δ, and Δ share the same distance unit, but D has no unit. If you standardize to z-scores, distances are dimensionless, and D remains unitless, simplifying comparisons across experiments.

Troubleshooting

Unexpectedly low or high values often trace back to scaling, outliers, or definition choices. Use the checks below to diagnose issues quickly.

  • If D is near zero, confirm feature scaling and inspect overlapping clusters on a scatterplot or projection.
  • If D is extremely high, check for tiny clusters or duplicate points that shrink diameters.
  • If results change drastically between runs, review the distance and diameter definitions for consistency.
  • If computation is slow, precompute distance matrices or sample large datasets.

After each fix, recompute and compare across the same parameter intervals. Document the assumptions you changed so you can reproduce or audit the result later.

FAQ about Dunn Index Calculator

What is a good Dunn index value?

Higher is better. Many datasets show D between 0 and 3; a value above 1 often indicates compact, separated clusters, given sensible metric choices.

Does the Dunn index require standardized features?

Standardization is recommended when features have different units or scales. Without it, distances can be dominated by a single feature.

Can I compare algorithms with different distance metrics?

You can, but be careful. Differences may reflect metric choice, not clustering quality. Prefer consistent metrics for fair comparisons.

How does Dunn differ from Silhouette?

Dunn focuses on the worst-case separation and diameter, while Silhouette averages point-level cohesion and separation. Using both gives a fuller view.

Dunn Index Terms & Definitions

Dunn index

An internal validation metric defined as the minimum inter-cluster distance divided by the maximum intra-cluster diameter; higher values indicate better clustering.

Cluster diameter

The measure of cluster compactness, often the maximum pairwise distance between points inside the cluster.

Inter-cluster distance

The separation between two clusters, defined by rules such as single-link, centroid-to-centroid, or average linkage.

Euclidean distance

The straight-line distance between points in feature space; commonly used for continuous, standardized features.

Manhattan distance

The sum of absolute coordinate differences; good for grid-like data or when L1 geometry matches domain assumptions.

Silhouette coefficient

An internal validation index that averages how similar points are to their own cluster versus other clusters, ranging from -1 to 1.

Outlier

A point far from the bulk of the data that can inflate cluster diameters and reduce Dunn index values.

Internal validation

A method evaluating clustering quality using only the dataset and labels, not external reference labels.

References

Here’s a concise overview before we dive into the key points:

These points provide quick orientation—use them alongside the full explanations in this page.

Save this calculator
Found this useful? Pin it on Pinterest so you can easily find it again or share it with your audience.

Leave a Comment