예제 #1
0
def buildmshidistance(snb, cog_p, inh_p, output1, input_v1):
    show_panel = snb.show_panel
    aa = ValidateDoubleLoop.outer_level_loop(cog_p, inh_p, output1, input_v1)
    yy = np.array(aa)
    y = yy[0]
    m = np.array(output1)
    n = len(m)
    d = ms.mashidistance(y, n, m)
    d1 = zi.Orang(d, len(d))

    show_panel = snb.show_panel
    grid = snb.grid_out
    grid.CreateGrid(1, 13)
    grid.SetRowLabelValue(0, '马氏距离')
    grid.SetRowLabelAlignment(horiz=wx.ALIGN_TOP, vert=wx.ALIGN_TOP)
    for i in range(13):
        grid.SetColLabelValue(i, '%d' % (i + 1))
        if (i < len(d)):
            grid.SetCellValue(0, i, str(round(d[i], 3)))

    axes = snb.axes
    axes2 = snb.axes2
    canvas = snb.canvas
    canvas2 = snb.canvas2
    axes.clear()
    #  lpred, = axes.plot(y_pred, 'r', label='predict value')
    # ltest, = axes.plot(y_test, 'g', label='real value')
    print "========================"
    x = []
    for i in range(len(d)):
        x.append(float(str(round(d[i], 8))))
    print x
    print "========================"
    d = x
    axes.boxplot(d)
    axes.set(ylabel='Markov distance', title='Simulation of Markov distance')

    axes2.set(ylabel='Markov distance', title='data analysis')
    name_list = ['sum', 'var', '1/4', '3/4', 'median']
    axes2.bar(range(len(d1)),
              d1,
              color='black',
              tick_label=name_list,
              width=0.6)

    # axes.legend(handles=[lpred, ltest], labels=['predict value', 'real value'])
    canvas.draw()
    canvas2.draw()
    show_panel.SetupScrolling()
    show_panel.Layout()
예제 #2
0
def figure_kl(y, m):
    plt.figure("4")
    KL = KLdistanse(y, m)
    if len(KL) == 1:
        x = [1]
        plt.title("KL")
        plt.bar(x, KL, color='black', tick_label=x)
        plt.show()

    if len(KL) == 2:
        x = [1, 2]
        plt.title("KL")
        plt.bar(x, KL, 0.1, color='black', tick_label=x)
        plt.xlabel("X-output")
        plt.ylabel("Y-kl")
        plt.show()

    if len(KL) == 3:
        x = [1, 2, 3]
        plt.title("KL")
        plt.bar(x, KL, 0.1, color='black', tick_label=x)
        plt.xlabel("X-output")
        plt.ylabel("Y-kl")
        plt.xlabel("X-output")
        plt.ylabel("Y-kl")
        plt.show()

    if len(KL) == 4:
        x = [1, 2, 3, 4]
        plt.title("KL")
        plt.bar(x, KL, 0.1, color='black', tick_label=x)
        plt.xlabel("X-output")
        plt.ylabel("Y-kl")
        plt.show()

    if len(KL) > 4:
        ax9 = plt.subplot(221)  #在图表2中创建子图1
        s2 = pd.Series(np.array(KL))
        data1 = pd.DataFrame({"KL": s2})
        plt.title("KL")
        num_list5 = zi.Orang(KL, len(KL))
        data1.boxplot()  # 这里,pandas自己有处理的过程,很方便哦。
        ax10 = plt.subplot(222)
        name_list = ['sum', 'var', '1/4', '3/4', 'median']
        plt.title("data")
        plt.bar(range(len(num_list5)),
                num_list5,
                color='black',
                tick_label=name_list)
        plt.show()
예제 #3
0
def figure_mh(y,n,m):
 plt.figure("6")
 ax3=plt.subplot(221)#在图表2中创建子图1
 d2 = manhadundistance(y,n,m)   #调用曼哈顿距离公式y 是仿真数据  m样本数据 n 样本数据个数
 s3 = pd.Series(np.array(d2))
 data2 = pd.DataFrame({"Simulation of Manhattan distance": s3})
 plt.title("Manhattan distance")
 data2.boxplot()
 ax4=plt.subplot(222)
# make a histogram of the data array
 num_list2 = zi.Orang(d2,len(d2))
 name_list = ['sum','std','1/4','3/4','median']
 plt.title("data")
 plt.bar(range(len(num_list2)), num_list2,color='black',tick_label=name_list)
 plt.show()
예제 #4
0
def figure_qbxf(y, n, m):
    plt.figure("7")
    ax5 = plt.subplot(221)  #在图表2中创建子图1
    d3 = qiebixuefudistance(y, n, m)
    s5 = pd.Series(np.array(d3))
    data3 = pd.DataFrame({"Simulation of Chebyshev distance": s5})
    plt.title("Chebyshev distance")
    data3.boxplot()
    ax6 = plt.subplot(222)
    # make a histogram of the data array
    num_list3 = zi.Orang(d3, len(d3))
    name_list = ['sum', 'var', '1/4', '3/4', 'median']
    plt.title("data")
    plt.bar(range(len(num_list3)),
            num_list3,
            color='black',
            tick_label=name_list)
    plt.show()
예제 #5
0
def figure_ms(y, n, m):
    plt.figure("8")
    d4 = mashidistance(y, n, m)
    ax7 = plt.subplot(221)  #在图表2中创建子图1
    s7 = pd.Series(np.array(d4))
    data4 = pd.DataFrame({"Simulation of Markov distance": s7})
    plt.title("Markov distance")
    data4.boxplot()
    ax8 = plt.subplot(222)
    # make a histogram of the data array
    num_list4 = zi.Orang(d4, len(d4))
    name_list = ['sum', 'var', '1/4', '3/4', 'median']
    plt.title("data")
    plt.bar(range(len(num_list4)),
            num_list4,
            color='black',
            tick_label=name_list)
    plt.show()
예제 #6
0
def figure_ou(y,n,m):
 plt.figure("5")
#plt.figure(2)#创建图表2
 d1 = oushidistance(y,n,m)


 ax1=plt.subplot(221)#在图表2中创建子图1
 s1 = pd.Series(np.array(d1))
 data1 = pd.DataFrame({"Simulation of Euclidean distance": s1})
#plt.ylabel("ylabel")
#plt.xlabel("xlabel")
 plt.title("Euclidean distance")
 data1.boxplot()  # 这里,pandas自己有处理的过程,很方便哦
 ax2=plt.subplot(222)
# make a histogram of the data array
 num_list1 = zi.Orang(d1,len(d1))
 name_list = ['sum','std','1/4','3/4','median']
 plt.title("data")
 plt.bar(range(len(num_list1)), num_list1,color='black',tick_label=name_list)
 plt.show()
 return d1