【问题标题】:How to calculate Centroid at DTWCLUST library in R如何在 R 中的 DTWCLUST 库中计算质心
【发布时间】:2017-08-26 00:59:22
【问题描述】:

我在 r 中使用 DTWCLUST 包。这是我的代码。

library(dtwclust)
sc1 <- read.table("D:/handling data/confirm4.csv", header=T, sep="," )
hc_sbd <- dtwclust(sc1, type = 'h', k=5L, method = 'ward.D', preproc = zscore,
                distance = 'dtw', control = list(trace=TRUE) )
clusters <- cutree(hc_sbd,6)
head(clusters)
result <- cbind.data.frame(sc1,clusters)
plot(hc_sbd, type='centroids', clus=1) + ylim(-3, 3) + scale_x_continuous( breaks = c(1,6,12,18,24,30,36,42), labels= real_label )

当我运行plot(hc_sbd, type='centroids', clus=1) + ylim(-3, 3) + scale_x_continuous( breaks = c(1,6,12,18,24,30,36,42), labels= real_label ) 时,原型被绘制出来了。 但我不知道 PAM 是如何计算质心的,这是默认选项。谁能帮我理解 PAM 到 obtaion 质心的概念? 提前感谢您。

【问题讨论】:

标签: r cluster-computing


【解决方案1】:

在包中包含的实现中, 数据中的 k 系列随机选择作为初始质心。 然后计算所有系列与质心之间的距离 (或从整个距离矩阵中检索,如果它是预先计算的), 并且每个系列都分配给其最近的质心的集群。 对于每个创建的集群, 计算所有成员系列之间的距离(如有必要), 并且距离总和最小的系列被选为新的质心。 这会迭代地继续,直到没有序列变化集群, 或已超过允许的最大迭代次数。

Here's the code.

(如果您使用 dtwclust 4.0.0 或更高版本,则应该使用tsclust 函数)

【讨论】:

  • 太棒了!!谢谢~~你是个好人~
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-04-06
  • 2014-06-30
  • 1970-01-01
  • 2013-11-14
  • 2014-06-28
  • 2014-09-09
相关资源
最近更新 更多