linkage_array ward(x_pcanow we plot the dendrogram for the linkage_array containing the distances between clusters plt figure(figsize=( )dendrogram(linkage_arrayp= truncate_mode='level'no_labels=trueplt xlabel("sample index"plt ylabel("cluster distance"figure - dendrogram of agglomerative clustering on the faces dataset creating clusterswe cut across the tree at the very topwhere there are vertical lines in the dendrogram for the toy data shown in figure - you could see by the length of the branches that two or three clusters might capture the data appropriately for the faces datathere doesn' seem to be very natural cutoff point there are some branches that represent more distinct groupsbut there doesn' appear to be particular number of clusters that is good fit this is not surprisinggiven the results of dbscanwhich tried to cluster all points together let' visualize the clustersas we did for -means earlier (figure - note that there is no notion of cluster center in agglomerative clustering (though we could compute the mean)and we simply show the first couple of points in each cluster we show the number of points in each cluster to the left of the first imagein[ ]n_clusters for cluster in range(n_clusters)mask labels_agg =cluster figaxes plt subplots( subplot_kw={'xticks'()'yticks'()}figsize=( )axes[ set_ylabel(np sum(mask)for imagelabelasdfax in zip(x_people[mask]y_people[mask]labels_agg[mask]axes)ax imshow(image reshape(image_shape)vmin= vmax= ax set_title(people target_names[labelsplit()[- ]fontdict={'fontsize' } unsupervised learning and preprocessing