简体   繁体   English

TP、TN、FP 和 FN 的总数不等于观测值的总数

[英]Total number of TP, TN, FP & FN do not sum up to total number of observed values

I was going through the Classification on imbalanced data by TensorFlow. Here in this tutorial they have used Kaggle's Credit Card Fraud Detection .我正在阅读 TensorFlow 对不平衡数据的分类。在本教程中,他们使用了Kaggle 的信用卡欺诈检测 In this section you could see that the number of training examples are 182276 and number of validation samples are 45569 .节中,您可以看到训练样本的数量为182276验证样本的数量为45569 To evaluate the baseline model they have used Keras's inbuilt metrics - TruePositive, FalsePositive, TrueNegative, FalseNegative.为了评估基线 model,他们使用了 Keras 的内置指标——TruePositive、FalsePositive、TrueNegative、FalseNegative。

However if you look at the training logs in train the model section then you can see that the sum of FP+TP+FN+TN is not equal to number of training examples.但是,如果您查看训练model部分中的训练日志,您会发现 FP+TP+FN+TN 的总和不等于训练示例的数量。 Nor the sum is equal to number of validation examples for validation data.总和也不等于验证数据的验证示例数。

Part 1第1部分

EPOCH 1时代 1

TP = 64
FP = 25
TN = 139431.9780
FN = 188.3956
TP+FP+TN+FN = 139709.3736

The above sum is nowhere close to 182276. Same is true for all the subsequent epochs.上面的总和远不及 182276。所有后续时期也是如此。 Why is this the case?为什么会这样?

Part 2第2部分

As the number of epoch increases, the total sum decreases further.随着epoch数量的增加,总和进一步减少。 For example compare the values for epoch 2 and 1. EPOCH 2例如,比较纪元 2 和纪元 1 的值。纪元2

TP - 25
FP - 5.67
TN - 93973.1538
FN - 136.2967 
TP+FP+TN+FN = 94135.1205

The total sum is now reduced further by 45574. Same is true for epochs lower down the order.总和现在进一步减少了 45574。对于顺序较低的时代也是如此。

  1. Shouldn't the total sum be the same?总和不应该是一样的吗?
  2. If not then why does it keep on decreasing?如果不是那么为什么它继续减少?

Part 3第 3 部分

Why are the values for TP, FP, FN, TN in both training and validation floating numbers?为什么 TP、FP、FN、TN 的值在训练和验证中都是浮点数? As per my understanding these should always be integer. As per the explanation in the Understanding useful metrics the values represent count and should hence be integers.根据我的理解,这些值应该始终为 integer。根据理解有用指标中的解释,这些值表示计数,因此应该是整数。

I was going through the Classification on imbalanced data by TensorFlow.我正在通过 TensorFlow 对不平衡数据进行分类。 Here in this tutorial they have used Kaggle's Credit Card Fraud Detection .在本教程中,他们使用了Kaggle 的信用卡欺诈检测 In this section you could see that the number of training examples are 182276 and number of validation samples are 45569 .节中,您可以看到训练样本的数量为182276验证样本的数量为45569 To evaluate the baseline model they have used Keras's inbuilt metrics - TruePositive, FalsePositive, TrueNegative, FalseNegative.为了评估基线 model,他们使用了 Keras 的内置指标——TruePositive、FalsePositive、TrueNegative、FalseNegative。

However if you look at the training logs in train the model section then you can see that the sum of FP+TP+FN+TN is not equal to number of training examples.但是,如果您查看train model部分中的训练日志,您会发现 FP+TP+FN+TN 的总和不等于训练示例的数量。 Nor the sum is equal to number of validation examples for validation data.总和也不等于验证数据的验证示例数。

Part 1第1部分

EPOCH 1纪元 1

TP = 64
FP = 25
TN = 139431.9780
FN = 188.3956
TP+FP+TN+FN = 139709.3736

The above sum is nowhere close to 182276. Same is true for all the subsequent epochs.上述总和远不接近 182276。所有后续时期也是如此。 Why is this the case?为什么会这样?

Part 2第2部分

As the number of epoch increases, the total sum decreases further.随着 epoch 数量的增加,总和进一步减少。 For example compare the values for epoch 2 and 1. EPOCH 2例如,比较 epoch 2 和 1 的值。EPOCH 2

TP - 25
FP - 5.67
TN - 93973.1538
FN - 136.2967 
TP+FP+TN+FN = 94135.1205

The total sum is now reduced further by 45574. Same is true for epochs lower down the order.现在总和进一步减少了 45574。对于低阶的时期也是如此。

  1. Shouldn't the total sum be the same?总和不应该一样吗?
  2. If not then why does it keep on decreasing?如果不是那么为什么它会继续下降?

Part 3第 3 部分

Why are the values for TP, FP, FN, TN in both training and validation floating numbers?为什么训练和验证中 TP、FP、FN、TN 的值都是浮点数? As per my understanding these should always be integer.根据我的理解,这些应该始终是 integer。 As per the explanation in the Understanding useful metrics the values represent count and should hence be integers.根据理解有用指标中的解释,这些值表示计数,因此应该是整数。

I was experiencing a similar issue for me the sum of TP, TN, FP, and FN doubled each epoch and were non integers.我遇到了类似的问题,TP、TN、FP 和 FN 的总和在每个时期翻了一番,并且不是整数。 my solution was that my model was built using tensor flows keras but I imported keras directly.我的解决方案是我的 model 是使用张量流 keras 构建的,但我直接导入了 keras。

so instead of所以而不是

import keras

use采用

from tensorflow import keras

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM