Clustering
DBSCAN
2023-12-21
Density Based Spatial Clustering of Applications with Noise (DBSCAN)
DBSCAN is an unsupervised clustering method that does not require the number of clusters to be specified in advance. It can outperform K-means when clusters consist of densely connected samples, as illustrated by the half-moon dataset below.

DBSCAN works as follows:
The algorithm needs two input values: ε (Epsilon) and the minimum number of neighbors to define a Core point.
Step 1. Calculate the distance between each data point and all other data points, mark the point as neighbor if it is within a distance of ε, and count the number of neighbors per each data point.
Step 2. If the number of neighbors of any sample is greater than the minimum number, mark them all as Core points.
Step 3. Mark all the neighbors of the Core point as Border points, and if any of the Border points also satisfies Step 2 of Core point, then its neighbors are also deemed to belong to the same cluster.
Step 4. If the Border point is not a Core point, only the Core point is classified into the same cluster.
Step 5. If it is neither a Border point nor a Core sample, it is determined as a Noise point and is not included in the cluster.

The key to running DBSCAN using Excel is to make Core point determinations for each sample and then repeatedly perform Step 3, which can be done in Excel by (1) after flagging the results of Step 2 as 1, performing a cross product (by SUMPRODUCT) for all samples, and (2) accumulating only positive results.
For example, if n=10 and the result of Step 2 is as follows, that is, clustered as (1,2), (2,3), (3,4), (4,5), (6,7), (7,8), (8,9), (9,10)

=IF(SUMPRODUCT(INDEX($B$2:$K$11,$A14,0),INDEX($B$2:$K$11,B$13,0))>0,1,0)
As shown below, when the result of SUMPRODUCT is positive for all samples (i.e., if at least one sample belongs to the same cluster), it is flagged as 1.



In the end, they all merge into the same cluster, and any row or column represents the same result of the clustering (0 or 1).