【问题标题】:Comparing 2 Cluster solutions using k-means clustering比较使用 k-means 聚类的 2 个聚类解决方案
【发布时间】:2012-07-02 18:48:06
【问题描述】:

我是第一次在 R 中尝试集群,并且一直在在线查看基本的 R 帮助,并尝试比较两种集群解决方案的结果。

我复制并粘贴脚本时小心翼翼地确保我首先正确命名了相关数据集,但不断收到我不理解的错误消息。

有什么想法吗?

脚本很简单:

比较 2 个集群解决方案

library(fpc)
cluster.stats (d, fit1$cluster, fit2$cluster)

我得到的错误信息是:

> library(fpc)
> cluster.stats(d, fit1$cluster, fit2$cluster)
Error in as.matrix.dist(d) : 
  length of 'dimnames' [1] not equal to array extent
In addition: Warning messages:
1: In as.dist.default(d) : NAs introduced by coercion
2: In as.dist.default(d) : non-square matrix
3: In as.matrix.dist(d) :
  number of items to replace is not a multiple of replacement length

谢谢

【问题讨论】:

    标签: r cluster-analysis k-means


    【解决方案1】:

    d 对象应该包含一个距离矩阵(通常是对角线上有零的对称矩阵)。在 R 中可以使用

    获得距离矩阵
    d <- dist(clustering_result)
    

    【讨论】:

      猜你喜欢
      • 2016-05-07
      • 2019-11-25
      • 2019-06-14
      • 2015-04-11
      • 2020-02-28
      • 2021-11-18
      • 2011-08-13
      • 2013-08-08
      • 2013-02-14
      相关资源
      最近更新 更多