# Davies–Bouldin index

The Davies–Bouldin index (DBI), introduced by David L. Davies and Donald W. Bouldin in 1979, is a metric for evaluating clustering algorithms. This is an internal evaluation scheme, where the validation of how well the clustering has been done is made using quantities and features inherent to the dataset. This has a drawback that a good value reported by this method does not imply the best information retrieval.

## Preliminaries

Given n dimensional points, let C$_i$ be a cluster of data points. Let X$_j$ be an n-dimensional feature vector assigned to cluster C$_i$.
    $S_{i}=\left({\frac {1}{T_{i}}}\sum _{j=1}^{T_{i}}{\left|\left|X_{j}-A_{i}\right|\right|_{p}^{q}}\right)^{1/q}$
Here $A_{i}$ is the centroid of C$_i$ and T$_i$ is the size of the cluster i. $S_{i}$ is the qth root of the qth moment of the points in cluster i about the mean. If $q=1$ then $S_{i}$ is the average distance between the feature vectors in cluster i and the centroid of the cluster. Usually the value of p is 2, which makes the distance a Euclidean distance function. Many other distance metrics can be used, in the case of manifolds and higher dimensional data, where the euclidean distance may not be the best measure for determining the clusters. It is important to note that this distance metric has to match with the metric used in the clustering scheme itself for meaningful results.
    $M_{i,j}=\left|\left|A_{i}-A_{j}\right|\right|_{p}={\Bigl\displaystyle \sum _{k=1}^{n}\left|a_{k,i}-a_{k,j}\right|^{p}{\Bigr )}^{\frac {1}{p}}$
    $M_{i,j}$ is a measure of separation between cluster $C_{i}$ and cluster $C_{j}$.
    $a_{k,i}$ is the kth element of $A_{i}$, and there are n such elements in A for it is an n dimensional centroid.
Here k indexes the features of the data, and this is essentially the Euclidean distance between the centers of clusters i and j when p equals 2.

## Definition

Let R$_{i,j}$ be a measure of how good the clustering scheme is. This measure, by definition has to account for M$_{i,j}$ the separation between the ith and the jth cluster, which ideally has to be as large as possible, and S$_i$, the within cluster scatter for cluster i, which has to be as low as possible. Hence the Davies–Bouldin index is defined as the ratio of S$_i$ and M$_{i,j}$ such that these properties are conserved:
* $R_{i,j}\geqslant 0$.
* $R_{i,j}=R_{j,i}$.
* When $S_{j}\geqslant S_{k}$ and $M_{i,j}=M_{i,k}$ then $R_{i,j}>R_{i,k}$.
* When $S_{j}=S_{k}$ and $M_{i,j}\leqslant M_{i,k}$ then $R_{i,j}>R_{i,k}$.
With this formulation, the lower the value, the better the separation of the clusters and the 'tightness' inside the clusters.
A solution that satisfies these properties is:
    $R_{i,j}={\frac {S_{i}+S_{j}}{M_{i,j}}}$
This is used to define D$_i$:
    $D_{i}\equiv \max _{j\neq i}R_{i,j}$
If N is the number of clusters:
    ${\mathit {DB}}\equiv {\frac {1}{N}}\displaystyle \sum _{i=1}^{N}D_{i}$
DB is called the Davies–Bouldin index. This is dependent both on the data as well as the algorithm. D$_i$ chooses the worst-case scenario, and this value is equal to R$_{i,j}$ for the most similar cluster to cluster i. There could be many variations to this formulation, like choosing the average of the cluster similarity, weighted average and so on.

## Explanation

Lower index values indicate a better clustering result. The index is improved (lowered) by increased separation between clusters and decreased variation within clusters.
These conditions constrain the index so defined to be symmetric and non-negative. Due to the way it is defined, as a function of the ratio of the within cluster scatter, to the between cluster separation, a lower value will mean that the clustering is better. It happens to be the average similarity between each cluster and its most similar one, averaged over all the clusters, where the similarity is defined as S$_i$ above. This affirms the idea that no cluster has to be similar to another, and hence the best clustering scheme essentially minimizes the Davies–Bouldin index. This index thus defined is an average over all the i clusters, and hence a good measure of deciding how many clusters actually exists in the data is to plot it against the number of clusters it is calculated over. The number i for which this value is the lowest is a good measure of the number of clusters the data could be ideally classified into. This has applications in deciding the value of k in the kmeans algorithm, where the value of k is not known apriori.

## Soft version of Davies-Bouldin index

Recently, the Davies–Bouldin index has been extended to the domain of soft clustering categories. This extension is based on the category clustering approach according to the framework of fuzzy logic. The starting point for this new version of the validation index is the result of a given soft clustering algorithm (e.g. fuzzy c-means), shaped with the computed clustering partitions and membership values associating the elements with the clusters. In the soft domain, each element of the system belongs to every classes, given the membership values. Therefore, this soft version of the Davies–Bouldin index is able to take into account, in addition to standard validation measures such as compactness and separation of clusters, the degree to which elements belong to classes.

## Implementations

The scikit-learn Python open source library provides an implementation of this metric in the sklearn.metrics module.
R provides a similar implementation in its clusterSim package.
A Java implementation is found in ELKI, and can be compared to many other clustering quality indexes.