Skip to content
My workspace
from sklearn.cluster import AgglomerativeClustering
import numpy as np
X = np.array([[1, 2], [1, 4], [1, 0],
[4, 2], [4, 4], [4, 0]])
clustering = AgglomerativeClustering().fit(X)
print(clustering)
print(clustering.labels_)
data = list(zip(x,y)) inertias = []
for i in range(1,11): kmeans = KMeans(n_clusters = i) kmeans.fit(data) inertias.append(kmeans.inertia_)
plt.plot(range(1,11), inertias, marker = 'o') plt.title('Elbow Method') plt.xlabel('Number of Clusters') plt.ylabel('Inertia')