首页 > 其他分享 >如何用Confusion matrix,classification report,ROC curve (AUC)分析一个二分类问题

如何用Confusion matrix,classification report,ROC curve (AUC)分析一个二分类问题

时间:2023-08-04 11:44:05浏览次数:33  
标签:25 AUC matrix classification positive negative TP predicted samples

ROC

https://zhuanlan.zhihu.com/p/246444894  

 

Sure, let's create a random confusion matrix as an example, and then I'll explain what each element in the matrix means:

Suppose we have a binary classification problem, where the true labels are as follows:

True Positive (TP) = 25
False Positive (FP) = 15
False Negative (FN) = 10
True Negative (TN) = 50

The corresponding confusion matrix would be:

```
Predicted Positive Predicted Negative
Actual Positive 25 (TP) 10 (FN)
Actual Negative 15 (FP) 50 (TN)
```

Let's now break down the elements of this confusion matrix:

1. **True Positive (TP)**:
The number of samples that are correctly predicted as positive (belonging to the positive class). In this example, we correctly predicted 25 positive instances.

2. **False Positive (FP)**:
The number of samples that are incorrectly predicted as positive, but they are actually negative (belonging to the negative class). In this example, we incorrectly predicted 15 negative instances as positive.

3. **False Negative (FN)**:
The number of samples that are incorrectly predicted as negative, but they are actually positive (belonging to the positive class). In this example, we incorrectly predicted 10 positive instances as negative.

4. **True Negative (TN)**:
The number of samples that are correctly predicted as negative (belonging to the negative class). In this example, we correctly predicted 50 negative instances.

Now, let's calculate some performance metrics using this confusion matrix:

- **Accuracy**:
Accuracy is the overall performance of the model and is calculated as the ratio of correctly predicted samples to the total number of samples.

Accuracy = (TP + TN) / (TP + TN + FP + FN) = (25 + 50) / (25 + 15 + 10 + 50) = 75 / 100 = 0.75 or 75%

- **Precision**:
Precision measures the proportion of true positive predictions among the total predicted positive samples. It is a measure of how many of the predicted positive instances are actually positive.

Precision = TP / (TP + FP) = 25 / (25 + 15) = 25 / 40 = 0.625 or 62.5%

- **Recall (Sensitivity)**:
Recall, also known as sensitivity or true positive rate, measures the proportion of true positive predictions among the actual positive samples. It is a measure of how many of the actual positive instances were correctly predicted.

Recall = TP / (TP + FN) = 25 / (25 + 10) = 25 / 35 = 0.714 or 71.4%

- **Specificity (True Negative Rate)**:
Specificity measures the proportion of true negative predictions among the actual negative samples. It is a measure of how many of the actual negative instances were correctly predicted.

Specificity = TN / (TN + FP) = 50 / (50 + 15) = 50 / 65 = 0.769 or 76.9%

These performance metrics provide insights into the model's ability to correctly classify positive and negative instances and overall accuracy. Different metrics may be more important depending on the specific use case and requirements.

如何利用classification_report评估模型的表现

https://www.python100.com/html/86808.html

标签:25,AUC,matrix,classification,positive,negative,TP,predicted,samples
From: https://www.cnblogs.com/chentianyu/p/17603787.html

相关文章

  • doubly block toeplitz matrix 在加速矩阵差卷积上的应用
    文档链接CNN的卷积是执行了\(w'_{i,j}=\sum\limits_{x,y}w_{i+x,j+y}\timesC_{x,y}\),有人认为每次平移卷积核,运算量很大,又是乘法又是加法。现在我们吧\(w_{x,y}\)展开形成一个\([n\timesm,1]\)的向量\(V\),然后构造一个大小为\([(n+1)\times(m+1),n\timesm]\)矩阵......
  • Matrix-writeup
    matrix信息收集只开放了80端口换了一个大一点的字典扫到了一个PHP页面此页面会将输入的内容显示在页面上,抓包之后可以看到他写入到了一个txt文件中那就可以把一句话写入到一个文件里再去连接连上哥斯拉在当前目录下找到一个flag,他提示要找密码以及一张图片找到这个......
  • 【模板】图的计数相关:行列式及求值、Matrix-Tree 定理、BEST 定理、LGV 引理
    归类为线性代数、图论。证明都是神仙,特别是名字带“理”的,不证了。行列式定义行列式(Determinant)是对\(n\)阶方阵\(A\)定义的,是一个标量。\(A\)的\(n\)阶行列式\(det(A)\)或\(|A|\)定义如下:\[det(A)=\sum_p(-1)^{\mu(p)}\prod_{i}A[i][p_i].\]这里将排列的逆序对数......
  • 题解 POJ3318【Matrix Multiplication】
    postedon2022-10-2119:56:08|under题解|sourceproblem判断三个\(n\timesn\)的矩阵是否满足\(A\timesB=C\),\(n\leq500\)。solution随机一个行向量\(v\)。若\(a\timesb=c\),则有\(v\timesa\timesb=v\timesc\)(不充分)。显然相乘复杂度仅为\(O(n^2)\)。类似于......
  • LeetCode 519. Random Flip Matrix 哈希Map
    Thereisanmxnbinarygridmatrixwithallthevaluesset0initially.Designanalgorithmtorandomlypickanindex(i,j)wherematrix[i][j]==0andflipsitto1.Alltheindices(i,j)wherematrix[i][j]==0shouldbeequallylikelytobereturne......
  • Paper Reading: Self-paced Ensemble for Highly Imbalanced Massive Data Classifica
    目录研究动机文章贡献分类硬度分布分类硬度的定义分类硬度的优点分类硬度视角下的样本类型本文方法自定步速欠采样硬度协调自定步速因子算法定义实验结果合成数据集实验数据集和实验设置合成数据实验结果类重叠下的鲁棒性真实数据集实验数据集和实验设置真实数据实验结果和重采样......
  • 时间序列转图像:相对位置矩阵(Relative Position Matrix)-Python版复现
    时间序列分类(TSC)在时间序列数据挖掘任务中备受关注,已经应用到各个领域。随着卷积神经网络(ConvolutionalNeuralNetwork,CNN)的迅速发展,基于卷积神经网络的TSC方法直到最近才开始出现。因此,提出了一个新的深度学习框架,使用相对位置矩阵(RelativePositionMatrix,RPM)和卷积神经......
  • 【树状数组】 POJ 2155 Matrix
    水水的二维树状数组,代码写搓了,找了好久的错。。。#include<iostream>#include<sstream>#include<algorithm>#include<vector>#include<queue>#include<stack>#include<map>#include<set>#include<bitset>#include<cst......
  • AHB协议理解2--AHBMatrix项目
    1.AHB协议中的burst传输bit、byte、word的联系1byte=8bit1word=2byte=16bit  注意:定长的burst传输期间,一直拉高HBUSREQx信号,目的是为了增加1次burst传输。不然仲裁器要根据仲裁算法把总线授权切换给其他主机了 2.(重中之重)AHB协议支持word和半字的读写,表现在haddr......
  • Japanese Student Championship 2021 F Max Matrix
    洛谷传送门AtCoder传送门我们考虑动态维护答案。如果已经知道上一步的答案,考虑计算这一次操作之后答案的变化。考虑现在有一个数列\(a_{1\simn}\),我们想知道\(\sum\limits_{i=1}^n\max(x,a_i)\)。计算出\(c=\sum\limits_{i=1}^n[a_i<x],s=\sum\limits_{i......