【问题标题】:Different Distance Matrix with Different Linkage used in Hierarchical Clustering层次聚类中使用不同链接的不同距离矩阵
【发布时间】:2020-07-26 07:37:04
【问题描述】:

我们如何在R中使用不同的距离矩阵和链接方法快速得到层次聚类的结果?

【问题讨论】:

    标签: r hierarchical-clustering


    【解决方案1】:

    我得到了答案,我们可以编写自定义函数,用它可以在 R 中处理此类问题,并且在 python 中也可以稍​​作改动。

    hierarchical_clust <- function(orig_data_frame,x1,x2,n)
    {
     y= dist(orig_data_frame,method =x1)
     fit <- hclust(y,method=x2)
     groups <- cuttree(fit,n)
     clust_centers <- aggregate(orig_data_frame,list(groups),mean)
    
    }
    
       
    

    【讨论】:

    • 将 x1 替换为您想尝试的距离。将 x2 替换为链接方法,将 n 替换为您要尝试的集群数
    猜你喜欢
    • 2014-10-24
    • 2016-08-21
    • 2012-09-05
    • 2019-01-11
    • 2019-02-05
    • 1970-01-01
    • 2020-01-23
    • 2016-03-20
    • 2011-04-13
    相关资源
    最近更新 更多