【问题标题】:How can plot Results of the Friedman-Nemenyi test using python如何使用 python 绘制 Friedman-Nemenyi 测试的结果
【发布时间】:2017-09-09 00:54:02
【问题描述】:

我计算了 12 个数据集和 11 个分类器的 Friedman-Nemenyi 检验结果,我想绘制如下图所示的结果

我计算了所有的需求CD是单个数字(图中显示为CD),分类器列表(C4.5+m+cf,C4.5+m等)和平均排名值(在x 轴)

在此先感谢

2:enter link description here

【问题讨论】:

    标签: python python-3.x matplotlib


    【解决方案1】:
    import Orange
    import matplotlib.pyplot as plt
    names = ["first", "third", "second", "fourth" ]
    avranks =  [1.9, 3.2, 2.8, 3.3 ]
    cd = Orange.evaluation.compute_CD(avranks, 30) #tested on 30 datasets
    Orange.evaluation.graph_ranks(avranks, names, cd=cd, width=6, textspace=1.5)
    plt.show()
    

    【讨论】:

    • 橙色站点的代码。
    【解决方案2】:

    为了重现上面的情节,您可以将普通情节的 3 个刺设置为不可见,然后将相应的元素添加到情节中。

    import matplotlib.pyplot as plt
    
    # input data
    cd = 1.2
    c = 3.2
    ccf = 2.8
    cmcf = 1.9
    cm = 2.05
    
    limits=(4,1)
    
    fig, ax = plt.subplots(figsize=(5,1.8))
    plt.subplots_adjust(left=0.2, right=0.8)
    
    # set up plot
    ax.set_xlim(limits)
    ax.set_ylim(0,1)
    ax.spines['top'].set_position(('axes', 0.6))
    #ax.xaxis.tick_top()
    ax.xaxis.set_ticks_position('top')
    ax.yaxis.set_visible(False)
    for pos in ["bottom", "left", "right"]:
        ax.spines[pos].set_visible(False)
    
    # CD bar
    ax.plot([limits[0],limits[0]-cd], [.9,.9], color="k")
    ax.plot([limits[0],limits[0]], [.9-0.03,.9+0.03], color="k")
    ax.plot([limits[0]-cd,limits[0]-cd], [.9-0.03,.9+0.03], color="k") 
    ax.text(limits[0]-cd/2., 0.92, "CD", ha="center", va="bottom") 
    
    # annotations
    bbox_props = dict(boxstyle="square,pad=0.3", fc="w", ec="k", lw=0.72)
    arrowprops=dict(arrowstyle="-",connectionstyle="angle,angleA=0,angleB=90")
    kw = dict(xycoords='data',textcoords="axes fraction",
              arrowprops=arrowprops, bbox=bbox_props, va="center")
    ax.annotate("C4.5", xy=(c, 0.6), xytext=(0,0.25),ha="right",  **kw)
    ax.annotate("C4.5+cf", xy=(ccf, 0.6), xytext=(0,0),ha="right",  **kw)
    ax.annotate("C4.5+m+cf", xy=(cmcf, 0.6), xytext=(1.,0.25),ha="left",  **kw)
    ax.annotate("C4.5+m", xy=(cm, 0.6), xytext=(1.,0),ha="left",  **kw)
    
    #bars
    ax.plot([ccf,c],[0.55,0.55], color="k", lw=3)
    ax.plot([ccf,cmcf],[0.48,0.48], color="k", lw=3)
    
    plt.show()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-01-05
      • 1970-01-01
      • 1970-01-01
      • 2017-04-20
      • 1970-01-01
      • 2019-02-11
      • 2017-12-13
      • 1970-01-01
      相关资源
      最近更新 更多