F1 weighs precision and recall equally. Sometimes that is wrong: a cancer screen must not miss cases (recall matters more), while a fraud alert that blocks good customers must not be noisy (precision matters more). F-beta lets you choose. beta > 1 leans toward recall and beta < 1 leans toward precision. beta = 1 gives F1.
Implement fbeta_score(y_true, y_pred, beta=1.0, positive=1) for binary labels.
0.0 when TP + FP is zero.0.0 when TP + FN is zero.0.0 when the denominator is zero.beta must be greater than zero, otherwise raise ValueError.Open one at a time. Each gives away a little more than the last.
Compute TP, FP, and FN from boolean masks on positive.
Compute b2 = beta ** 2 once, then use the formula with b2 in place of beta ** 2.
No results yet
Run your code to check it against the examples, or submit to run every test.