【分类评估指标,精确率,召回率,】from sklearn.metrics import classification_report

from: https://zhuanlan.zhihu.com/p/368196647

多分类

from sklearn.metrics import classification_report
y_true = [0, 1, 2, 2, 2]
y_pred = [0, 0, 2, 2, 1]
target_names = ['class 0', 'class 1', 'class 2']
# print(classification_report(y_true, y_pred, target_names=target_names))
print(classification_report(y_true, y_pred))

在这里插入图片描述

多标签分类

import numpy as np
from sklearn.metrics import classification_report

y_true = np.array([ [1, 0, 1, 0, 0],
                    [0, 1, 0, 1, 1],
                    [1, 1, 1, 0, 1]])
y_pred = np.array([[1, 0, 0, 0, 1],
                   [0, 1, 1, 1, 0],
                   [1, 1, 1, 0, 0]])
print(classification_report(y_true, y_pred, digits=3)) # digits=3, 3位小数

理解多标签分类中 micro avg, precision表示所有预测1中,对的个数,所以是/8;recall表示所有样本1中,对的个数,所以是/9

在这里插入图片描述

在这里插入图片描述

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-29 00:22:04       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-29 00:22:04       100 阅读
  3. 在Django里面运行非项目文件

    2024-03-29 00:22:04       82 阅读
  4. Python语言-面向对象

    2024-03-29 00:22:04       91 阅读

热门阅读

  1. 2020校招面试

    2024-03-29 00:22:04       43 阅读
  2. 程序员35岁会失业吗?

    2024-03-29 00:22:04       41 阅读
  3. 【MySQL】MySQL小结

    2024-03-29 00:22:04       36 阅读
  4. 详解 WebWorker 的概念、使用场景、示例

    2024-03-29 00:22:04       43 阅读
  5. ASTM D7032-21 木塑地板、踏板、围栏和扶手检测

    2024-03-29 00:22:04       40 阅读
  6. # Python 编程入门教程

    2024-03-29 00:22:04       51 阅读
  7. 多项式分布采样

    2024-03-29 00:22:04       40 阅读
  8. Rust编程(一)

    2024-03-29 00:22:04       44 阅读
  9. 细节之PyTorch 中的 torch.ones([])

    2024-03-29 00:22:04       41 阅读