本文整理汇总了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)
示例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)
示例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
示例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
示例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)
示例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)