1
$\begingroup$

I had a data set of images that I have extracted 9 numerical features that I want to apply k means clustering or hierarchical clustering to. I'm just not sure how to go about it. The tutorials I have read all only have 2 or 3 features to them, so it's easy to apply and graph. Any help would be appreciated

Here's the code I have so far:

numpyArr = df.values


ms = MeanShift()
ms.fit(numpyArr)
labels = ms.labels_
cluster_centers = ms.cluster_centers_
n_clusters_ = len(np.unique(labels))
print("Number of estimated clusters:", n_clusters_)
$\endgroup$

3 Answers 3

2
$\begingroup$

You may use a dimensionality reduction algorithm like PCA method after performing clustering, to reduce the dimension of your clustered data into two dimensions and then visualize the clusters.

$\endgroup$
4
  • $\begingroup$ So I would apply normal clustering using my data set then use PCA to visualize it? How would I go about doing that $\endgroup$ Jul 30, 2019 at 12:36
  • $\begingroup$ Yes exactly. Please check the following link medium.com/@dmitriy.kavyazin/… $\endgroup$ Jul 30, 2019 at 13:57
  • $\begingroup$ oh wow great article. I'll def try this out. Thank you! $\endgroup$ Jul 30, 2019 at 14:02
  • $\begingroup$ @somedude1234 you are welcome! $\endgroup$ Jul 30, 2019 at 16:24
2
$\begingroup$

Same as visualizing 9 dimensional data:

  • scatter plot matrix with 9x9 scatterplots
  • dimensionality reduction
  • parallel coordinates
  • whisker plots
  • ...
$\endgroup$
1
$\begingroup$

If you want to visualise the data after K-Means, the better approach would be to reduce the dimensionality to two or three dimensions and visualise using a matplotlib 2D or 3D plot. You might also try pair plots but I don't think It would be much helpful from clustering stand point.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.