cluster = AgglomerativeClustering(n_clusters=3, linkage='average', affinity
    =pearson_affinity)
cluster.fit(X)
How to use Pearson Correlation as distance metric in Scikit-learn Agglomerative clustering