I want to calculate AUC / ROC curve without sklearn. I have:
tpr = true_positive / (true_positive + false_negative)
and
fpr = false_positive / (false_positive + true_negative)
tpr = 0.9537037037037037
fpr = 0.17300380228136883
my_roc_auc = auc(fpr, tpr)
I am getting error because there are only two floats but i need a matrix.
I have tried this method Manually calculate AUC but it does not work for me.
import pandas as pd
import numpy as np
import click as ck
from sklearn.metrics import roc_curve, auc
import matplotlib
matplotlib.use('Agg')
from matplotlib import pyplot as plt
from scipy.stats import spearmanr, pearsonr, wilcoxon, rankdata
plot_title = 'AUC alexnet'
plt.figure()
roc_auc = auc(fpr, tpr)
print(roc_auc)
plt.plot(
fpr,
tpr,
label='Real annotation ROC curve (area = %0.3f)' % roc_auc)
roc_auc = auc(fpr, tpr)
print(roc_auc)
plt.plot(
fpr,
tpr,
label='Only predictions ROC curve (area = %0.3f)' % roc_auc)
roc_auc = auc(fpr, tpr)
print(roc_auc)
plt.plot(
fpr,
tpr,
label='With predictions ROC curve (area = %0.3f)' % roc_auc)
plt.plot([0, 1], [0, 1], 'k--')
plt.xlim([0.0, 1.0])
plt.ylim([0.0, 1.05])
plt.xlabel('False Positive Rate')
plt.ylabel('True Positive Rate')
plt.title(plot_title)
plt.legend(loc="lower right")
So my question is: Can i calculate AUC / ROC only with tpr and fpr ? Thank you in advance