R中的距离聚类 [英] Clustering by distance in R

查看:78
本文介绍了R中的距离聚类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个整数向量,希望将其划分为多个簇,以使任何两个簇之间的距离均大于下界,而在任何簇中,两个元素之间的距离均小于上限。 p>

例如,假设我们有以下向量:



1、4、5、6、9、29, 32,36



并将上述下限和上限分别设置为19和9,以下两个向量应该是可能的结果:



1、4、5、6、9



29、32、36



< hr>

感谢@flodel的评论,我意识到这种聚类可能是不可能的。因此,我想对问题进行一些修改:



如果仅强加 between 之间的群集距离下限,可能有哪些群集方法?
如果仅在群集距离上限内强加,可能有哪些群集方法?

解决方案

如果仅强加集群距离之间的下限,可能有哪些集群方法?



具有单链接的分层集群

  x<-c(1、4、5、6、9、29、32、46 ,55)
树<-hclust(dist(x),method = single)
split(x,cutree(tree,h = 19))

# $`1`
#[1] 1 4 5 6 9

#$`2`
#[1] 29 32 46 55






如果我仅施加群集内距离,可能的群集方法是什么



具有完全链接的分层聚类:

  x<-c(1、4、5、6、9、20、26、29、32)
树<-hclust(dist(x),method = 完整)
split(x,cutree(tree,h = 9))

# $`1`
#[1] 1 4 5 6 9

#$`2`
#[1] 20

# $`3`
#[1] 26 29 32


I have a vector of integers which I wish to divide into clusters so that the distance between any two clusters is greater than a lower bound, and within any cluster, the distance between two elements is less than an upper bound.

For example, suppose we have the following vector:

1, 4, 5, 6, 9, 29, 32, 36

And set the aforementioned lower bound and upper bound to 19 and 9 respectively, the two vectors below should be a possible result:

1, 4, 5, 6, 9

29, 32, 36


Thanks to @flodel 's comments, I realized this kind of clustering may be impossible. So I would like to modify the questions a bit:

What are the possible clustering methods if I impose only the between cluster distance lower bound? What are the possible clustering methods if I impose only the within cluster distance upper bound?

解决方案

What are the possible clustering methods if I impose only the between cluster distance lower bound?

Hierarchical clustering with single linkage:

x <- c(1, 4, 5, 6, 9, 29, 32, 46, 55)
tree <- hclust(dist(x), method = "single")
split(x, cutree(tree, h = 19))

# $`1`
# [1] 1 4 5 6 9
# 
# $`2`
# [1] 29 32 46 55


What are the possible clustering methods if I impose only the within cluster distance upper bound?

Hierarchical clustering with complete linkage:

x <- c(1, 4, 5, 6, 9, 20, 26, 29, 32)
tree <- hclust(dist(x), method = "complete")
split(x, cutree(tree, h = 9))

# $`1`
# [1] 1 4 5 6 9
# 
# $`2`
# [1] 20
# 
# $`3`
# [1] 26 29 32

这篇关于R中的距离聚类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆