def f2_score(output, target, threshold): output = (output > threshold) return fbeta_score(target, output, beta=2, average='samples')