Visualizing a clustering result with matplotlib

56 views Asked by At

I ran a fuzzy c-means clustering algorithm on a dataset of size (11464, 2622) with 10 clusters and that yields a (10, 11464) size centers with Final fuzzy c-partitioned matrix of size (10, 2622).

My challenge is how to plot assigned clusters, for each data point in my dataset. I tried this below but didnt work.

cluster_membership = np.argmax(u, axis=0)
colors = ['b', 'orange', 'g', 'r', 'c', 'm', 'y', 'k', 'Brown','ForestGreen']

for j in range(10):
  x = data[:, 0]
  y = data[:, 1]
  plt.scatter(x[cluster_membership == j], y[cluster_membership == j], '.', color=colors[j])

where u is the partitioned matrix. but I get the error below ufunc 'sqrt' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

Can someone point me on the right direction to get my visualization? Regards

P.S I am following this example here

0

There are 0 answers