也就是说ABC: sadhcjsd是一个字符串,现在要提取出后边对吧? in_string = ABC: sadhcjsd 那么: in_string.split(':')[-1] 就是你想要的。
-- plt.annotate(cm[x, y], xy=(x, y)
++ plt.annotate(cm[x, y], xy=(y, x)
上述详细答案应该修改如上,要不然 pred, truth 方向就反了,
此外,还可参考:
http://scikit-learn.org/stable/auto_examples/model_selection/plot_confusion_matrix.html#sphx-glr-auto-examples-model-selection-plot-confusion-matrix-py