Exercise

# Hierarchical agglomerative clustering

In the last exercise, you saw how the number of clusters while performing K-means clustering could impact your results allowing you to discuss K-means in a machine learning interview. However, another clustering model you can use is hierarchical agglomerative clustering. In Python, you could derive the optimal number of clusters for this technique both visually and mathematically. You will the `scipy`

and `sklearn`

modules to do both.

Recall that selecting the optimal number of clusters from a dendrogram depends on both the linkage criteria and distance threshold. Here, you'll create a dendrogram with the `X`

matrix from `diabetes`

, then extend an imaginary line at length 1.50, counting the number of vertical lines crossed to represent the optimal number of clusters for your hierarchical clustering algorithm going forward.

Instructions 1/4

**undefined XP**

- Import the relevant packages to create a dendrogram and perform agglomerative hierarchical clustering.