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:Evidentlyai Evidently Legacy Report

From Leeroopedia
Knowledge Sources
Domains ML Monitoring, Reporting
Last Updated 2026-02-14 12:00 GMT

Overview

Implements the legacy Report class, the primary entry point for running a collection of metrics against current and reference datasets and producing HTML, JSON, and DataFrame outputs.

Description

The Report class orchestrates the entire legacy metric pipeline. It accepts a list of metrics, metric presets, and generators, runs them against provided datasets, and produces renderable output in multiple formats.

Class: Report

Inherits from ReportBase and manages:

  • Initialization -- Accepts a list of Metric, MetricPreset, or BaseGenerator objects. Supports optional metadata (model_id, batch_size, reference_id, dataset_id), tags, options, and a name. Deprecated parameters (id, timestamp) emit warnings.
  • run() -- The main execution method. Keyword-only arguments:
    • reference_data -- Optional baseline dataset (pandas DataFrame or engine-specific type).
    • current_data -- Required current dataset.
    • column_mapping -- Optional ColumnMapping (defaults to empty mapping).
    • engine -- Optional engine class (defaults to PythonEngine).
    • additional_data -- Optional dict of extra data passed to presets.
    • timestamp -- Optional datetime for the report snapshot.
 The method:
 # Creates a new report ID and sets the timestamp.
 # Resets the internal Suite and sets the engine.
 # Computes the DataDefinition from the datasets and column mapping.
 # Iterates over the metrics list, expanding BaseGenerator objects and MetricPreset objects into concrete Metric instances.
 # Records generator and preset names in metadata.
 # Passes all metrics to the inner Suite and runs calculation via run_calculate().
  • as_dict() -- Serializes results to a dictionary. Each metric is rendered via its renderer's render_json(). Supports include/exclude field filtering and optional render data inclusion.
  • as_dataframe() -- Serializes results to pandas DataFrames. Returns a dict of DataFrames keyed by metric ID, or a single DataFrame if there is only one metric type. Supports filtering by metric group.
  • _build_dashboard_info() -- Builds the HTML dashboard. Iterates over metrics, calls each renderer's render_html(), sets source fingerprints, replaces widget IDs, and collects additional graph details. Returns a tuple of (dashboard element ID, DashboardInfo, additional graphs dict).
  • Metadata setters -- set_batch_size(), set_model_id(), set_reference_id(), set_dataset_id() for tagging reports.
  • Snapshot support -- _get_snapshot() captures the full report state. _parse_snapshot() restores a Report from a saved Snapshot, reconstructing the suite context and metric list.

Module-level constants:

  • METRIC_GENERATORS = "metric_generators" -- Metadata key for tracking generators.
  • METRIC_PRESETS = "metric_presets" -- Metadata key for tracking presets.

Usage

This is the main class users interact with to generate Evidently reports. Create a Report with desired metrics, call run() with data, then export via as_dict(), as_dataframe(), show() (HTML in notebooks), or save_html().

Code Reference

Source Location

Signature

class Report(ReportBase):
    metrics: List[Union[Metric, MetricPreset, BaseGenerator]]

    def __init__(
        self,
        metrics: List[Union[Metric, MetricPreset, BaseGenerator]],
        options: AnyOptions = None,
        timestamp: Optional[datetime] = None,
        id: SnapshotID = None,
        metadata: Dict[str, MetadataValueType] = None,
        tags: List[str] = None,
        model_id: str = None,
        reference_id: str = None,
        batch_size: str = None,
        dataset_id: str = None,
        name: str = None,
    ): ...

    def run(
        self,
        *,
        reference_data,
        current_data,
        column_mapping: Optional[ColumnMapping] = None,
        engine: Optional[Type[Engine]] = None,
        additional_data: Dict[str, Any] = None,
        timestamp: Optional[datetime] = None,
    ) -> None: ...

    def as_dict(
        self,
        include_render: bool = False,
        include: Dict[str, IncludeOptions] = None,
        exclude: Dict[str, IncludeOptions] = None,
        **kwargs,
    ) -> dict: ...

    def as_dataframe(self, group: str = None) -> Union[Dict[str, pd.DataFrame], pd.DataFrame]: ...

    def set_batch_size(self, batch_size: str) -> "Report": ...
    def set_model_id(self, model_id: str) -> "Report": ...
    def set_reference_id(self, reference_id: str) -> "Report": ...
    def set_dataset_id(self, dataset_id: str) -> "Report": ...

    @classmethod
    def _parse_snapshot(cls, snapshot: Snapshot) -> "Report": ...

Import

from evidently.legacy.report.report import Report

I/O Contract

Inputs

Name Type Required Description
metrics List[Union[Metric, MetricPreset, BaseGenerator]] Yes List of metrics, presets, or generators to include in the report.
reference_data pd.DataFrame (or engine-specific) No Baseline/reference dataset for comparison.
current_data pd.DataFrame (or engine-specific) Yes Current/production dataset to analyze.
column_mapping Optional[ColumnMapping] No Mapping of column roles (target, prediction, features, etc.). Defaults to empty mapping.
engine Optional[Type[Engine]] No Calculation engine class. Defaults to PythonEngine.
additional_data Dict[str, Any] No Extra data passed to metric presets during generation.
timestamp Optional[datetime] No Timestamp for the report snapshot.
options AnyOptions No Global options (color, data drift, rendering, etc.).
metadata Dict[str, MetadataValueType] No Arbitrary metadata to attach to the report.
tags List[str] No Tags for report categorization.

Outputs

Name Type Description
dict dict Via as_dict(): JSON-serializable dictionary with metric results.
DataFrame(s) Union[Dict[str, pd.DataFrame], pd.DataFrame] Via as_dataframe(): metric results as pandas DataFrames.
HTML dashboard str Via inherited show() or save_html(): rendered HTML report.
Snapshot Snapshot Via save(): serialized report state for persistence.

Usage Examples

import pandas as pd
from evidently.legacy.report.report import Report
from evidently.legacy.pipeline.column_mapping import ColumnMapping

# Assume some_metric and some_preset are already defined
# from evidently.legacy.metrics import SomeMetric
# from evidently.legacy.metric_preset import SomePreset

reference = pd.DataFrame({"feature": [1, 2, 3], "target": [0, 1, 0]})
current = pd.DataFrame({"feature": [4, 5, 6], "target": [1, 0, 1]})

mapping = ColumnMapping(target="target")

# Create and run the report
report = Report(
    metrics=[some_metric, some_preset],
    options=None,
    tags=["production", "v2"],
)
report.run(reference_data=reference, current_data=current, column_mapping=mapping)

# Export as dict
result_dict = report.as_dict()

# Export as DataFrame
result_df = report.as_dataframe()

# Render as HTML (in notebook)
# report.show()

# Save HTML to file
# report.save_html("report.html")

# Attach metadata
report.set_model_id("model_v2").set_batch_size("daily")

Related Pages

Page Connections

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