NTT DATA evaluates binary classification outputs from AI solutions. Implement a custom F1-score metric from scratch using only basic Python arrays and arithmetic, without importing machine learning libraries.
Given two arrays, y_true and y_pred, containing binary labels, calculate the F1-score:
F1 = 2 * TP / (2 * TP + FP + FN)
Count true positives, false positives, and false negatives during one pass through the arrays. True negatives do not affect the F1-score. If the denominator is zero, return 0.0.
y_true and y_pred, with equal length. Each value is either 0 or 1.0.0 and 1.0.def binary_f1_score(y_true, y_pred):