Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Online ml River Metrics Recall

From Leeroopedia


Knowledge Sources
Domains Online_Learning, Evaluation_Metrics
Last Updated 2026-02-08 16:00 GMT

Overview

Recall metrics measuring the proportion of actual positives that are correctly identified.

Description

This module provides recall (sensitivity/true positive rate) metrics that compute TP / (TP + FN), the fraction of actual positives correctly identified. It includes Recall (binary), MacroRecall (unweighted average across classes), MicroRecall (global recall from aggregated counts, equivalent to MicroPrecision), and WeightedRecall (weighted by class support, equivalent to accuracy). Recall answers "Of all actual positives, how many did we find?"

Usage

Use Recall when false negatives are particularly costly in your application. High recall means few missed positives. Choose MacroRecall for equal per-class treatment, MicroRecall for overall performance, or WeightedRecall when accounting for class frequency. Recall is critical in scenarios like disease screening or fraud detection where missing positive cases has serious consequences.

Code Reference

Source Location

Signature

class Recall(metrics.base.BinaryMetric):
    def __init__(self, cm=None, pos_val=True):
        pass

class MacroRecall(metrics.base.MultiClassMetric):
    def __init__(self, cm=None):
        pass

class MicroRecall(metrics.MicroPrecision):
    # Inherits from MicroPrecision as they are equivalent
    def __init__(self, cm=None):
        pass

class WeightedRecall(metrics.base.MultiClassMetric):
    def __init__(self, cm=None):
        pass

Import

from river import metrics

I/O Contract

Method Parameters Returns Description
update y_true, y_pred, [w] None Updates metric with true and predicted labels
get - float Returns recall score (0.0 to 1.0)

Usage Examples

from river import metrics

# Binary Recall
y_true = [True, False, True, True, True]
y_pred = [True, True, False, True, True]

metric = metrics.Recall()

for yt, yp in zip(y_true, y_pred):
    metric.update(yt, yp)
    print(metric)
# Recall: 100.00%
# Recall: 100.00%
# Recall: 50.00%
# Recall: 66.67%
# Recall: 75.00%

# High recall (75%) means we found most of the actual positives
# Only 1 false negative out of 4 actual positives

# Multi-class Macro Recall (average per class)
y_true = [0, 1, 2, 2, 2]
y_pred = [0, 0, 2, 2, 1]

metric_macro = metrics.MacroRecall()
for yt, yp in zip(y_true, y_pred):
    metric_macro.update(yt, yp)
    print(metric_macro)
# MacroRecall: 100.00%
# MacroRecall: 50.00%
# MacroRecall: 66.67%
# MacroRecall: 66.67%
# MacroRecall: 55.56%

# Multi-class Micro Recall (equivalent to MicroPrecision)
metric_micro = metrics.MicroRecall()
for yt, yp in zip([0, 1, 2, 2, 2], [0, 0, 2, 2, 1]):
    metric_micro.update(yt, yp)
    print(metric_micro)
# MicroRecall: 100.00%
# MicroRecall: 50.00%
# MicroRecall: 66.67%
# MicroRecall: 75.00%
# MicroRecall: 60.00%

# Multi-class Weighted Recall (equivalent to Accuracy)
metric_weighted = metrics.WeightedRecall()
for yt, yp in zip([0, 1, 2, 2, 2], [0, 0, 2, 2, 1]):
    metric_weighted.update(yt, yp)

print(metric_weighted)
# WeightedRecall: 60.00%

# Note: Precision-Recall tradeoff
# High precision with low recall: few false positives, many false negatives
# Low precision with high recall: many false positives, few false negatives
# Balance with F1 score or adjust classification threshold

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment