Classification
F1 score
Implemented
classification.f1Definition
Harmonic mean of precision and recall.
Formula
F1 = 2 · Precision · Recall / (Precision + Recall) = 2TP / (2TP + FP + FN)
Range: [0, 1]
Inputs and outputs
- y_true: array of class labels
- y_pred: array of predicted labels
Returns: float or per-class array
Assumptions
- Multiclass and multilabel inputs require an explicit `average` (micro, macro, weighted, samples, or None).
Limitations
- Ignores true negatives.
- Macro, micro, and weighted averages can rank models differently.
Python API
import evalsuite as es
es.f1(y_true, y_pred, average="macro")References
- van Rijsbergen, C. J. (1979). Information Retrieval (2nd ed.). Butterworths.