ClusteringTree[{e1,e2,…}]
构建元素 e1、e2、…等的分级聚类的加权树.
ClusteringTree[{e1v1,e2v2,…}]
在构建的图中用 vi 表示 ei.
ClusteringTree[{e1,e2,…}{v1,v2,…}]
在构建的图中用 vi 表示 ei.
ClusteringTree[label1e1,label2e2…]
在构建的图中用标签 labeli 表示 ei.
ClusteringTree[data,h]
通过把距离小于 h 的子聚类连在一起,根据 data 的分级聚类构建加权树.
ClusteringTree
ClusteringTree[{e1,e2,…}]
构建元素 e1、e2、…等的分级聚类的加权树.
ClusteringTree[{e1v1,e2v2,…}]
在构建的图中用 vi 表示 ei.
ClusteringTree[{e1,e2,…}{v1,v2,…}]
在构建的图中用 vi 表示 ei.
ClusteringTree[label1e1,label2e2…]
在构建的图中用标签 labeli 表示 ei.
ClusteringTree[data,h]
通过把距离小于 h 的子聚类连在一起,根据 data 的分级聚类构建加权树.
更多信息和选项
- ClusteringTree 创建一个 Tree 对象,显示数据点如何分层聚集在一起.
- 数据元素 ei 可以是数字;数值列表、矩阵或张量;布尔元素列表;字符串或图像;地理位置或地理实体;颜色;以及这些数据的组合. 如果 ei 是列表、矩阵或张量,它们的维度必须相同.
- 来自 ClusteringTree 的结果是一个二项加权树,其中每个顶点的权重表示由该顶点作为根的两个子树之间的距离:
- ClusteringTree 具有与 Graph 相同的选项,并有以下增加和变化: [所有选项的列表]
-
ClusterDissimilarityFunction Automatic 要使用的聚类关联算法 DistanceFunction Automatic 要使用的距离或相异度 EdgeStyle GrayLevel[0.65] 边的样式 FeatureExtractor Automatic 怎样从数据中提取特征 VertexSize 0 顶点的大小 - 缺省情况下,除非指定了 DistanceFunction 或 FeatureExtractor,ClusteringTree 将自动对数据进行预处理.
- ClusterDissimilarityFunction 定义聚类内的相异度,不同成员元素之间的相异度已知.
- ClusterDissimilarityFunction 的可能设置包括:
-
"Average" 平均聚类内相异度 "Centroid" 聚类质心的距离 "Complete" 最大的聚类内相异度 "Median" 到聚类中位数的距离 "Single" 最小的聚类内相异度 "Ward" Ward 最小方差相异度 "WeightedAverage" 加权平均聚类内相异度 纯函数 - 函数 f 定义了任意两个聚类之间的距离.
- 函数 f 必须是 DistanceMatrix 的实值函数.
所有选项的列表
范例
打开所有单元 关闭所有单元基本范例 (5)
ClusteringTree[{1, 2, 5}]ClusteringTree[{1, 2, 5}, 1.3]ClusteringTree[{"a", "abba", "ababa", "abcdefg"}]ClusteringTree[{[image], [image], [image], [image]}]ClusteringTree[{Entity["City", {"Paris", "IleDeFrance", "France"}], Entity["City", {"Sydney", "NewSouthWales", "Australia"}], Entity["City", {"Boston", "Massachusetts", "UnitedStates"}], Entity["City", {"SanFrancisco", "California", "UnitedStates"}]}]ClusteringTree[{{False, False}, {True, False}, {True, True}}]范围 (8)
g = ClusteringTree[{0.1, 2.2, 3.4, 5.6, 8.9}]AnnotationValue[g, "LeafLabels"]通过 VertexWeight 查看子聚类之间的距离:
AnnotationValue[g, VertexWeight]FindShortestPath[g, 1, 7 ]data = {{RGBColor[0.3882530591983919, 0.2972372289203644, 0.14662872236042124], "brown"}, {RGBColor[0.3134110772018093, 0.6577487501778145, 0.7061181487042973], "light blue"}, {RGBColor[0.31684543929904985, 0.32154575812724917, 0.8496239355766027], "blue"}, {RGBColor[0.5443420548178017, 0.4583234220657759, 0.8094937667804043], "violet"}, {RGBColor[0.4274650545373566, 0.9072941688093845, 0.898117681435409], "light blue"}, {RGBColor[0.9323469092538643, 0.8301659871869203, 0.4534352919547222], "yellow"}, {RGBColor[0.7518445360980579, 0.05631287374652039, 0.6430690822523268], "light violet"}};ClusteringTree[data]ClusteringTree[data[[All, 1]]]data = RandomColor[20]ClusteringTree[data, ClusterDissimilarityFunction -> "Centroid"]根据 Association 计算层次聚类:
association = <|"Red" -> RGBColor[0.7355420127983632, 0.2464091158003272, 0.1318671396857256], "Blue" -> RGBColor[0.19595271830233885, 0.10998208611256777, 0.5195988419509086], "Pink" -> RGBColor[0.98714064424384, 0.4517971556938676, 0.7345757642205208], "Yellow" -> RGBColor[0.914802573832932, 0.9472567075421043, 0.19573643015491093]|>;ClusteringTree[association]与 Values 的层次聚类进行比较:
ClusteringTree[Values[association]]与 Keys 的层次聚类进行比较:
ClusteringTree[Keys[association]]data = RandomColor[20]ClusteringTree[data, 0.4, ClusterDissimilarityFunction -> "Centroid"]改变 ClusteringTree 的样式和布局:
data = RandomInteger[{0, 100}, 50];disk = Graphics[{GrayLevel[.45], Disk[]}]ClusteringTree[data, VertexSize -> 0.2, VertexShape -> disk]ClusteringTree[data, GraphLayout -> "RadialEmbedding"]从三维向量列表获取聚类层次结构并用相应元素的总和作为叶的标记:
r = RandomReal[1, {7, 3}];g = ClusteringTree[r -> Total /@ r]ClusteringTree[Total /@ r]data = RandomSample[Range[3, 10], 6];g = ClusteringTree[data]labels = Graphics[{Blue, RegularPolygon[#]}, ImageSize -> 20]& /@ datag = ClusteringTree[data -> labels]选项 (9)
ClusterDissimilarityFunction (1)
data = RandomColor[80]通过使用 "Centroid" 的关联获取列表的聚类层次结构:
ClusteringTree[data, ClusterDissimilarityFunction -> "Centroid"]ClusteringTree[data, ClusterDissimilarityFunction -> "Single"]使用不同的 "ClusterDissimilarityFunction" 获取列表的聚类层次结构:
ClusteringTree[data, ClusterDissimilarityFunction -> (Max[#]&)]DistanceFunction (1)
data = RandomReal[{10, 20}, {10, 2}];使用一个不同的 DistanceFunction 获取聚类层次结构:
ClusteringTree[data, DistanceFunction -> ManhattanDistance]ClusteringTree[data, DistanceFunction -> ChessboardDistance]FeatureExtractor (1)
flowers = { [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image]};ClusteringTree[flowers]使用不同的 FeatureExtractor 提取特征:
fe = FeatureExtraction[flowers, "ImageFeatures"]ClusteringTree[flowers, FeatureExtractor -> fe]使用 Identity FeatureExtractor 保持数据不变:
ClusteringTree[flowers, FeatureExtractor -> Identity]ImageSize (2)
ClusteringTree[{1, 2, 5}, ImageSize -> Tiny]ClusteringTree[{1, 2, 5}, ImageSize -> {300, 150}]//Framed明确设置 ImageSize 和 AspectRatio:
ClusteringTree[{1, 2, 5}, ImageSize -> {300, 150}, AspectRatio -> 150 / 300]VertexLabelStyle (4)
ClusteringTree[{3, 3, 5, 4, 7, 7}, VertexLabelStyle -> Large]ClusteringTree[{3, 3, 5, 4, 7, 7}, VertexLabelStyle -> Red]ClusteringTree[{3, 3, 5, 4, 7, 7}, VertexLabelStyle -> Directive[Purple, Italic, 40]]有些表达式,如图像,不受 FontSize 的影响:
images = {[image], [image], [image], [image]};ClusteringTree[images, VertexLabelStyle -> Tiny, ImageSize -> Small]用 Magnification 作用于每种类型的表达式:
ClusteringTree[images, VertexLabelStyle -> Directive[Magnification -> .3], ImageSize -> Small]labels = ColorConvert[ImageResize[#, {Automatic, 40}], "Grayscale"]& /@ imagesClusteringTree[images -> labels, ImageSize -> Small]文本
Wolfram Research (2016),ClusteringTree,Wolfram 语言函数,https://reference.wolfram.com/language/ref/ClusteringTree.html (更新于 2017 年).
CMS
Wolfram 语言. 2016. "ClusteringTree." Wolfram 语言与系统参考资料中心. Wolfram Research. 最新版本 2017. https://reference.wolfram.com/language/ref/ClusteringTree.html.
APA
Wolfram 语言. (2016). ClusteringTree. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/ClusteringTree.html 年
BibTeX
@misc{reference.wolfram_2026_clusteringtree, author="Wolfram Research", title="{ClusteringTree}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/ClusteringTree.html}", note=[Accessed: 14-September-2026]}
BibLaTeX
@online{reference.wolfram_2026_clusteringtree, organization={Wolfram Research}, title={ClusteringTree}, year={2017}, url={https://reference.wolfram.com/language/ref/ClusteringTree.html}, note=[Accessed: 14-September-2026]}