Section I: Brief Introduction on Hierarchy Cluster
The two standard algorithms for agglomerative hierarchical clustering are single linkage and complete linkage. Using single linkage, the distances between the most similar members for each pair of clusters and merge the two clusters for which the distance between the most similar members is the smallest. With respect to complete linkage, the approach is similar to single linkage but, instead of comparing the most similar members in each pair of clusters, it compare the most dissimilar members to perform the merge.
Hierarchical complete linkage clustering is an iterative procedure that can be summarized by the following steps:
- Step 1: Compute the distance matrix of all samples (Euclidean Distance)
- Step 2: Represent each data point as a singleton cluster
- Step 3: Merge the two closest clusters based on the distance between the most similar/dissimilar (distant) members
- Step 4: Update similarity matrix
- Step 5: Repeat steps 2-4 until one single cluster remains
FROM
Sebastian Raschka, Vahid Mirjalili. Python机器学习第二版. 南京:东南大学出版社,2018.
第一部分: 数据初始化
代码
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import warnings
warnings.filterwarnings("ignore")
plt.rcParams['figure.dpi']=200
plt.rcParams['savefig.dpi']=200
font = {