Statistical note
Positive and negative likelihood ratios
Positive and negative likelihood ratios: theory, interpretation, Python computation, and a scientific-imaging case study.
A classification metric maps predictions and references to a task-specific utility or loss. Hard-label metrics use a decision threshold; score-based metrics evaluate ranking or probability quality.
Mathematical definition
The central quantity is
This expression states what is being counted, averaged, ranked, or compared. Its scale and direction must be interpreted in the context of the data and sampling design.
Compute it in Python
import numpy as np
from sklearn import metrics
y_true = np.array([0, 1, 1, 0, 1, 0])
y_pred = np.array([0, 1, 0, 0, 1, 1])
y_score = np.array([0.1, 0.9, 0.4, 0.2, 0.8, 0.7])
y_prob = y_score
print(metrics.class_likelihood_ratios(y_true, y_pred))
The function is sklearn.metrics.class_likelihood_ratios. Inspect its current signature and return object in the official documentation for the version installed in your environment.
Interpretation and cautions
No single metric is universally best. State the positive class, averaging rule, threshold, prevalence, and unit of analysis. Evaluate held-out acquisitions rather than augmented views of training specimens.
A numerical value is not self-interpreting. Compare it with a baseline, uncertainty interval, operational threshold, or competing model, and retain the underlying observations or confusion counts.
Scientific-imaging case study
For how evidence changes pre-test odds in a microscopy classifier, inspect per-experiment behavior and the underlying confusion counts before accepting the aggregate score.
Split train, validation, and test data at the specimen or experimental level. Report variability across independent repeats so that the metric describes generalization rather than leakage.