Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Evidentlyai Evidently ValueDrift Metric

From Leeroopedia
Knowledge Sources
Domains ML_Monitoring, Statistical_Testing
Last Updated 2026-02-14 12:00 GMT

Overview

Concrete metric for detecting data distribution drift in a single column provided by the Evidently library.

Description

ValueDrift is a column-level metric that computes a drift score by comparing the distribution of values in a specified column between reference and current datasets. It auto-selects the appropriate statistical test based on column type and dataset size, or accepts an explicit method override.

The metric returns a drift score (float) and a boolean drift detection result based on the threshold. It supports numerical, categorical, and text columns.

Usage

Import this metric when you need to detect drift in a specific column. Include it in a Report metrics list. Reference data is required.

Code Reference

Source Location

  • Repository: evidently
  • File: src/evidently/metrics/column_statistics.py
  • Lines: L527-543

Signature

class ValueDrift(ColumnMetric, SingleValueMetric):
    method: Optional[str] = None
    threshold: Optional[float] = None
    nbinsx: Optional[int] = None

Import

from evidently.metrics import ValueDrift

I/O Contract

Inputs

Name Type Required Description
column str Yes Column name to test for drift (inherited from ColumnMetric)
method Optional[str] No Drift detection method (auto-selected if None)
threshold Optional[float] No Drift threshold (method default if None)
nbinsx Optional[int] No Number of bins for distribution histogram

Outputs

Name Type Description
value float Drift score (method-dependent)
drift_detected bool Whether drift exceeds the threshold

Usage Examples

Basic Drift Detection

from evidently import Report, Dataset, DataDefinition
from evidently.metrics import ValueDrift

report = Report([
    ValueDrift(column="age"),
    ValueDrift(column="salary"),
    ValueDrift(column="department"),
])

snapshot = report.run(current_dataset, reference_dataset)
result = snapshot.dict()
# result["metrics"][0]["value"] contains drift score for "age"

With Explicit Method and Threshold

from evidently.metrics import ValueDrift

report = Report([
    ValueDrift(column="price", method="wasserstein", threshold=0.1),
    ValueDrift(column="category", method="chi-squared", threshold=0.05),
])

Related Pages

Implements Principle

Requires Environment

Uses Heuristic

Page Connections

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