'How to plot center correctly in clustering matplotlib? [duplicate]
i have plenty of time analyzing the center of the clustering, I also am able to plot the center, but i guess i am doing wrong as i cannot find it properly, i also have feature_pca with the output: array([[-0.0455233 , -0.03700059],
[ 0.04053692, 0.00630769],
[-0.0095335 , -0.00375971],
...,
[ 0.27832255, -0.29928393],
[ 0.27832255, -0.29928393],
[-0.14545832, -0.00768137]])
But, still using the code i am not able to calculate the cluster center, can anybody tell where am i going wrong? The final image is as:
fig, axes = plt.subplots(1, 1, sharey=True)
fig.set_size_inches(20, 10)
# use the same set of colors as above to compare side to side of the two graphs
colors = ['blue', 'green', 'red', 'purple', 'orange']
for e in set(kmeans.labels_):
mark = kmeans.labels_ == e
axes.scatter(feature_pca[:, 0][mark], feature_pca[:, 1][mark], color=colors[e], label=e, alpha=0.9)
axes.legend()
centers = fitted.cluster_centers_
axes.scatter(centers[:, 0], centers[:, 1],c='black', s=200, alpha=0.6 );
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
