HDBSCAN (Hierarchical DBSCAN) › Visualizing HDBSCAN

Michael BrenndoerferAugust 17, 20255 min read
Machine Learning from ScratchAll chapters
Part 7 of 9Unsupervised Learning
Chapter 56HDBSCAN (Hierarchical DBSCAN) › Visualizing HDBSCAN
Reading section 3 of 8 · Visualizing HDBSCAN · 5 minSection 3 of 8 · 5 min

Book contents

Section 3 of 8 · 5 min read

HDBSCAN (Hierarchical DBSCAN) › Visualizing HDBSCANOne section · Sections in this chapter3 / 8 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Let's create visualizations that demonstrate how HDBSCAN works and how it differs from other clustering methods.

Out[4]:
Visualization
Scatter plot showing ground truth for variable density blobs dataset.
True labels for variable density blobs dataset. This synthetic dataset contains four clusters with different standard deviations (1.0, 2.5, 0.5, 1.5), creating clusters of varying densities. The ground truth shows how clusters can have different shapes and densities, which challenges many traditional clustering algorithms that assume uniform cluster characteristics.
Scatter plot showing K-means results on variable density blobs.
K-Means clustering on variable density blobs. K-Means struggles with this dataset because it assumes spherical clusters of similar size. The algorithm incorrectly splits the dense cluster (bottom left) and merges some of the sparse clusters. The fixed number of clusters (4) also constrains the algorithm's flexibility.
Scatter plot showing DBSCAN results on variable density blobs.
DBSCAN clustering on variable density blobs. DBSCAN performs better than K-Means by identifying clusters of arbitrary shapes, but it still struggles with the variable density. The algorithm correctly identifies the dense cluster but fails to capture the sparse clusters properly.
Scatter plot showing HDBSCAN results on variable density blobs.
HDBSCAN clustering on variable density blobs. HDBSCAN excels at this dataset by automatically determining the optimal number of clusters and handling variable densities effectively. The algorithm successfully identifies all four clusters with their different densities.
Scatter plot showing ground truth for concentric circles dataset.
True labels for concentric circles dataset. This dataset contains two circular clusters with one nested inside the other, creating a challenging non-linear separation. The inner circle has a smaller radius and is completely surrounded by the outer circle.
Scatter plot showing K-means results on concentric circles.
K-Means clustering on concentric circles. K-Means completely fails on this dataset because it assumes linear separability and spherical clusters. The algorithm creates artificial boundaries that cut through both circles. This is a classic example where K-Means produces meaningless results.
Scatter plot showing DBSCAN results on concentric circles.
DBSCAN clustering on concentric circles. DBSCAN also struggles with this dataset because it has difficulty with nested structures and requires careful parameter tuning. The algorithm may either merge the two circles into one cluster or fail to identify the inner circle properly, depending on the eps parameter setting.
Scatter plot showing HDBSCAN results on concentric circles.
HDBSCAN clustering on concentric circles. HDBSCAN handles this challenging dataset well by using its hierarchical approach to identify nested structures. The algorithm can separate the two concentric circles effectively.
Scatter plot showing ground truth for two moons dataset.
True labels for two moons dataset. This dataset consists of two interleaving half-circles (moons) that are non-linearly separable. The moons are positioned so that they cannot be separated by a straight line.
Scatter plot showing K-means results on two moons.
K-Means clustering on two moons. K-Means fails completely on this dataset because it cannot handle the non-linear separation between the two moons. The algorithm creates a straight-line boundary that cuts through both moons, assigning points from the same moon to different clusters. This demonstrates K-Means' basic limitation with non-linearly separable data.
Scatter plot showing DBSCAN results on two moons.
DBSCAN clustering on two moons. DBSCAN performs reasonably well on this dataset by identifying the two moons as separate clusters. However, it may struggle with the noise parameter and the curved shape, potentially misclassifying some points or requiring careful parameter tuning to achieve optimal results.
Scatter plot showing HDBSCAN results on two moons.
HDBSCAN clustering on two moons. HDBSCAN excels at this dataset by automatically identifying the two moons as distinct clusters. The algorithm handles the non-linear separation and arbitrary shapes effectively.

Here's how HDBSCAN performs compared to K-Means and DBSCAN across different types of data structures. You can see that HDBSCAN successfully handles variable density clusters, non-spherical shapes, and automatically determines the appropriate number of clusters.