MCPcopy Create free account
hub / github.com/PaddlePaddle/Research / run

Method run

ST_DM/GenRegion/src/generate/gen/cluster.py:462–490  ·  view source on GitHub ↗

Desc: 层次聚类算法的实现 Args: self : self points : 所有的点 Return: list of clusters Raise: None

(self, points)

Source from the content-addressed store, hash-verified

460 self.grids = {}
461
462 def run(self, points):
463 """
464 Desc: 层次聚类算法的实现
465 Args:
466 self : self
467 points : 所有的点
468 Return:
469 list of clusters
470 Raise:
471 None
472 """
473 # 每个点构建一个HCCluster
474 self.build_clusters(points)
475 # 构建点与点之间的friend关系
476 self.build_friends()
477 # 深度优先merge
478 merge_count = 1
479 while merge_count > 0:
480 merge_count = 0
481 for hc in self.hcclusters:
482 if not hc.is_empty():
483 if hc.bfs_merge(self.width):
484 merge_count += 1
485 # 从中间结果中得出最终的聚类结果
486 ret = []
487 for hc in self.hcclusters:
488 if not hc.is_empty():
489 ret.append(hc)
490 return ret
491
492 def build_clusters(self, points):
493 """

Callers 1

rect_clusterFunction · 0.95

Calls 5

build_clustersMethod · 0.95
build_friendsMethod · 0.95
bfs_mergeMethod · 0.80
is_emptyMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected