Created
March 15, 2021 10:08
-
-
Save PranjalDureja0002/8d030d51a6ac5aa973613f2225caad77 to your computer and use it in GitHub Desktop.
model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def find_best_threshold(threshold, fpr, tpr): | |
t = threshold[np.argmax(tpr*(1-fpr))] | |
print("the maximum value of tpr*(1-fpr)", max(tpr*(1-fpr)), "for threshold", np.round(t,3)) | |
return t | |
def predict_with_best_t(proba, threshold): | |
predictions = [] | |
for i in proba: | |
if i>=threshold: | |
predictions.append(1) | |
else: | |
predictions.append(0) | |
return predictions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment