简体   繁体   English

有没有办法用已知的真阳性、真阴性、假阳性和假阴性来绘制混淆矩阵?

[英]Is there a way to draw confusion matrix with known True Positive, True Negative, False Positive and False Negative?

Today I have finished processing some data and came to conclusion that I have the following final tables containing:今天我已经完成了一些数据的处理并得出结论,我有以下最终表格,其中包含:

Counts.计数。
True Positive真阳性 23070 23070
True Negative真阴性 4503 4503
False Positive假阳性 28 28
False Negative假阴性 34 34

I am trying to construct a confusion matrix here, scikit-learn.confusion_matrix style, but I cant figure out how.我正在尝试在这里构建一个混淆矩阵,scikit-learn.confusion_matrix 样式,但我不知道如何。 Can I use Matplotlib for this instead?我可以为此使用 Matplotlib 吗? Do you guys ever come to his type of quest?你们有没有来过他的任务类型? I believe we can draw it somehow.我相信我们可以以某种方式绘制它。 Thank you!谢谢!

With scikit-learn.confusion_matrix You can get the confusion matrix byscikit-learn.confusion_matrix你可以得到混淆矩阵
cm = confusion_matrix(y_true, y_pred)

And the confusion matrix is already in the form并且混淆矩阵已经是形式
TP|FN
FP|TN

You can use seaborn's heatmap to plot the data:您可以使用 seaborn 的热图到 plot 数据:

import seaborn as sns
sns.heatmap(cm, annot=True, cmap='Blues')

If you already have the data then try storing it in a list of list then plot the data using seaborn:如果您已经拥有数据,请尝试将其存储在列表列表中,然后使用 seaborn 将数据存储在 plot 中:

cm_data = [[23070, 34], [4503, 28]]
sns.heatmap(cm_data, annot=True, cmap='Blues', fmt='d')

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从混淆矩阵中获取假阴性、假阳性、真阳性和真阴性的相关数据集 - Getting relevant datasets of false negatives, false positives, true positive and true negative from confusion matrix True positive, False positive, False Negative 计算数据帧 python - True positive, False positive, False Negative calculation data frame python 哪个是哪个? (真阳性、真阴性、假阳性、假阴性) - Which one is which ? (True Positive, True Negative, False Positive, False Negative) Scikit-learn:如何获取True Positive、True Negative、False Positive和False Negative - Scikit-learn: How to obtain True Positive, True Negative, False Positive and False Negative 二元分类器只进行真阴性和假阳性预测 - Binary classifier making only making true negative and false positive predictions 如何查看混淆矩阵中标记为假阳性和假阴性的行 - How to view the rows marked as False Positive and False Negative from confusion matrix 如何从多类分类的混淆矩阵中提取假阳性,假阴性 - How to extract False Positive, False Negative from a confusion matrix of multiclass classification 混淆矩阵中的误报率 - False Positive Rate in Confusion Matrix filecmp.cmp()什么时候返回假阳性或假阴性? - When will filecmp.cmp() return a false positive or false negative? 如何计算误报率 (FPR) 和误报率百分比? - How to compute false positive rate (FPR) and False negative rate percantage?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM