R中的K-均值聚类分析
我正在尝试根据相对稀疏的数据框/矩阵(下图)以图形方式可视化单个群集。我不确定为什么要继续遇到以下错误:
cannot rescale a constant/zero column to unit variance`
这是我在此分析中使用的代码段。
library(cluster)
library(factoextra)
library(gridExtra)
kmeans2 = kmeans(df, centers=1, nstart=5) # df (see table below) contains probabilities
fviz_cluster(kmeans2, data=df, scale=F) # Visualize the cluster
这是上面代码中使用的数据框(“ DF”)。您可能已经注意到,大多数值接近0。是否有任何调整/转换能够成功执行群集分析?
a b c d e f g h i j
0.06906453 0.01083181 0.01627455 0.03762042 0.1144168 0.01529368 0.03265494 0.08005074 0.08902436 0.003516431
k l m n o p q r s t
0.01686642 0.0410222 0.0133853 0.07202466 0.0890314 0.01146801 0.0002297176 0.04715371 0.07463133 0.1023295
u v w x y z
0.02023235 0.005822369 0.02169929 0.0003092351 0.01494907 9.718769e-05
I'm trying to graphically visualize a single cluster based on a relatively sparse dataframe/matrix (below). I'm not sure why I keep getting the following error:
cannot rescale a constant/zero column to unit variance`
Here is the code snippet that I have used in this analysis.
library(cluster)
library(factoextra)
library(gridExtra)
kmeans2 = kmeans(df, centers=1, nstart=5) # df (see table below) contains probabilities
fviz_cluster(kmeans2, data=df, scale=F) # Visualize the cluster
This is the dataframe ("df") used in the code above. As you may have noticed, most values as close to 0. Is there any adjustment/transformation that I could make to be able to successfully perform a cluster analysis ?
a b c d e f g h i j
0.06906453 0.01083181 0.01627455 0.03762042 0.1144168 0.01529368 0.03265494 0.08005074 0.08902436 0.003516431
k l m n o p q r s t
0.01686642 0.0410222 0.0133853 0.07202466 0.0890314 0.01146801 0.0002297176 0.04715371 0.07463133 0.1023295
u v w x y z
0.02023235 0.005822369 0.02169929 0.0003092351 0.01494907 9.718769e-05
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论