Package: edbscan
EDBSCANEnforced Density-Based Spatial Clustering of Applications with Noise.This package is an extension on theDBSCANalgorithm to enable for pre-labeled data points in the clusters, or in other words to enforce certain cluster values and splits.
It mimics thescikit-learnimplementation ofsklearn.cluster.DBSCAN.InstallationYou can either install the package throughPyPI:pipinstalledbscanOr via this repository directly:pipinstallgit+https://github.com/RubenPants/EDBSCAN.gitUsageThe image below shows you the result of EDBSCAN on a given input. The image on the left shows you the raw input data, together with the few labeled samples. The image on the right shows the clusters found by EDBSCAN, where the light blue dots represent the detected noise.# Load in the dataimportnumpyasnpdata=np.load(open('data.npy'))print(data.shape)# (220, 2)y=np.load(open('y.npy'))print(y.shape)# (220, )print(y)# array([None, None, …, -1, None, …, 0, None, …, 1, …], dtype=object)# Run the algorithmfromedbscanimportedbscancore_points,labels=edbscan(X=data,y=y)print(labels)# array([-1, 2, 2, 4, -1, -1, 6, 3, 4, …])As shown in the code snippet above, aside from the raw data (data), a target vectoryis provided. This vector indicates the known (labeled) clusters. ANonecluster label are those not yet known, that need to get clustered by the EDBSCAN algorithm.For more detailed usages, see the notebooks present in theexamples/folder.How EDBSCAN worksThere are three concepts that define how EDBSCAN operates:TheDBSCANalgorithm on which this algorithm is based on, read thepaperor thescikit-learn documentationfor more.Semi-supervised annotations, represented by theyvector in theUsagesection. This vector contains three types of values:Noneif the given sample is not known to belong to a specific cluster and needs to get labeled by the EDBSCAN algorithm-1if the given sample is known to be noise0..Nif the given sample is known to belong to cluster0..NWhere DBSCAN expands its clusters in aFIFOfashion, will EDBSCAN expand its clusters in amost dense firstfashion. In other words, the items that have the most detected nearest neighbours get expanded first. By doing so, the denser areas get assigned a cluster faster. This prevents two dense cluster that are near each other from merging if they are already assigned a different label.ComparisonThis section compares EDBSCAN to (1) other clustering algorithms as DBSCAN and HDBSCAN, and (2) on different clustering benchmarks.1. DBSCAN, HDBSCAN, and EDBSCANThis section compares the behaviour of theDBSCANalgorithm, theHDBSCANand theEDBSCANalgorithm on the data shown in theUsagesection. The input data looks as follows:In each of the clustered results, light-blue data represents the detected noise.Some observations on theDBSCANresult:Green combined two clusters that should be separatedPurple combined two clusters that should be separatedBrown identified noise as a clusterSome observations on theHDBSCANresult:Yellow and Grey are now successfully separatedBrown and Pink are now successfully separatedPurple identified noise as a clusterSome observations on theEDBSCANresult:Grey and Orange are now successfully separatedBrown and Pink are now successfully separatedThe noise that was previously detected as a cluster is now successfully identified as noise2. Scikit-learn cluster benchmarkThe following images show the results of the EDBSCAN algorithm on differentscikit-learn clustering benchmarks.