Skip to content

Instantly share code, notes, and snippets.

@suhaskv
Created January 6, 2021 09:45
Show Gist options
  • Save suhaskv/576736f9545b972ec97814069c0fbfa4 to your computer and use it in GitHub Desktop.
Save suhaskv/576736f9545b972ec97814069c0fbfa4 to your computer and use it in GitHub Desktop.
VSB Power Line Blog - Best threshold selection
best_threshold = 0
best_score = 0
thresh_arr = np.linspace(0, 0.99, 100)
y_val = y_train
for thresh in thresh_arr:
preds_train_target = (preds_train_target_proba > thresh).astype(np.int).flatten()
score = matthews_corrcoef(y_val, preds_train_target)
if score > best_score:
best_threshold = thresh
best_score = score
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment