O'Reilly logo

Hands-On Automated Machine Learning by Umit Mert Cakmak, Sibanjan Das

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Simple automation of unsupervised learning

You should automate this whole discovery process to try different clustering algorithms with different hyperparameter settings. The following code will show you a simple way of doing that:

# You will create a list of algorithms to testfrom sklearn.cluster import MeanShift, estimate_bandwidth, SpectralClusteringfrom hdbscan import HDBSCAN# bandwidth estimate for MeanShift algorithm to work properlybandwidth = estimate_bandwidth(X, quantile=0.3, n_samples=100)estimators = [{'estimator': KMeans, 'args': (), 'kwargs': {'n_clusters': 5}},                         {'estimator': DBSCAN, 'args': (), 'kwargs': {'eps': 0.5}},                         {'estimator': AgglomerativeClustering, 'args': (), 'kwargs': {'n_clusters': 5, 'linkage': 'ward'}},                         {'estimator' ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required