Path: blob/master/ML Clustering Analysis/3.2 Divisive hierarchical clustering.ipynb
3074 views
Kernel: Python 3 (ipykernel)
Divisive hierarchical clustering is less commonly used compared to agglomerative clustering, and it’s not directly supported by many popular libraries. However, you can implement it manually. Here’s a simple example using Python:
Steps for Divisive Clustering
Start with all data points in a single cluster.
At each step, split the largest cluster into two smaller clusters.
Continue splitting until the desired number of clusters is reached
In [2]:
Out[2]:
Cluster labels: [0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 2 2 2 2 2 2 3 3 3 3 3 3 3]
Explanation
divisive_clustering function: This function performs divisive clustering by repeatedly splitting the largest cluster into two smaller clusters until the desired number of clusters is reached.
KMeans: Used to split the largest cluster into two clusters at each step.
Combining results: All clusters are combined into one array, and labels are assigned to each data point.