如何从此代码中获取真实负利率?
How to get the True Negative Rate from this code?
我在一个更大的代码项目中,我们有一个二元分类器。我要计算TNR
主要问题是我没有在代码中找到有关变量的信息。
什么是benign rate
、guesses
和ad rate
、guesses
?并计算它的 TNR?
我猜 TNR 是 TNR = 2*benign_rate/len(y_hat)
.
y_hat = np.array([0, 1])
y_test = np.array([0, 1])
nr_not_detect_adv = 0
benign_rate = 0
benign_guesses = 0
ad_guesses = 0
ad_rate = 0
for i in range(len(y_hat)):
if y_hat[i] == 0:
benign_guesses += 1
if y_test[i] == 0:
benign_rate += 1
else:
ad_guesses += 1
if y_test[i] == 1:
ad_rate += 1
if y_test[i] == 1:
if y_hat[i] == 0:
nr_not_detect_adv +=1
acc = (benign_rate+ad_rate)/len(y_hat)
TP = 2*ad_rate/len(y_hat)
TNR = 2*benign_rate/len(y_hat)
precision = ad_rate/ad_guesses
recall = round(100*TPR, 2)
TPR = 2 * ad_rate / len(y_hat)
查看 for
循环,我猜变量的含义是:
y_hat
:预测标签
y_test
:基本事实
beningn_rate
:TN(真阴性)
benign_guesses
:TN + FN(漏报)
ad_rate
:TP(真阳性)
ad_guesses
:TP + FP(误报)
nr_not_detect_adv
: FN(是的,多余)
应修复这些行 (definitions):
TP = ad_rate
TNR = benign_rate/benign_guesses
precision = ad_rate/ad_guesses
recall = ad_rate / (ad_rate+nr_not_detect_adv)
TPR = recall
我在一个更大的代码项目中,我们有一个二元分类器。我要计算TNR
主要问题是我没有在代码中找到有关变量的信息。
什么是benign rate
、guesses
和ad rate
、guesses
?并计算它的 TNR?
我猜 TNR 是 TNR = 2*benign_rate/len(y_hat)
.
y_hat = np.array([0, 1])
y_test = np.array([0, 1])
nr_not_detect_adv = 0
benign_rate = 0
benign_guesses = 0
ad_guesses = 0
ad_rate = 0
for i in range(len(y_hat)):
if y_hat[i] == 0:
benign_guesses += 1
if y_test[i] == 0:
benign_rate += 1
else:
ad_guesses += 1
if y_test[i] == 1:
ad_rate += 1
if y_test[i] == 1:
if y_hat[i] == 0:
nr_not_detect_adv +=1
acc = (benign_rate+ad_rate)/len(y_hat)
TP = 2*ad_rate/len(y_hat)
TNR = 2*benign_rate/len(y_hat)
precision = ad_rate/ad_guesses
recall = round(100*TPR, 2)
TPR = 2 * ad_rate / len(y_hat)
查看 for
循环,我猜变量的含义是:
y_hat
:预测标签y_test
:基本事实beningn_rate
:TN(真阴性)benign_guesses
:TN + FN(漏报)ad_rate
:TP(真阳性)ad_guesses
:TP + FP(误报)nr_not_detect_adv
: FN(是的,多余)
应修复这些行 (definitions):
TP = ad_rate
TNR = benign_rate/benign_guesses
precision = ad_rate/ad_guesses
recall = ad_rate / (ad_rate+nr_not_detect_adv)
TPR = recall