subplot_kw={'xticks'()'yticks'()}create random cluster assignment for reference random_state np random randomstate(seed= random_clusters random_state randint(low= high= size=len( )plot random assignment axes[ scatter(x_scaled[: ]x_scaled[: ] =random_clusterscmap=mglearn cm = axes[ set_title("random assignment{ }formatsilhouette_score(x_scaledrandom_clusters))algorithms [kmeans(n_clusters= )agglomerativeclustering(n_clusters= )dbscan()for axalgorithm in zip(axes[ :]algorithms)clusters algorithm fit_predict(x_scaledplot the cluster assignments and cluster centers ax scatter(x_scaled[: ]x_scaled[: ] =clusterscmap=mglearn cm = ax set_title("{{ }format(algorithm __class__ __name__silhouette_score(x_scaledclusters))figure - comparing random assignmentk-meansagglomerative clusteringand dbscan on the two_moons dataset using the unsupervised silhouette score--the more intuitive result of dbscan has lower silhouette score than the assignments found by -means as you can seek-means gets the highest silhouette scoreeven though we might prefer the result produced by dbscan slightly better strategy for evaluating clusters is using robustness-based clustering metrics these run an algorithm after adding some noise to the dataor using different parameter settingsand compare the outcomes the idea is that if many algorithm parameters and many perturbations of the data return the same resultit is likely to be trustworthy unfortunatelythis strategy is not implemented in scikit-learn at the time of writing even if we get very robust clusteringor very high silhouette scorewe still don' know if there is any semantic meaning in the clusteringor whether the clustering unsupervised learning and preprocessing