一、【问题描述】
假定有一组数据:
真实值:[“ant”, “bird”, “ant”, “cat”, “cat”,“cat”]
预测值:[“ant”, “cat”, “ant”, “cat”, “cat”,“ant”]
请给出precision_score(查准率)、confusion_matrix(混淆矩阵)和classification_report(显示主要分类指标的文本报告),用Python实现。
二、【问题解答】
代码:
# 假定有一组数据:
#真实值:["ant", "bird", "ant", "cat", "cat","cat"]
#预测值:["ant", "cat", "ant", "cat", "cat","ant"]
#请给出precision_score(查准率)、confusion_matrix(混淆矩阵)和classification_report(显示主要分类指标的文本报告),用Python实现。
import warnings
warnings.filterwarnings("ignore")
from sklearn