I want to calculate the TNR. I am in a larger code project and we have this one binary classifier.
The major problem is that I don't find the information about the variables in the code.
What is the benign rate
, guesses
and ad rate
, guesses
? And to calculate the TNR of that?
I am guessing that the TNR is TNR = 2*benign_rate/len(y_hat)
.
y_hat = np.array([0, 1])
y_test = np.array([0, 1])
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:
acc = (benign_rate+ad_rate)/len(y_hat)
TP = 2*ad_rate/len(y_hat)
precision = ad_rate/ad_guesses
recall = round(100*TPR, 2)
TPR = 2 * ad_rate / len(y_hat)
TNR = 2*benign_rate/len(y_hat)
y_hat
) and true (y_test
) values, right? Then, TNR isnp.sum((y_hat == 0) & (y_test == 0)) / np.sum(y_test == 0)
. $\endgroup$