April 2018
Beginner to intermediate
282 pages
6h 52m
English
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' ...
Read now
Unlock full access