# Silhouette score

> Source: https://aiwiki.ai/wiki/silhouette_score
> Updated: 2026-12-02
> Fact-checked: 2026-11-18
> Categories: Machine Learning, Model Evaluation, Statistics
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) - attribute to "AI Wiki (aiwiki.ai)"
> Cite as: AI Wiki. "Silhouette score." aiwiki.ai, 2 Dec 2026. https://aiwiki.ai/wiki/silhouette_score
> From AI Wiki (https://aiwiki.ai), the free encyclopedia of artificial intelligence. Reuse freely with attribution.

The **silhouette score** (also called the silhouette coefficient, or the average silhouette width) is an internal measure of [clustering](https://aiwiki.ai/wiki/clustering) quality that compares, for each data point, how close the point is to the other members of its own cluster with how close it is to the nearest other cluster. Each point receives a silhouette value between -1 and 1, and the mean over all points summarizes a whole partition in a single number. Peter J. Rousseeuw introduced silhouettes in 1987 as a graphical display for partitioning methods, proposing the average silhouette width as an evaluation of clustering validity and as a way to choose an appropriate number of clusters [1]. Because it needs only the cluster labels and the pairwise dissimilarities, and no ground-truth classes, the silhouette is widely used to compare clusterings and to pick $$k$$ for algorithms such as [k-means](https://aiwiki.ai/wiki/k-means) and k-medoids [2][3][8].

## Definition

Let a dataset be divided into $$k$$ clusters and let $$d(i, j)$$ be the dissimilarity (often a distance) between objects $$i$$ and $$j$$. For an object $$i$$ assigned to cluster $$A$$, the quantities below follow the notation of Struyf, Hubert and Rousseeuw (1997) [2]:

- $$a(i)$$ is the average dissimilarity of $$i$$ to all other objects of $$A$$:

$$
a(i) = \frac{1}{|A| - 1} \sum_{j \in A,\, j \neq i} d(i, j)
$$

- For every other cluster $$C \neq A$$, $$d(i, C)$$ is the average dissimilarity of $$i$$ to all objects of $$C$$, and $$b(i)$$ is the smallest of these:

$$
b(i) = \min_{C \neq A} \frac{1}{|C|} \sum_{j \in C} d(i, j)
$$

The cluster $$B$$ that attains this minimum is called the neighbor of $$i$$, its second-best cluster [2]. The silhouette value of $$i$$ is then

$$
s(i) = \frac{b(i) - a(i)}{\max\{a(i), b(i)\}}
$$

which always lies between -1 and 1 [2]. The overall score is the mean of $$s(i)$$ over all $$n$$ objects, called the average silhouette width (ASW) [2][9]:

$$
\bar{s} = \frac{1}{n} \sum_{i=1}^{n} s(i)
$$

The silhouette is only defined when the number of clusters $$k$$ satisfies $$2 \le k \le n - 1$$ [3][6]. If an object is the only member of its cluster, $$a(i)$$ cannot be computed; the R `cluster` package and Batool and Hennig set $$s(i) = 0$$ in that case [6][8], and scikit-learn's implementation also returns 0 for points in clusters of size one [17]. MATLAB's `silhouette` function instead sets the value of such a point to 1 [7], so averages that include singleton clusters can differ between software packages.

### Interpretation of individual values

| Value of $$s(i)$$ | Meaning |
|---|---|
| Close to 1 | Object $$i$$ is well classified: it is much closer to its own cluster than to the neighbor cluster |
| Close to 0 | Object $$i$$ lies between two clusters ($$a(i) \approx b(i)$$) |
| Close to -1 | Object $$i$$ is badly classified: it is closer to the neighbor cluster than to its own |

These readings follow Struyf, Hubert and Rousseeuw [2]; scikit-learn's documentation states the same range, adds that values near 0 indicate overlapping clusters, and says negative values generally indicate that a sample has been assigned to the wrong cluster [3]. A negative value is possible only when $$b(i) < a(i)$$, that is, when some other cluster is on average closer to the point than its own cluster [9].

### Worked example

Take five points on a line, $$\{1, 2, 3\}$$ in cluster A and $$\{8, 9\}$$ in cluster B, with absolute difference as the distance. For the point 3, the average distance to the other members of A is $$a = (2 + 1)/2 = 1.5$$ and the average distance to B is $$b = (5 + 6)/2 = 5.5$$, so $$s = (5.5 - 1.5)/5.5 \approx 0.73$$. Repeating the calculation for the other four points gives values of 0.80, 0.85, 0.83 and 0.86, and the average silhouette width of the partition is about 0.81. The point 3, which sits nearest to the other cluster, has the lowest value.

<figure class="embedvideo">
<iframe src="https://www.youtube-nocookie.com/embed/a2Kg2_l3L8M" title="Silhouette Score, Inliers, and Outliers"></iframe>
<figcaption>"Silhouette Score, Inliers, and Outliers", video from Orange Data Mining, published August 21, 2023. <a href="https://www.youtube.com/watch?v=a2Kg2_l3L8M">Watch on YouTube</a>.</figcaption>
</figure>

## History

Rousseeuw's paper "Silhouettes: A graphical aid to the interpretation and validation of cluster analysis" appeared in the *Journal of Computational and Applied Mathematics* in 1987 [1]. Its abstract describes a display in which each cluster is represented by a silhouette based on a comparison of its tightness and separation, showing which objects lie well inside their cluster and which lie somewhere between clusters; the silhouettes of all clusters are combined into one plot that allows the relative quality of the clusters to be compared [1]. According to Batool and Hennig, the original paper also mentions, in a side remark, the possibility of optimizing the measure to find a clustering [8]. As of November 2026, Crossref lists more than 19,000 works citing the paper [16].

The silhouette was designed together with Partitioning Around Medoids (PAM), the k-medoids method of Kaufman and Rousseeuw [9]. It was built into the clustering programs described in their 1990 book *Finding Groups in Data*, which were originally stand-alone Fortran programs and were later ported to S-PLUS by Struyf, Hubert and Rousseeuw [2]. Those functions survive in the R `cluster` package, which CRAN describes as much extended from the original by Rousseeuw, Struyf and Hubert and based on Kaufman and Rousseeuw (1990) [19]; its `silhouette()` function computes the per-object widths for any partition and cites Rousseeuw (1987) and chapter 2 of Kaufman and Rousseeuw (1990) [6].

## Silhouette plots

<figure>
<a href="/images/silhouette-score-18dae2c5425e.png"><img src="/images/silhouette-score-18dae2c5425e.png" alt="Silhouette bands for four groups appear to the left of a scatterplot colored by cluster." width="1800" height="700" /></a>
<figcaption>Silhouette values for a four-cluster k-means fit appear beside the corresponding synthetic data. The dashed line marks the mean across samples. <a href="https://scikit-learn.org/1.9/auto_examples/cluster/plot_kmeans_silhouette_analysis.html">The scikit-learn developers</a>. <a href="https://github.com/scikit-learn/scikit-learn/blob/1.9.1/COPYING">BSD 3-Clause License</a>. © 2007-2026 The scikit-learn developers.</figcaption>
</figure>



The silhouette of a single cluster is a plot of all its $$s(i)$$ values ranked in decreasing order, and the full silhouette plot stacks the silhouettes of all clusters so their quality can be compared: a wide silhouette is better than a narrow one [2]. In the example given by Struyf, Hubert and Rousseeuw, a two-cluster PAM partition of 12 European countries (described by gross national product per capita and the percentage of the population employed in agriculture) had an average silhouette width of 0.63; the medoids Portugal and Germany had high values, while Spain, a boundary case, had a low one [2].

The thickness of each band also shows cluster size. In a scikit-learn example on synthetic data, the plot for a two-cluster solution shows one much thicker band because three underlying sub-clusters were merged into it, while a four-cluster solution produces bands of similar thickness [5]. Lenssen and Schubert note that visually inspecting the silhouette plot is feasible only for small datasets, which is one reason the values are usually aggregated into the single ASW statistic [9].

## Choosing the number of clusters

The most common use of the silhouette is to choose the number of clusters. Struyf, Hubert and Rousseeuw proposed running PAM several times with different values of $$k$$ and selecting the $$k$$ that gives the highest average silhouette width; that maximum over $$k$$ is what they called the silhouette coefficient (SC) [2]. They gave a subjective interpretation of SC, based on experience, which they said does not depend on the number of objects [2]:

| Silhouette coefficient | Proposed interpretation [2] |
|---|---|
| 0.71 to 1.00 | A strong structure has been found |
| 0.51 to 0.70 | A reasonable structure has been found |
| 0.26 to 0.50 | The structure is weak and could be artificial; try additional methods |
| 0.25 or less | No substantial structure has been found |

On the 75-point Ruspini dataset, for instance, PAM with four clusters found the four natural groups and gave an average silhouette width of 0.74, compared with 0.63 for three clusters and 0.71 for five, so the four-cluster partition was preferred [2].

The highest average is not always the whole story. scikit-learn's k-means silhouette example reports these averages on synthetic data [5]:

| Number of clusters | Average silhouette score [5] |
|---|---|
| 2 | 0.705 |
| 3 | 0.588 |
| 4 | 0.651 |
| 5 | 0.561 |
| 6 | 0.486 |

Although two clusters score highest, the example's text calls 3, 5 and 6 bad choices because they produce clusters with below-average silhouette values and widely varying silhouette sizes, and describes the analysis as ambivalent between 2 and 4 [5]. Batool and Hennig found the same tendency more generally: used to estimate $$k$$, the ASW can be tempted to choose too low a $$k$$ if that allows very large distances between neighboring clusters, hiding structure that is still meaningful. They advise also considering local optima of the ASW over $$k$$ when the global optimum is at $$k = 2$$ or another very low value [8].

## Properties

- **Distance-based.** The measure depends only on the cluster labels and the dissimilarities, so it works with any dissimilarity, including non-Euclidean ones, and is not tied to a particular clustering algorithm [2][8]. In Kaufman and Rousseeuw's book it was suggested for finding the number of clusters with PAM, but Batool and Hennig note that its definition is not directly connected to any specific partitioning method [8].
- **Bounded and scale-free.** Values lie in $$[-1, 1]$$ [2]. Batool and Hennig showed that the ASW satisfies the axioms for clustering quality measures proposed by Ackerman and Ben-David, one of which is scale invariance [8][9].
- **Empirical performance.** Batool and Hennig report that the ASW achieved overall very good results in the comparison of 30 cluster validity indices by Arbelaitz and colleagues [8][11], and Lenssen and Schubert describe it as performing very well in empirical studies [9].

## Limitations

- **Bias toward convex clusters.** scikit-learn's documentation states that the silhouette coefficient is generally higher for convex clusters than for other kinds of clusters, such as the density-based clusters produced by [DBSCAN](https://aiwiki.ai/wiki/dbscan) [4]. The same caveat appears for the Calinski-Harabasz and Davies-Bouldin indices [4].
- **Preference for few, well-separated clusters.** As noted above, the ASW can favor a low $$k$$ when merging groups makes the remaining clusters far apart [8].
- **Quadratic cost.** Exact computation needs all pairwise dissimilarities, which takes $$O(N^2)$$ time, far more than popular clustering algorithms such as k-means [9]. Sarpe and colleagues put the cost at $$\Theta(n^2)$$ distance calculations under general metrics [14].
- **Cluster imbalance.** Pavlopoulos, Vardakas and Likas argue that the usual average over all points (micro-averaging) is sensitive to cluster imbalance and can mislead when clusters differ greatly in size [15].
- **Unknown attainable maximum.** Sträng and Dinh point out that the dataset-specific maximum of the ASW is usually unknown and that the nominal upper limit of 1 is rarely attainable [18].

## Variants

### Simplified and medoid silhouette

For center-based methods such as k-means and k-medoids, the average distances can be replaced by the distance to the cluster center or medoid. This "simplified silhouette", which Van der Laan, Pollard and Bryan called the medoid-based silhouette, can be computed in $$O(Nk)$$ time [9]. When every point is assigned to its closest center, the value reduces further to the medoid silhouette,

$$
\tilde{s}(i) = 1 - \frac{d_1(i)}{d_2(i)}
$$

where $$d_1(i)$$ and $$d_2(i)$$ are the distances from point $$i$$ to its closest and second-closest center, and the average medoid silhouette (AMS) is the mean of these values [9]. Lenssen and Schubert proved that the AMS satisfies adapted versions of the clustering-quality axioms [9].

### Clustering by optimizing the silhouette

Instead of only scoring clusterings, the silhouette can serve as the objective of a clustering algorithm. Van der Laan, Pollard and Bryan modified PAM's swap step to maximize the ASW directly (PAMSIL), and also proposed a variant that maximizes the medoid silhouette (PAMMEDSIL) [9]. Because PAMSIL recomputes the full silhouette for every candidate swap, each iteration costs $$O(k(N-k)N^2)$$ [9]. Batool and Hennig proposed the OSil algorithm and a faster version based on subsetting, FOSil, for optimum-ASW clustering; in their simulations OSil was the strongest method for data containing clearly separated clusters with differing spreads and sizes [8]. Lenssen and Schubert combined PAMMEDSIL with the FasterPAM improvements to PAM, reporting a 10,464-fold speedup over the original PAMMEDSIL on real data with 30,000 samples and $$k = 100$$ [9]; a 2024 journal version adds a variant that chooses the number of clusters directly [10].

### Macro-averaged silhouette

Rather than averaging the point values directly, one can average them within each cluster first and then average the cluster means. Pavlopoulos, Vardakas and Likas call this macro-averaging and report it to be far more robust to cluster imbalance than the usual micro-average. They also found that uniform subsampling, the only sampling option in the libraries they examined, undermines that robustness, and proposed sampling per cluster instead [15]. Sträng and Dinh extended their ASW upper bound to the macro-averaged silhouette [18].

### Scalable approximations

Several methods address the quadratic cost. Gaido described an algorithm that computes the silhouette with linear complexity in the dataset size for two distance measures, squared Euclidean and cosine, and contributed it to the Apache Spark ML library; the approach does not extend to ordinary Euclidean distance, because the square root prevents the cluster-level statistics from being aggregated [12]. Spark's `ClusteringEvaluator`, added in version 2.3.0, computes the silhouette using squared Euclidean distance by default, with cosine distance as the alternative [13]. Sarpe, Altieri, Pietracaprina, Pucci and Vandin proposed sampling-based estimators with provable error guarantees, using $$O(nk\varepsilon^{-2}\ln(nk/\delta))$$ distance computations to estimate both individual and global silhouettes within additive error $$O(\varepsilon)$$ with probability at least $$1 - \delta$$, together with MapReduce and massively parallel designs [14].

## Software implementations

| Software | Function | Notes |
|---|---|---|
| [scikit-learn](https://aiwiki.ai/wiki/scikit_learn) ([Python](https://aiwiki.ai/wiki/python)) | `silhouette_score`, `silhouette_samples` | Mean and per-sample values; Euclidean distance by default, any `pairwise_distances` metric or a precomputed matrix; optional `sample_size` to score a random subset [3] |
| R `cluster` package | `silhouette()` | Per-object widths, neighbor cluster and summaries for any partition; hierarchical clusterings via `cutree()` [6] |
| MATLAB | `silhouette` | Silhouette plot and values; squared Euclidean distance by default; singleton points set to 1 [7] |
| Apache Spark ML | `ClusteringEvaluator` | Squared Euclidean (default) or cosine distance, linear-time algorithm [12][13] |

As of November 2026, scikit-learn's documentation (version 1.9.1) describes `silhouette_score` as returning the mean silhouette coefficient over all samples, with 1 as the best value and -1 as the worst [3]. Its user guide groups the silhouette coefficient with the Calinski-Harabasz and Davies-Bouldin indices as measures for use when the ground-truth labels are not known, so that evaluation must be performed using the model itself [4].

## See also

- [Clustering](https://aiwiki.ai/wiki/clustering)
- [K-means](https://aiwiki.ai/wiki/k-means)
- [K-median](https://aiwiki.ai/wiki/k-median)
- [Centroid](https://aiwiki.ai/wiki/centroid)
- [Hierarchical clustering](https://aiwiki.ai/wiki/hierarchical_clustering)
- [DBSCAN](https://aiwiki.ai/wiki/dbscan)
- [Unsupervised learning](https://aiwiki.ai/wiki/unsupervised_learning)
- [Model evaluation](https://aiwiki.ai/wiki/model_evaluation)

## References

1. Rousseeuw, Peter J. "Silhouettes: A graphical aid to the interpretation and validation of cluster analysis". Journal of Computational and Applied Mathematics, vol. 20, pp. 53-65, November 1987. https://doi.org/10.1016/0377-0427(87)90125-7
2. Struyf, Anja; Hubert, Mia; Rousseeuw, Peter J. "Clustering in an Object-Oriented Environment". Journal of Statistical Software, vol. 1, no. 4, 1997. https://doi.org/10.18637/jss.v001.i04
3. scikit-learn developers. "silhouette_score". scikit-learn 1.9.1 documentation, accessed November 2026. https://scikit-learn.org/stable/modules/generated/sklearn.metrics.silhouette_score.html
4. scikit-learn developers. "Clustering: Clustering performance evaluation (Silhouette Coefficient)". scikit-learn User Guide, accessed November 2026. https://scikit-learn.org/stable/modules/clustering.html
5. scikit-learn developers. "Selecting the number of clusters with silhouette analysis on KMeans clustering". scikit-learn examples, accessed November 2026. https://scikit-learn.org/stable/auto_examples/cluster/plot_kmeans_silhouette_analysis.html
6. R package cluster. "Compute or Extract Silhouette Information from Clustering". R documentation, accessed November 2026. https://stat.ethz.ch/R-manual/R-devel/library/cluster/html/silhouette.html
7. MathWorks. "silhouette". Statistics and Machine Learning Toolbox documentation, accessed November 2026. https://www.mathworks.com/help/stats/silhouette.html
8. Batool, Fatima; Hennig, Christian. "Clustering with the Average Silhouette Width". Computational Statistics & Data Analysis, vol. 158, 107190, 2021 (preprint arXiv:1910.11339). https://arxiv.org/abs/1910.11339
9. Lenssen, Lars; Schubert, Erich. "Clustering by Direct Optimization of the Medoid Silhouette". Similarity Search and Applications (SISAP 2022), Lecture Notes in Computer Science, pp. 190-204, 2022 (preprint arXiv:2209.12553). https://arxiv.org/abs/2209.12553
10. Lenssen, Lars; Schubert, Erich. "Medoid Silhouette clustering with automatic cluster number selection". Information Systems, vol. 120, 102290, 2024 (preprint arXiv:2309.03751). https://arxiv.org/abs/2309.03751
11. Arbelaitz, O.; Gurrutxaga, I.; Muguerza, J.; Pérez, J. M.; Perona, I. "An extensive comparative study of cluster validity indices". Pattern Recognition, vol. 46, no. 1, pp. 243-256, January 2013. https://doi.org/10.1016/j.patcog.2012.07.021
12. Gaido, Marco. "Distributed Silhouette Algorithm: Evaluating Clustering on Big Data". arXiv:2303.14102, March 2023. https://arxiv.org/abs/2303.14102
13. Apache Spark. "ClusteringEvaluator". PySpark 4.3.0 documentation, accessed November 2026. https://spark.apache.org/docs/latest/api/python/reference/api/pyspark.ml.evaluation.ClusteringEvaluator.html
14. Sarpe, Ilie; Altieri, Federico; Pietracaprina, Andrea; Pucci, Geppino; Vandin, Fabio. "Scalable and Distributed Silhouette Approximation". arXiv:2607.01993, July 2026. https://arxiv.org/abs/2607.01993
15. Pavlopoulos, John; Vardakas, Georgios; Likas, Aristidis. "Revisiting Silhouette Aggregation". arXiv:2401.05831, January 2024. https://arxiv.org/abs/2401.05831
16. Crossref. "Silhouettes: A graphical aid to the interpretation and validation of cluster analysis" (metadata record, is-referenced-by count). Crossref REST API, accessed November 2026. https://api.crossref.org/works/10.1016/0377-0427(87)90125-7
17. scikit-learn developers. "sklearn/metrics/cluster/_unsupervised.py" (silhouette_samples source). scikit-learn 1.9.1, GitHub. https://github.com/scikit-learn/scikit-learn/blob/1.9.1/sklearn/metrics/cluster/_unsupervised.py
18. Sträng, Hugo; Dinh, Tai. "An upper bound on the silhouette evaluation metric for clustering". Pattern Recognition, vol. 178, 113402, 2026 (preprint arXiv:2509.08625). https://arxiv.org/abs/2509.08625
19. Maechler, Martin; Rousseeuw, Peter; Struyf, Anja; Hubert, Mia; Hornik, Kurt; et al. "cluster: 'Finding Groups in Data': Cluster Analysis Extended Rousseeuw et al." R package version 2.1.8.3, CRAN, published 2026-07-30. https://cran.r-project.org/package=cluster

