Skip to content
EvalSuite
Documentation menu

Classification

F1 score

Implementedclassification.f1

Definition

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

PythonSince v0.1.0
import evalsuite as es

es.f1(y_true, y_pred, average="macro")

References

  1. van Rijsbergen, C. J. (1979). Information Retrieval (2nd ed.). Butterworths.

Implementation status