Compute the micro-averaged F1 score for equal-length sequences of single-label multiclass predictions. First aggregate true positives, false positives, and false negatives across every class, then compute
F1,micro=2TP+FP+FN2TPHere, TP, FP, and FN are the totals across all classes. Return the score as a Python float rounded to four decimal places.
Input: y_true = [0, 1, 1], y_pred = [0, 1, 0]
Output: 0.6667
Explanation: Across all classes there are two true positives, one false positive, and one false negative.
Input: y_true = [0, 1, 2, 2], y_pred = [0, 1, 2, 2]
Output: 1.0
Input: y_true = [2, 2, 1, 0], y_pred = [1, 2, 1, 0]
Output: 0.75
sum(actual == predicted for actual, predicted in zip(y_true, y_pred)) counts correct single-label predictions.
For single-label multiclass data, every mismatch contributes one false positive and one false negative.
Sign in to take notes on this problem
Accepts: array
Accepts: array
Compute the micro-averaged F1 score for equal-length sequences of single-label multiclass predictions. First aggregate true positives, false positives, and false negatives across every class, then compute
F1,micro=2TP+FP+FN2TPHere, TP, FP, and FN are the totals across all classes. Return the score as a Python float rounded to four decimal places.
Input: y_true = [0, 1, 1], y_pred = [0, 1, 0]
Output: 0.6667
Explanation: Across all classes there are two true positives, one false positive, and one false negative.
Input: y_true = [0, 1, 2, 2], y_pred = [0, 1, 2, 2]
Output: 1.0
Input: y_true = [2, 2, 1, 0], y_pred = [1, 2, 1, 0]
Output: 0.75
sum(actual == predicted for actual, predicted in zip(y_true, y_pred)) counts correct single-label predictions.
For single-label multiclass data, every mismatch contributes one false positive and one false negative.
Sign in to take notes on this problem
Accepts: array
Accepts: array