• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python hierarchy.maxdists函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: check_maxdists_Q_linkage

 def check_maxdists_Q_linkage(self, method):
     # Tests maxdists(Z) on the Q data set
     X = hierarchy_test_data.Q_X
     Z = linkage(X, method)
     MD = maxdists(Z)
     expectedMD = calculate_maximum_distances(Z)
     assert_allclose(MD, expectedMD, atol=1e-15)
开发者ID:abudulemusa,项目名称:scipy,代码行数:7,代码来源:test_hierarchy.py


示例2: check_maxdists_Q_linkage

 def check_maxdists_Q_linkage(self, method):
     # Tests maxdists(Z) on the Q data set
     X = eo['Q-X']
     Y = pdist(X)
     Z = linkage(X, method)
     MD = maxdists(Z)
     expectedMD = calculate_maximum_distances(Z)
     assert_allclose(MD, expectedMD, atol=1e-15)
开发者ID:FrankZhao66,项目名称:scipy,代码行数:8,代码来源:test_hierarchy.py


示例3: check_fcluster_monocrit

 def check_fcluster_monocrit(self, t, criterion):
     # Tests fcluster(Z, criterion='monocrit'/'maxclust_monocrit', t=t,
     # monicrit=maxdists(Z)) on a random 3-cluster data set.
     expectedT = np.int_(eo['fcluster-%s-%d' % (criterion, t)])
     X = eo['Q-X']
     Y = pdist(X)
     Z = linkage(Y)
     T = fcluster(Z, criterion=criterion, t=t, monocrit=maxdists(Z))
     assert_(is_isomorphic(T, expectedT))
开发者ID:FrankZhao66,项目名称:scipy,代码行数:9,代码来源:test_hierarchy.py


示例4: test_maxdists_one_cluster_linkage

 def test_maxdists_one_cluster_linkage(self):
     # Tests maxdists(Z) on linkage with one cluster.
     Z = np.asarray([[0, 1, 0.3, 4]], dtype=np.double)
     MD = maxdists(Z)
     expectedMD = calculate_maximum_distances(Z)
     assert_allclose(MD, expectedMD, atol=1e-15)
开发者ID:abudulemusa,项目名称:scipy,代码行数:6,代码来源:test_hierarchy.py


示例5: check_fcluster_maxclust_monocrit

 def check_fcluster_maxclust_monocrit(self, t):
     expectedT = hierarchy_test_data.fcluster_maxclust[t]
     Z = single(hierarchy_test_data.Q_X)
     T = fcluster(Z, t, criterion='maxclust_monocrit', monocrit=maxdists(Z))
     assert_(is_isomorphic(T, expectedT))
开发者ID:abudulemusa,项目名称:scipy,代码行数:5,代码来源:test_hierarchy.py


示例6: pdist

    ax.set_aspect(1./ax.get_data_ratio())

    #### figure 2 #####
    uniqueLabels = np.sort(np.unique(case1Labels))
    centroids = np.array([case1[np.where(case1Labels == i)[0],:].mean(axis=0) for i in uniqueLabels])

    fig = plt.figure()
    ax = fig.add_subplot(111)
    ncluster = 27
    y = pdist(centroids)
    method = 'centroid'#'average'
    z = hierarchy.linkage(y,'average')
    #t = hierarchy.fcluster(27,criterion='maxclust')

    ## computes the max distance between any cluster and ea non singleton cluster
    print 'max dists', hierarchy.maxdists(z)
    

    ## inconsistancy
    r = hierarchy.inconsistent(z)
    print 'r',r
    #print 'max inconsts', hierarchy.maxinconsts(z,r,i)
    print 'z',z
    #print 'blah', z[:,2] - np.array(z[1:,2].tolist()+[0])
    print z[:,2]
    print np.hstack([z[1:,2],[0]])
    levelDiffs = np.abs(z[:,2] - np.hstack([z[1:,2],[0]]))
    levelDiffMeans = z[:,2]# - 0.001 #np.hstack([z[1:,2],[0]]) / 2.0#z[:,2] + np.hstack([z[1:,2],[0]]) / 2.0

    print 'diffs',levelDiffs*100
    diffInds = np.argsort(levelDiffs)
开发者ID:ajrichards,项目名称:cytostream,代码行数:31,代码来源:SimulatedData3.py


示例7: plot_corr_cluster

def plot_corr_cluster(m, method=1, **kargs):
    sns.set_style('white')

    l = fst.linkage(m, method='average')

    if method == 1:
        # Threshold 1: MATLAB-like behavior
        t = 0.7*max(l[:, 2])
    elif method == 2:
        t = np.median(hierarchy.maxdists(l))
    elif method == 3:
        t= mquantiles(hierarchy.maxdists(l), prob=0.75)[0]
    else:
        raise RuntimeError('no such method')

    # Plot the clustermap
    # Save the returned object for further plotting
    mclust = sns.clustermap(m,
                            linewidths=0,
                            cmap=plt.get_cmap('RdBu'),
                            vmax=1,
                            vmin=-1,
                            row_linkage=l,
                            col_linkage=l,
                            **kargs)

    # Draw the threshold lines
    mclust.ax_col_dendrogram.hlines(t,
                                    0,
                                    m.shape[0]*10,
                                    colors='g',
                                    linewidths=2,
                                    zorder=1)
    mclust.ax_row_dendrogram.vlines(t,
                                    0,
                                    m.shape[0]*10,
                                    colors='g',
                                    linewidths=2,
                                    zorder=1)

    # Extract the clusters
    clusters = hierarchy.fcluster(l, t, 'distance')
    for c in set(clusters):
        # Retrieve the position in the clustered matrix
        index = [x for x in range(m.shape[0])
                 if mclust.data2d.columns[x] in m.index[clusters == c]]
        # No singletons, please
        if len(index) == 1:
            continue

        # Draw a rectangle around the cluster
        mclust.ax_heatmap.add_patch(
            patches.Rectangle(
                (min(index),
                 m.shape[0] - max(index) - 1),
                len(index),
                len(index),
                facecolor='none',
                edgecolor='g',
                lw=3)
        )

    plt.title('Cluster matrix')
开发者ID:luoq,项目名称:datatrek,代码行数:63,代码来源:visualization.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python hierarchy.num_obs_linkage函数代码示例发布时间:2022-05-27
下一篇:
Python hierarchy.linkage函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap