Próbka klastrowania K-średnich

from scipy.cluster.vq import kmeans, vq

# Compute cluster centers
centroids,_ = kmeans(df, 2)

# Assign cluster labels
df['cluster_labels'], _ = vq(df , centroids)

# Plot the points with seaborn
sns.scatterplot(x='x', y='y' , hue= 'cluster_labels', data=df)
plt.show()
josh.ipynb