# Silhouette (clustering)

Silhouette refers to a method of interpretation and validation of consistency within clusters of data. The technique provides a succinct graphical representation of how well each object has been classified.[1]

The silhouette value is a measure of how similar an object is to its own cluster (cohesion) compared to other clusters (separation). The silhouette ranges from −1 to +1, where a high value indicates that the object is well matched to its own cluster and poorly matched to neighboring clusters. If most objects have a high value, then the clustering configuration is appropriate. If many points have a low or negative value, then the clustering configuration may have too many or too few clusters.

The silhouette can be calculated with any distance metric, such as the Euclidean distance or the Manhattan distance.

## Definition

A plot showing silhouette scores from three types of animals from the Zoo dataset as rendered by Orange data mining suite. At the bottom of the plot, silhouette identifies dolphin and porpoise as outliers in the group of mammals.

Assume the data have been clustered via any technique, such as k-means, into ${\displaystyle k}$  clusters.

For each data point ${\displaystyle i\in C_{i}}$  (data point ${\displaystyle i}$  in the cluster ${\displaystyle C_{i}}$ ), let

${\displaystyle a(i)={\frac {1}{|C_{i}|-1}}\sum _{j\in C_{i},i\neq j}d(i,j)}$

be the average distance between ${\displaystyle i}$  and all other data points in the same cluster, where ${\displaystyle d(i,j)}$  is the distance between data points ${\displaystyle i}$  and ${\displaystyle j}$  in the cluster ${\displaystyle C_{i}}$  (we divide by ${\displaystyle |C_{i}|-1}$  because we do not include the distance ${\displaystyle d(i,i)}$  in the sum). We can interpret ${\displaystyle a(i)}$  as a measure of how well ${\displaystyle i}$  is assigned to its cluster (the smaller the value, the better the assignment).

We then define the average dissimilarity of point ${\displaystyle i}$  to a cluster ${\displaystyle c}$  as the average of the distance from ${\displaystyle i}$  to all points in ${\displaystyle c}$ .

For each data point ${\displaystyle i\in C_{i}}$ , we now define

${\displaystyle b(i)=\min _{i\neq j}{\frac {1}{|C_{j}|}}\sum _{j\in C_{j}}d(i,j)}$

to be the smallest (hence the ${\displaystyle \min }$  operator in the formula) average distance of ${\displaystyle i}$  to all points in any other cluster, of which ${\displaystyle i}$  is not a member. The cluster with this smallest average dissimilarity is said to be the "neighbouring cluster" of ${\displaystyle i}$  because it is the next best fit cluster for point ${\displaystyle i}$ .

We now define a silhouette (value) of one data point ${\displaystyle i}$

${\displaystyle s(i)={\frac {b(i)-a(i)}{\max\{a(i),b(i)\}}}}$ , if ${\displaystyle |C_{i}|>1}$

and

${\displaystyle s(i)=0}$ , if ${\displaystyle |C_{i}|=1}$

Which can be also written as:

${\displaystyle s(i)={\begin{cases}1-a(i)/b(i),&{\mbox{if }}a(i)b(i)\\\end{cases}}}$

From the above definition it is clear that

${\displaystyle -1\leq s(i)\leq 1}$

Also, note that score is 0 for clusters with size = 1. This constraint is added to prevent the number of clusters from increasing significantly.

For ${\displaystyle s(i)}$  to be close to 1 we require ${\displaystyle a(i)\ll b(i)}$ . As ${\displaystyle a(i)}$  is a measure of how dissimilar ${\displaystyle i}$  is to its own cluster, a small value means it is well matched. Furthermore, a large ${\displaystyle b(i)}$  implies that ${\displaystyle i}$  is badly matched to its neighbouring cluster. Thus an ${\displaystyle s(i)}$  close to one means that the data is appropriately clustered. If ${\displaystyle s(i)}$  is close to negative one, then by the same logic we see that ${\displaystyle i}$  would be more appropriate if it was clustered in its neighbouring cluster. An ${\displaystyle s(i)}$  near zero means that the datum is on the border of two natural clusters.

The average ${\displaystyle s(i)}$  over all points of a cluster is a measure of how tightly grouped all the points in the cluster are. Thus the average ${\displaystyle s(i)}$  over all data of the entire dataset is a measure of how appropriately the data have been clustered. If there are too many or too few clusters, as may occur when a poor choice of ${\displaystyle k}$  is used in the clustering algorithm (e.g.: k-means), some of the clusters will typically display much narrower silhouettes than the rest. Thus silhouette plots and averages may be used to determine the natural number of clusters within a dataset. One can also increase the likelihood of the silhouette being maximized at the correct number of clusters by re-scaling the data using feature weights that are cluster specific.[2]

## References

1. ^ Peter J. Rousseeuw (1987). "Silhouettes: a Graphical Aid to the Interpretation and Validation of Cluster Analysis". Computational and Applied Mathematics. 20: 53–65. doi:10.1016/0377-0427(87)90125-7.
2. ^ R.C. de Amorim, C. Hennig (2015). "Recovering the number of clusters in data sets with noise features using feature rescaling factors". Information Sciences. 324: 126–145. arXiv:1602.06989. doi:10.1016/j.ins.2015.06.039.