initiallyeach point is its own cluster thenin each stepthe two clusters that are closest are merged in the first four stepstwo single-point clusters are picked and these are joined into two-point clusters in step one of the two-point clusters is extended to third pointand so on in step there are only three clusters remaining as we specified that we are looking for three clustersthe algorithm then stops let' have look at how agglomerative clustering performs on the simple threecluster data we used here because of the way the algorithm worksagglomerative clustering cannot make predictions for new data points thereforeagglomerative clustering has no predict method to build the model and get the cluster memberships on the training setuse the fit_predict method instead the result is shown in figure - in[ ]from sklearn cluster import agglomerativeclustering xy make_blobs(random_state= agg agglomerativeclustering(n_clusters= assignment agg fit_predict(xmglearn discrete_scatter( [: ] [: ]assignmentplt xlabel("feature "plt ylabel("feature " we could also use the labels_ attributeas we did for -means clustering