DBSCAN Clustering Algorithm in R


The DBSCAN algorithm is based on this intuitive notion of “clusters” and “noise”. It groups together point that are close to each other based on eps(min. distance between two points) and a minimum number of points(minPoints).


eps: the minimum distance between two points. It means that if the distance between two points is lower or equal to this value (eps), these points are considered neighbors.

minPoints:  the minimum number of points required to form a cluster.


Parameter Estimation
1. Determine minPoints: Generally, a minPoints can be derived from a number of dimensions(D) in a dataset, as minPoints>=D+1. minPoints value should be minimum 3 and larger dependending on the dataset choosed.

2. Determining optimum ‘eps’ value: To determine the optimum eps value we used K-distance plot method, a knee corresponds to a threshold where a sharp change occurs along the k-distance curve.
Function used: knndistplot()

Package used


For K-distance Plot

iris_mat = as.matrix(iris[,-5])

K-Distance Plot

Apply DBSCAN and plot clusters

db = dbscan(iris_mat,0.4,4)


Advantages of DBSCAN algorithm
1. It can discover any number of clusters.
2. Clusters of varying shapes and sizes can be obtained using the DBSCAN algorithm.
3. It can detect and ignore outliers.

Leave a Reply


WordPress.com Logo


Google photo


Twitter picture


Facebook photo


Connecting to %s


Website Powered by WordPress.com.

Up ↑
