I have a data set with 16 variables, and after clustering by kmeans, I wish to plot the two groups.
What plots do you suggest to visually represent the two clusters?
Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It only takes a minute to sign up.Sign up to join this community
There's no single right visualization. It depends on what aspect of the clusters you want to see or emphasize.
Do want to see how each variable contributes? Consider a parallel coordinates plot.
Do you want to see how clusters are distributed along the principal components? Consider a biplot (in 2D or 3D):
Do you want to look for cluster outliers over all dimensions. Consider a scatterplot of distance from cluster 1's center against distance from cluster's center 2. (By definition of K Means each cluster will fall on one side of the diagonal line.)
Do you want to see pairwise relations compared to the clustering. Consider a scatterplot matrix colored by cluster.
Do you want to see a summary view of the cluster distances? Consider a comparison of any distribution visualization, such as histograms, violin plots, or box plots.
Multivariate displays are tricky, especially with that number of variables. I have two suggestions.
If there are certain variables that are particularly important to the clustering, or substantively interesting, you can use a scatterplot matrix and display the bivariate relationships between your interesting variables. You could even used enhanced scatterplots (e.g. use shapes with size proportional to a third variable) to add in some more dimensionality
Alternatively, you could use a springplot which was developed for displaying high dimensional data that exhibits clustering. Note, I have never seen this in the literature I am familiar with, but I think it is a very interesting way of displaying multivariate data. The following citation is where the plot was originally proposed.
Hoffman,P.E. et al. (1997) DNA visual and analytic data mining. In the Proceedings of the IEEE Visualization. Phoenix, AZ, pp. 437-441.
And here is where I originally found mention of it.
Now, fair warning, I haven't been able to find an implementation of springplots outside of Orange. Then again, I haven't searched that hard!
I am assuming that your data is real valued and continuous, if it is discrete or non-interval, so on so forth, I don't think either plots would be helpful.
You can use fviz_cluster function from factoextra pacakge in R. It will show the scatter plot of your data and different colors of the points will be the cluster.
To the best of my understanding, this function performs the PCA and then chooses the top two pc and plot those on 2D.
Any suggestion/improvement in my answer are most welcome.