cluster#

Module: cluster#

Helper functions for clustering#

This module contains functions used for clustering in the unsupervised lab of ISLP. Currently it contains just a simple function to construct a linkage matrix to assist plotting a dendrogram of a hierarchical clustering.

ISLP.cluster.compute_linkage(hclust)#

Create linkage matrix used to plot a dendrogram

Follows [sklearn example](https://scikit-learn.org/stable/auto_examples/cluster/plot_agglomerative_dendrogram.html)

Parameters:
hclustsklearn.cluster.AgglomerativeClustering

Fitted hierarchical clustering object.

Returns:
linkage_matrixnp.ndarray

Array to be passed to dendrogram from scipy.cluster.hierarchy.