utils.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:Iris-Classification-with-Heroku 作者: gaborvecsei 项目源码 文件源码
def plotPrediction(pred):
    """
    Plots the prediction than encodes it to base64
    :param pred: prediction accuracies
    :return: base64 encoded image as string
    """

    labels = ['setosa', 'versicolor', 'virginica']
    sns.set_context(rc={"figure.figsize": (5, 5)})
    with sns.color_palette("RdBu_r", 3):
        ax = sns.barplot(x=labels, y=pred)
    ax.set(ylim=(0, 1))

    # Base64 encode the plot
    stringIObytes = cStringIO.StringIO()
    sns.plt.savefig(stringIObytes, format='jpg')
    sns.plt.show()
    stringIObytes.seek(0)
    base64data = base64.b64encode(stringIObytes.read())
    return base64data
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号