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 ClassificationReport

From Leeroopedia
Revision as of 16:08, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Online_ml_River_Metrics_ClassificationReport.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


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

Overview

Comprehensive classification report displaying precision, recall, F1, and support for all classes with macro, micro, and weighted averages.

Description

ClassificationReport maintains and displays a comprehensive set of classification metrics in a tabular format. For each class, it shows precision, recall, F1 score, and support. It also computes macro (unweighted), micro (global), and weighted (by support) averages, along with overall accuracy. The report updates incrementally as new predictions arrive and can be printed at any time for a snapshot of model performance.

Usage

Use ClassificationReport when you need a comprehensive overview of multi-class classifier performance. It's particularly useful during model development and monitoring, providing at-a-glance insights into per-class and aggregate performance. The report can be wrapped with utils.Rolling or utils.TimeRolling to create windowed reports showing recent performance rather than cumulative statistics.

Code Reference

Source Location

Signature

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

Import

from river import metrics

I/O Contract

Method Parameters Returns Description
update y_true, y_pred, [w] None Updates all contained metrics
__repr__ - str Returns formatted classification report table

Note: The get() method is not implemented; use str() or print() to display the report.

Usage Examples

from river import metrics

y_true = ['pear', 'apple', 'banana', 'banana', 'banana']
y_pred = ['apple', 'pear', 'banana', 'banana', 'apple']

report = metrics.ClassificationReport()

for yt, yp in zip(y_true, y_pred):
    report.update(yt, yp)

print(report)
#                Precision   Recall   F1       Support
#
#    apple       0.00%    0.00%    0.00%         1
#   banana     100.00%   66.67%   80.00%         3
#     pear       0.00%    0.00%    0.00%         1
#
#    Macro      33.33%   22.22%   26.67%
#    Micro      40.00%   40.00%   40.00%
# Weighted      60.00%   40.00%   48.00%
#
#                  40.00% accuracy

# Custom decimals
report2 = metrics.ClassificationReport(decimals=3)
for yt, yp in zip(y_true, y_pred):
    report2.update(yt, yp)

print(report2)
# Shows 3 decimal places

# Windowed report (last 100 samples)
from river import utils

windowed_report = utils.Rolling(
    metrics.ClassificationReport(),
    window_size=100
)

# Update with streaming data
for yt, yp in stream_data:
    windowed_report.update(yt, yp)
    # Print shows metrics for last 100 samples only

# Time-based window (last 1 hour)
import datetime as dt

timed_report = utils.TimeRolling(
    metrics.ClassificationReport(),
    period=dt.timedelta(hours=1)
)

Related Pages

Page Connections

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