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
utils.py 文件源码
python
阅读 26
收藏 0
点赞 0
评论 0
评论列表
文章目录