model_evaluator.py 文件源码

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

项目:johnson-county-ddj-public 作者: dssg 项目源码 文件源码
def plot_normalized_confusion_matrix_at_depth(self):
        """ Returns a normalized confusion matrix.

        :returns: normalized confusion matrix
        :rtype: matplotlib figure
        """
        cm = metrics.confusion_matrix(self.predictions['label'], self.y_pred)
        np.set_printoptions(precision = 2)
        fig = plt.figure()
        cm_normalized = cm.astype('float') / cm.sum(axis = 1)[:, np.newaxis]

        plt.imshow(cm_normalized, interpolation = 'nearest',
                   cmap = plt.cm.Blues)
        plt.title("Normalized Confusion Matrix")
        plt.colorbar()
        tick_marks = np.arange(len(self.labels))
        plt.xticks(tick_marks, self.labels, rotation = 45)
        plt.yticks(tick_marks, self.labels)
        plt.tight_layout()
        plt.ylabel('True label')
        plt.xlabel('Predicted label')
        return(fig)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号