I have use this pice of code below which returns a set of tpr , fpr and their associated thresholds. Now I would like to have the corresponding tpr and fpr for any arbitrary threshold. Probably I need to do an interpolation. Can anyone help me?
from sklearn import metrics
fpr, tpr, thresholds = metrics.roc_curve(label, probability)
Now what I need is given threshold=0.122 what are the corresponding tpr and fpr for this roc curve?
Here we can use the interpolation function:
from scipy import interpolate
from sklearn import metrics
fpr, tpr, thresholds = metrics.roc_curve(label, probability)
tpr_intrp = interpolate.interp1d(thresholds, tpr)
fpr_intrp= interpolate.interp1d(thresholds, fpr)
print(tpr_intrp(0.122))
results in the interpolated value of tpr for this certain threshold 0.122.