Created
June 2, 2022 18:38
-
-
Save kusal1990/b6ccddd1fb15727440ea87cad55b6c12 to your computer and use it in GitHub Desktop.
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 threshold_search(y_true, y_proba): | |
best_threshold = 0 | |
best_score = 0 | |
for threshold in tqdm([i * 0.01 for i in range(100)]): | |
score = K.eval(matthews_correlation(y_true.astype(np.float64), (y_proba > threshold).astype(np.float64))) | |
if score > best_score: | |
best_threshold = threshold | |
best_score = score | |
search_result = {'threshold': best_threshold, 'matthews_correlation': best_score} | |
return search_result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ok