Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def f1_smart(y_true, y_pred):
- args = np.argsort(y_pred)
- tp = y_true.sum()
- fs = (tp - np.cumsum(y_true[args[:-1]])) / np.arange(y_true.shape[0] + tp - 1, tp, -1)
- res_idx = np.argmax(fs)
- return 2 * fs[res_idx], (y_pred[args[res_idx]] + y_pred[args[res_idx + 1]]) / 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement