The Challenge of Evaluating Without Labels
In supervised learning, evaluation is straightforward: compare predicted labels to ground truth and compute accuracy, precision, recall, or F1. In unsupervised learning, there is no ground truth. The algorithm itself decides the groupings, which creates a fundamental tension:
- No external benchmark — You cannot compute “accuracy” because there are no known correct assignments. A K-Means run with K=3 and another with K=5 both produce valid partitions; how do you decide which is better?
- Algorithm bias — Every clustering algorithm has built-in assumptions about cluster shape and density. K-Means favours spherical clusters; DBSCAN favours density-connected regions. An evaluation metric that matches the algorithm's assumption will always look good, even on random data.
- Dimensionality fog — Real-world civil engineering datasets — soil test results, sensor streams, damage logs — often live in high-dimensional spaces where human visual inspection is impossible without dimensionality reduction, which itself distorts distances.
- Domain context matters — A statistically optimal partition may be operationally useless. Five soil clusters might be mathematically tighter than three, but the project's geotechnical report only needs three actionable categories.
The solution is a combination of internal validation metrics (computed from the data alone) and domain-informed visual inspection. No single number can tell you everything; the metrics illuminate different facets of cluster quality, and the final judgement always requires engineering expertise.
Think of unsupervised model evaluation like quality control on a concrete mix without a lab-certified reference sample. You cannot compare your cylinder break results to a “correct” strength because there is no external standard — only internal consistency checks. Are the cylinders from the same batch giving similar readings? Do the values form a tight group, or are they scattered all over? Internal validation metrics are those consistency checks for cluster quality.
Internal vs. External Evaluation
Evaluation metrics for clustering fall into two broad categories. This sub-chapter focuses on internal metrics because in most real-world CE applications labels simply do not exist.
| Aspect | Internal Metrics | External Metrics |
|---|---|---|
| Labels required? | No | Yes (ground truth) |
| What they measure | Cohesion & separation within the data | Agreement with known classes |
| Examples | Silhouette, DB, CH, Elbow/SSE | ARI, NMI, V-measure |
| CE availability | Always available | Rarely — need lab-classified samples |
| Limitation | Biased toward algorithm assumptions | Ground truth may be subjective |
The Elbow Method (Within-Cluster SSE)
The simplest approach: run K-Means for K = 1, 2, 3, … and plot the total within-cluster sum of squared errors (SSE), also called inertia. As K increases, SSE always decreases (more clusters = tighter groups). The trick is finding the “elbow” — the value of K where adding another cluster yields diminishing returns in SSE reduction.
SSE = sum over all clusters C_k of sum over x_i in C_k of ||x_i - mu_k||^2
How to read the plot: The curve drops sharply at first (each new cluster captures a genuine group). At some K, the curve bends and flattens — further splits are slicing real groups in half rather than capturing new ones. That bend is the elbow.
CE Example: Soil Classification
A geotechnical investigation collects 200 borehole samples with measurements for grain size distribution, Atterberg limits, moisture content, and SPT blow count. The engineer runs K-Means for K = 2 through 8 and plots SSE. The elbow appears at K = 4, suggesting four distinct soil strata beneath the site — consistent with the geological cross-section showing topsoil, clay, sandy gravel, and weathered rock.
Limitations of the Elbow Method
- Ambiguous elbows — In many real datasets, the curve is a smooth decay with no sharp bend. The “elbow” becomes a matter of opinion.
- SSE is scale-dependent — Features with larger numeric ranges dominate the metric. Always standardise data before clustering.
- Only measures compactness — SSE does not consider how well-separated clusters are from each other. Two overlapping clusters may have lower SSE than two well-separated ones simply because they are each very tight.
Silhouette Score
The silhouette score (Rousseeuw, 1987) measures how similar each data point is to its own cluster compared to other clusters. For each sample i:
a(i) = average distance from i to all other points in the same cluster
b(i) = minimum average distance from i to points in any other cluster
s(i) = (b(i) - a(i)) / max(a(i), b(i))
- s(i) close to +1 — The point is well-matched to its own cluster and poorly matched to neighbouring clusters. Excellent assignment.
- s(i) close to 0 — The point sits on the boundary between two clusters. Its assignment is ambiguous.
- s(i) close to -1 — The point is probably assigned to the wrong cluster. It is closer to a neighbouring cluster than its own.
The overall silhouette score is the mean of s(i) across all samples. It ranges from -1 to +1; a higher value indicates better-defined clusters.
Interpreting Silhouette Scores
| Score Range | Interpretation |
|---|---|
| 0.71 – 1.00 | Strong structure. Clusters are well-separated and cohesive. |
| 0.51 – 0.70 | Reasonable structure. Some overlap but clusters are meaningful. |
| 0.26 – 0.50 | Weak structure. Clusters overlap significantly. |
| ≤ 0.25 | No substantial structure or wrong number of clusters. |
The Silhouette Plot
Beyond the single average score, a silhouette plot shows the silhouette coefficient for every sample, grouped and sorted by cluster. Each cluster forms a “knife shape” (or silhouette). Key things to look for:
- Width uniformity — Ideally, all knife shapes have similar width (similar cluster sizes). A very thin knife next to a very wide one suggests imbalanced clustering.
- Extent past the average line — Most samples should extend beyond the dashed average line. Samples falling short are poorly assigned.
- Negative values — Any bars extending to the left of zero indicate mis-clustered points. A good clustering has few or no negative silhouette values.
The silhouette score is like evaluating the zoning in an urban plan. Each building (data point) should feel like it belongs in its zone (residential, commercial, industrial). A high silhouette means the building is surrounded by similar neighbours within its zone and far from buildings in other zones. A negative silhouette is a factory placed in the middle of a residential neighbourhood — clearly misassigned.
Davies-Bouldin Index
The Davies-Bouldin (DB) index (1979) measures the average “similarity” between each cluster and its most similar neighbour, where similarity is defined as the ratio of within-cluster scatter to between-cluster distance.
For clusters C_i and C_j:
S_i = average distance of points in C_i to centroid of C_i
d_ij = distance between centroids of C_i and C_j
R_ij = (S_i + S_j) / d_ij
DB = (1/K) * sum over i of max_{j != i} R_ij
- Lower is better. A DB index of 0 means perfectly separated, infinitely compact clusters (theoretical ideal).
- No upper bound. Values typically range from 0.2 to 2.0+ in practice.
- Sensitive to cluster shape: The metric assumes convex, similarly-sized clusters. It may mislead with non-spherical clusters.
CE Application: Damage Pattern Grouping
A bridge management system clusters damage reports based on crack width, depth of spalling, area of delamination, and chloride penetration depth. The engineer runs K-Means for K = 2 through 8 and computes the DB index for each. The minimum DB (say 0.48 at K = 3) suggests three natural damage severity categories: cosmetic, moderate, and severe. This aligns with the agency's existing condition-rating tiers and confirms the clustering is capturing real structural distinctions.
Calinski-Harabasz Index (Variance Ratio Criterion)
The Calinski-Harabasz (CH) index (1974) is the ratio of between-cluster dispersion to within-cluster dispersion, adjusted for the number of clusters and samples.
CH = [B / (K - 1)] / [W / (N - K)]
Where:
B = between-cluster sum of squares (trace of between-group scatter)
W = within-cluster sum of squares (trace of within-group scatter)
K = number of clusters
N = total number of samples
- Higher is better. A high CH means clusters are dense internally and well-separated from each other.
- Fast to compute. It uses only cluster centroids and distances, making it efficient for large datasets.
- Biased toward convex clusters. Like DB, it favours spherical, similarly-sized groups — a natural fit for K-Means but potentially misleading for DBSCAN results.
CE Application: Soil Strata Identification
When clustering borehole logs into soil strata, the engineer plots CH for K = 2 through 8. A peak at K = 4 with CH = 312 (compared to 185 at K = 3 and 287 at K = 5) strongly suggests four distinct layers. The engineer cross-references this with the actual boring log profiles and confirms the four groups map to topsoil, stiff clay, sandy gravel, and bedrock.
Comparing the Four Metrics
| Metric | Direction | Measures | Weakness |
|---|---|---|---|
| Elbow (SSE) | Lower SSE + diminishing returns | Compactness only | Ambiguous bend; no separation info |
| Silhouette | Higher is better [-1, 1] | Cohesion & separation per point | Expensive on large datasets (O(n²)) |
| Davies-Bouldin | Lower is better [0, ∞) | Worst-case cluster similarity | Assumes convex, similarly-sized clusters |
| Calinski-Harabasz | Higher is better [0, ∞) | Variance ratio (between/within) | Favours spherical clusters; scale-sensitive |
Best practice: Use at least two metrics from different families. If the silhouette score peaks at K = 4 and the DB index reaches its minimum at K = 4, you have convergent evidence. If they disagree, investigate the discrepancy — it often reveals interesting data structure (e.g., overlapping clusters that one metric penalises more than another).
Visual Inspection Strategies
Numbers alone are not enough. Visual inspection complements quantitative metrics by revealing patterns that a single scalar cannot capture:
- Scatter plots with cluster colouring — For 2D or 3D data, colour-code points by cluster assignment and look for overlapping regions, outliers, or clusters that should have been merged.
- PCA / t-SNE / UMAP projections — For high-dimensional data, project to 2D and colour by cluster. If clusters look well-separated in the projection, they are likely well-separated in the original space (though the converse is not guaranteed).
- Silhouette plots — As described above, the per-sample silhouette plot reveals which clusters are strong and which are fragmented or mis-assigned.
- Centroid feature profiles — Plot a bar chart of each centroid's feature values. If two centroids have nearly identical profiles, they represent the same underlying group and should be merged.
- Pair plots / parallel coordinates — For moderate dimensionality (5–15 features), pair plots or parallel coordinate plots coloured by cluster quickly expose which features drive the separation.
Visual inspection of clustering results is analogous to a site walk-through after reading the structural analysis report. The report (metrics) says the building is safe, but the walk-through (visual inspection) reveals context that the numbers miss: a crack running along a construction joint, an unexpected load path through a non-structural wall, or drainage problems that the model did not consider. Both the numbers and the eyes are essential.
CE Application: Validating Soil Clustering Results
Geotechnical engineers routinely classify soils using the Unified Soil Classification System (USCS), but this relies on predefined rules and laboratory tests. When large volumes of in-situ data (CPT logs, SPT records, moisture content, resistivity) are available, clustering can reveal sub-groups that USCS misses. Evaluating these clusters is critical:
- Run K-Means for K = 2..8 on standardised features (grain size, plasticity, moisture, blow count).
- Plot the elbow curve to find the range of plausible K values.
- Compute silhouette and DB for each K in the plausible range to identify the optimal partition.
- Inspect the silhouette plot at the chosen K. If one cluster has many negative silhouettes, its samples may span two soil types that need separate treatment.
- Cross-validate with boring logs and geologic maps. The clusters should correspond to physically meaningful strata.
CE Application: Assessing Damage Pattern Grouping
Infrastructure asset managers use clustering to group bridge damage reports into severity tiers, maintenance categories, or deterioration patterns. Evaluation ensures the groups are actionable:
- Cluster features: crack width (mm), crack length (m), spall area (cm²), chloride concentration (%wt), half-cell potential (mV), cover depth (mm).
- Silhouette check: If the average silhouette is below 0.30, the damage types overlap too much for the chosen K. Consider reducing K or using a density-based algorithm.
- DB check: Compare DB indices across algorithms (K-Means vs. hierarchical). The algorithm with the lower DB for the same K produces more distinct groups.
- Operational validation: Map cluster labels back to actual repair actions. If two clusters always receive the same repair treatment, they should be merged. If one cluster triggers both “seal only” and “structural repair,” it should be split.
Interactive Demo 1: Silhouette Visualiser
This demo generates a synthetic 2D dataset with well-separated clusters, then runs K-Means for different K values. The canvas shows a coloured silhouette plot for each cluster with the overall silhouette score. Adjust K to see how over- or under-clustering degrades the silhouette profile.
Silhouette Plot Visualiser
Silhouette Plot
Cluster Scatter
CE Application: Validating Soil & Damage Clusters
A high silhouette score is necessary but not sufficient — clusters must also make engineering sense.
Soil Cluster Validation
Your k-means gave 4 clusters — but do they match USCS soil classes (CL, CH, ML, SM)? Cross-reference cluster centroids with known classification boundaries. Silhouette + domain check = trustworthy clusters.
Elbow Method in Practice
For site zoning, the elbow often suggests k=3-5. But a geotechnical engineer knows the site has 2 distinct formations — use domain knowledge to override the elbow when it makes sense.
A K-Means clustering of soil samples yields an average silhouette score of 0.68 for K = 4 and 0.41 for K = 6. What does this suggest?
An engineer computes the Davies-Bouldin index for K = 3 (DB = 1.42) and K = 4 (DB = 0.67). Which K does the DB index favour?
Interactive Demo 2: Multi-Metric Dashboard
This dashboard runs K-Means for K = 2 through 8 on a synthetic dataset and plots all four evaluation metrics side by side: Elbow (SSE), Silhouette, Davies-Bouldin, and Calinski-Harabasz. Look for convergent evidence — when multiple metrics agree on the best K, you can be confident in your cluster count.
Multi-Metric Comparison Dashboard
Elbow (SSE)
Silhouette Score
Davies-Bouldin Index
Calinski-Harabasz
Practical Evaluation Workflow
A step-by-step guide for evaluating unsupervised models in a civil engineering context:
- Standardise features: Before any clustering, z-score-standardise all features so that no single variable dominates the distance calculations. For soil data, this means putting grain size, moisture, and blow count on the same scale.
- Run the elbow method first: It is cheap and provides a coarse range for K. Do not trust it as the final answer — use it as a starting bracket.
- Compute silhouette, DB, and CH for every K in the bracket. Look for convergent evidence across metrics.
- Inspect silhouette plots for the top two or three candidate K values. Look for uniform knife shapes and few negative values.
- Project to 2D using PCA or UMAP and colour by cluster. Sanity-check that the groups look visually distinct.
- Cross-reference with domain knowledge: Map clusters back to physical meaning. Do they correspond to known soil types, damage severities, or operational categories?
- Document and iterate: Record the chosen K, all metric values, and the rationale for the decision. Re-evaluate when new data arrives.
Python Example: Full Evaluation Pipeline
import numpy as np
from sklearn.cluster import KMeans
from sklearn.metrics import (silhouette_score,
davies_bouldin_score,
calinski_harabasz_score)
from sklearn.preprocessing import StandardScaler
# Standardise soil sample features
scaler = StandardScaler()
X = scaler.fit_transform(soil_data)
results = []
for k in range(2, 9):
km = KMeans(n_clusters=k, n_init=10, random_state=42)
labels = km.fit_predict(X)
results.append({
'K': k,
'SSE': km.inertia_,
'Silhouette': silhouette_score(X, labels),
'Davies-Bouldin': davies_bouldin_score(X, labels),
'Calinski-Harabasz': calinski_harabasz_score(X, labels)
})
# Best K by each metric
best_sil = max(results, key=lambda r: r['Silhouette'])
best_db = min(results, key=lambda r: r['Davies-Bouldin'])
best_ch = max(results, key=lambda r: r['Calinski-Harabasz'])
print(f"Silhouette => K={best_sil['K']}")
print(f"Davies-Bouldin => K={best_db['K']}")
print(f"Calinski-Harabasz => K={best_ch['K']}")
Which is a key limitation of the elbow method for determining the optimal number of clusters?
An engineer evaluates K = 2..7 and finds: Silhouette peaks at K = 4, DB minimises at K = 4, CH peaks at K = 4, but the elbow suggests K = 3. What should the engineer do?
Pitfalls and Best Practices
- Do not rely on a single metric: Each metric has blind spots. The silhouette score may favour K = 4 while CH favours K = 5. Use convergent evidence from multiple metrics plus visual and domain checks.
- Beware of metric-algorithm alignment: Silhouette, DB, and CH all assume convex clusters. If you cluster with DBSCAN (which finds arbitrary shapes), these metrics may penalise correct results. Use density-based validity indices (DBCV) instead.
- Standardise before computing metrics: If features are on different scales, distance-based metrics will be dominated by high-range features.
- Metrics are necessary but not sufficient: A high silhouette score on meaningless features produces meaningless clusters. The features you choose to cluster on must be physically relevant.
- Repeat with different random seeds: K-Means is sensitive to initialisation. Compute metrics over 10+ runs with different seeds and report the mean and standard deviation.
- Consider stability: Beyond internal metrics, check whether clusters are stable under perturbation. Remove 10% of data, re-cluster, and see if the assignments remain consistent. Stable clusters are trustworthy.
Evaluating clusters with multiple metrics is like assessing structural safety with multiple checks: deflection limits, stress ratios, fatigue life, and vibration criteria. A structure that passes deflection checks but fails fatigue analysis is not safe. Similarly, a clustering that scores well on silhouette but poorly on DB may have hidden weaknesses. Only when multiple independent checks agree can you have confidence in the result.
Key Takeaways
- Unsupervised model evaluation is inherently harder than supervised evaluation because there is no ground truth. Internal metrics fill the gap by measuring cluster cohesion and separation from the data alone.
- The elbow method provides a quick visual estimate of K but is often ambiguous. Use it as a coarse starting bracket, not a final answer.
- The silhouette score [-1, +1] measures per-sample fit. Higher is better. The silhouette plot reveals cluster-level detail that the average score hides.
- The Davies-Bouldin index measures worst-case cluster similarity. Lower is better. It is fast but assumes convex clusters.
- The Calinski-Harabasz index measures variance ratio. Higher is better. It is efficient and favours well-separated, spherical clusters.
- In civil engineering, always cross-validate metrics with domain knowledge: do the clusters map to known soil types, damage severities, or operational categories? Numbers guide; expertise decides.
Switch to a labelled view of model performance
When you do have ground-truth labels, hop over to the metrics widget to inspect confusion matrices, ROC and PR curves at any threshold — the bridge between unsupervised exploration and supervised evaluation.