def plot_confusion_matrix(targets, predictions, target_names,
title='Confusion matrix', cmap="Blues"):
"""Plot Confusion Matrix."""
cm = confusion_matrix(targets, predictions)
cm = 100 * cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]
df = pd.DataFrame(data=cm, columns=target_names, index=target_names)
g = sns.heatmap(df, annot=True, fmt=".1f", linewidths=.5, vmin=0, vmax=100,
cmap=cmap)
g.set_title(title)
g.set_ylabel('True label')
g.set_xlabel('Predicted label')
return g
viz.py 文件源码
python
阅读 21
收藏 0
点赞 0
评论 0
评论列表
文章目录