gpt4 book ai didi

r - "The TSS matrix is indefinite. There must be too many missing values. The index cannot be calculated "使用 nbclust 时

转载 作者:行者123 更新时间:2023-12-04 13:46:37 27 4
gpt4 key购买 nike

我想确定使用 NbClust 包进行聚类的最佳 k。我的数据同时具有连续变量和分类变量,因此我使用了使用集群包中的 daisy() 计算的相异矩阵。我使用了下面的代码:

 res.nb <- NbClust(gower_dist_gender, min.nc = 1, 
max.nc = 5,method = "complete", index ="all")

并遇到此错误:
The TSS matrix is indefinite. There must be too many missing values. The 
index cannot be calculated.

有什么问题,我应该如何解决?
另外考虑当我将索引设置为“silhouette”时,没有发生任何问题并将最好的k返回为2。但我想使用index="all"来确保根据大多数索引获得最佳k的结果.(当索引设置为“全部”时,26 个索引被视为索引,结果显示索引对 k 的数量的多数投票)。
所以问题是为什么运行上面将索引设置为“全部”的代码会遇到前面提到的错误?

任何小帮助将不胜感激。

最佳答案

您对 NbClust 的调用是错误的。
请参阅有关如何使用距离矩阵而不是数据矩阵的文档:

data

matrix or dataset.

diss

dissimilarity matrix to be used. By default, diss=NULL, but if it is replaced by a dissimilarity matrix, distance should be "NULL".

distance

the distance measure to be used to compute the dissimilarity matrix. This must be one of: "euclidean", "maximum", "manhattan", "canberra", "binary", "minkowski" or "NULL". By default, distance="euclidean". If the distance is "NULL", the dissimilarity matrix (diss) should be given by the user. If distance is not "NULL", the dissimilarity matrix should be "NULL".


使用 data=NULL, distance=NULL 并设置 diss 代替。

关于r - "The TSS matrix is indefinite. There must be too many missing values. The index cannot be calculated "使用 nbclust 时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46067602/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com