ywjfx

1、展现混淆矩阵

import matplotlib.pyplot as plt
import itertools
def plot_confusion_matrix(cm, classes,
                          title=\'Confusion matrix\',
                          cmap=plt.cm.Blues):
    """
    This function prints and plots the confusion matrix.
   cm:混淆矩阵值
   classes:分类标签
  
""" plt.imshow(cm, interpolation=\'nearest\', cmap=cmap) plt.title(title) plt.colorbar() tick_marks = np.arange(len(classes)) plt.xticks(tick_marks, classes, rotation=0) plt.yticks(tick_marks, classes) thresh = cm.max() / 2. for i, j in itertools.product(range(cm.shape[0]), range(cm.shape[1])): plt.text(j, i, cm[i, j], horizontalalignment="center", color="white" if cm[i, j] > thresh else "black") plt.tight_layout() plt.ylabel(\'True label\') plt.xlabel(\'Predicted label\')

 

分类:

技术点:

相关文章:

  • 2021-08-14
  • 2022-01-09
  • 2021-11-24
  • 2021-07-20
  • 2021-08-24
  • 2021-08-24
  • 2021-08-05
  • 2021-05-05
猜你喜欢
  • 2021-08-14
  • 2021-09-27
  • 2021-08-24
  • 2021-08-14
相关资源
相似解决方案