-
Book Overview & Buying
-
Table Of Contents
scikit-learn Cookbook - Third Edition
By :
DBSCAN is a somewhat unique clustering algorithm capable of identifying clusters of varying shapes and sizes. It differs from K-means and hierarchical clustering by not requiring the number of clusters to be specified in advance and by handling outliers (noise) effectively. This means, unlike K-means, it does not generate centroids a priori. This recipe applies DBSCAN on a rather unconventional dataset.
Here, we are going to use another data generator function in scikit-learn called make_moons(), which, again, like make_blobs() is aptly named!
Load the libraries:
from sklearn.cluster import DBSCAN
from sklearn.datasets import make_moonsCreate a new one with noise:
X, _ = make_moons(n_samples=300, noise=0.1, random_state=2024)Another scikit-learn dataset generator (make_moons) creates crescent shaped data sets for exploring clustering algorithms that work better with data not arranged in spherical groupings
Let&...