有没有办法在Python中绘制圆形图表(作为目标)?

时间:2018-01-02 22:33:26

标签: python plot artificial-intelligence

我正在建立一个人工神经网络,我实施了K折交叉验证,通过这些方法返回的精度的均值和方差来评估模型。

现在我想绘制四个圆形图表(作为目标)来“说明”模型所在的偏差 - 方差权衡的类别,具体取决于方差和准确度的值。

有一种方法可以在Python中执行此操作吗?

1 个答案:

答案 0 :(得分:1)

我写了一个简单的例子

import numpy as np    
import matplotlib.mlab as mlab    
import matplotlib.pyplot as plt  


labels = ['USA', 'China', 'India', 'Japan', 'Germany', 'Russia', 'Brazil', 'UK', 'France', 'Italy']

quants = [15094025.0, 11299967.0, 4457784.0, 4440376.0, 3099080.0, 2383402.0, 2293954.0, 2260803.0, 2217900.0, 1846950.0]
def draw_pie(labels,quants):

    plt.figure(1, figsize=(6,6))

    # For China, make the piece explode a bit

    expl = [0,0.1,0,0,0,0,0,0,0,0]

    # Colors used. Recycle if not enough.

    colors  = ["blue","red","coral","green","yellow","orange"]

    # autopct: format of "percent" string;

    plt.pie(quants, explode=expl, colors=colors, labels=labels, 
    autopct='%1.1f%%',pctdistance=0.8, shadow=True)

    plt.title('Top 10 GDP Countries', bbox={'facecolor':'0.8', 'pad':5})

    plt.show()

draw_pie(labels,quants)

enter image description here