当前位置: 首页>>代码示例>>Python>>正文


Python hierarchy.num_obs_linkage函数代码示例

本文整理汇总了Python中scipy.cluster.hierarchy.num_obs_linkage函数的典型用法代码示例。如果您正苦于以下问题:Python num_obs_linkage函数的具体用法?Python num_obs_linkage怎么用?Python num_obs_linkage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了num_obs_linkage函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_num_obs_linkage_4_and_up

 def test_num_obs_linkage_4_and_up(self):
     # Tests num_obs_linkage(Z) on linkage on observation sets between sizes
     # 4 and 15 (step size 3).
     for i in xrange(4, 15, 3):
         y = np.random.rand(i*(i-1)//2)
         Z = linkage(y)
         self.assertTrue(num_obs_linkage(Z) == i)
开发者ID:abudulemusa,项目名称:scipy,代码行数:7,代码来源:test_hierarchy.py

示例2: test_num_obs_linkage_multi_matrix

 def test_num_obs_linkage_multi_matrix(self):
     # Tests num_obs_linkage with observation matrices of multiple sizes.
     for n in xrange(2, 10):
         X = np.random.rand(n, 4)
         Y = pdist(X)
         Z = linkage(Y)
         self.assertTrue(num_obs_linkage(Z) == n)
开发者ID:abudulemusa,项目名称:scipy,代码行数:7,代码来源:test_hierarchy.py

示例3: __init__

 def __init__(self, Z, indices, leaf_labeller, node_labeller):
     self._Z = np.asarray(Z)
     self._n = sp_hierarchy.num_obs_linkage(self._Z)
     self._flat_ids = hierarchy.flatten_nodes(self._Z)
     self._embed_ids = hierarchy.embed_nodes(self._Z, indices)
     self._indices = indices
     self._leaf_labeller = leaf_labeller
     self._node_labeller = node_labeller
开发者ID:timbalam,项目名称:GroopM,代码行数:8,代码来源:cluster.py

示例4: isNoiseCluster

 def isNoiseCluster(self, Z):
     Z = np.asarray(Z)
     n = sp_hierarchy.num_obs_linkage(Z)
     flat_ids = hierarchy.flatten_nodes(Z)
     
     # Quality clusters have total contig length at least minSize (if
     # defined) or a number of contigs at least minPts (if defined)
     doMinSize = self._minSize is not None
     doMinPts = self._minPts is not None
     if not doMinSize and not doMinPts:
         return np.zeros(2*n-1, dtype=bool)
     if doMinSize:
         weights = np.concatenate((self._profile.contigLengths, np.zeros(n-1)))
         weights[n:] = hierarchy.maxscoresbelow(Z, weights, fun=operator.add)
         weights[n:] = weights[flat_ids+n]
         is_noise = weights < self._minSize   
     if doMinPts:
         is_below_minPts = np.concatenate((np.full(n, 1 < self._minPts, dtype=bool), Z[flat_ids, 3] < self._minPts))
         if doMinSize:
             is_noise = np.logical_and(is_noise, is_below_minPts)
         else:
             is_noise = is_below_minPts
             
     return is_noise
开发者ID:timbalam,项目名称:GroopM,代码行数:24,代码来源:cluster.py

示例5: test_num_obs_linkage_2x4

 def test_num_obs_linkage_2x4(self):
     # Tests num_obs_linkage(Z) on linkage over 3 observations.
     Z = np.asarray([[0, 1, 3.0, 2],
                     [3, 2, 4.0, 3]], dtype=np.double)
     self.assertTrue(num_obs_linkage(Z) == 3)
开发者ID:abudulemusa,项目名称:scipy,代码行数:5,代码来源:test_hierarchy.py

示例6: test_num_obs_linkage_1x4

 def test_num_obs_linkage_1x4(self):
     # Tests num_obs_linkage(Z) on linkage over 2 observations.
     Z = np.asarray([[0, 1, 3.0, 2]], dtype=np.double)
     self.assertTrue(num_obs_linkage(Z) == 2)
开发者ID:abudulemusa,项目名称:scipy,代码行数:4,代码来源:test_hierarchy.py


注:本文中的scipy.cluster.hierarchy.num_obs_linkage函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。