(values: Sequence[float])
| 236 | |
| 237 | if scoring == "f1": |
| 238 | tp = sum(w for y, p, w in zip(y_true, pred, weights) if y > 0.5 and p > 0.5) |
| 239 | fp = sum(w for y, p, w in zip(y_true, pred, weights) if y <= 0.5 and p > 0.5) |
| 240 | fn = sum(w for y, p, w in zip(y_true, pred, weights) if y > 0.5 and p <= 0.5) |
| 241 | precision = tp / (tp + fp) if tp + fp > 0 else 0.0 |
| 242 | recall = tp / (tp + fn) if tp + fn > 0 else 0.0 |
| 243 | return 2.0 * precision * recall / (precision + recall) if precision + recall > 0 else 0.0 |
| 244 | |
| 245 | raise ValueError("scoring must be one of: neg_log_loss, accuracy, f1") |
| 246 |
no test coverage detected