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 Data Quality Metrics

From Leeroopedia
Knowledge Sources
Domains Metrics, Data Quality
Last Updated 2026-02-14 12:00 GMT

Overview

Provides data quality correlation metrics including column-level and dataset-level correlation matrix calculations using Pearson, Spearman, Kendall, and Cramer's V methods.

Description

The Data Quality Metrics module implements correlation analysis metrics that bridge from the legacy Evidently metric system to the modern metric framework. It contains the following key classes:

  • ColumnCorrelations -- A MetricContainer that generates correlation metrics for a specific column against all other columns. It automatically selects correlation methods based on column type: Pearson, Spearman, and Kendall for numerical columns, and Cramer's V for categorical columns. Its render method delegates to the legacy ColumnCorrelationsMetric for widget generation.
  • ColumnCorrelationMatrix -- A DataframeMetric that computes correlations between a specified column and all other columns using a given method (auto, pearson, spearman, kendall, or cramer_v). Returns a DataframeValue.
  • LegacyColumnCorrelationsCalculation -- A LegacyMetricCalculation subclass that bridges ColumnCorrelationMatrix to the legacy ColumnCorrelationsMetric. It extracts the correct correlation kind from the legacy result and produces DataframeValue outputs for both current and optional reference data.
  • DatasetCorrelations -- A MetricContainer that generates four CorrelationMatrix metrics (Pearson, Spearman, Kendall, Cramer's V) for the entire dataset. Its render method delegates to the legacy DatasetCorrelationsMetric.
  • CorrelationMatrix -- A DataframeMetric that computes pairwise correlations for all columns using a specified method.
  • LegacyDatasetCorrelationsCalculation -- A LegacyMetricCalculation subclass that bridges CorrelationMatrix to the legacy DatasetCorrelationsMetric.

The helper function _extract_render_tab extracts a specific correlation tab's widget from the legacy tabbed rendering output.

Usage

Use ColumnCorrelations when you need to analyze how a specific column relates to all other columns. Use DatasetCorrelations for a comprehensive correlation analysis of the entire dataset. Both can be included in Evidently reports and presets. Use the individual metric classes (ColumnCorrelationMatrix, CorrelationMatrix) for fine-grained control over specific correlation methods.

Code Reference

Source Location

Signature

class ColumnCorrelations(MetricContainer):
    column_name: str
    def generate_metrics(self, context: "Context") -> Sequence[MetricOrContainer]:
        ...
    def render(self, context, child_widgets=None) -> List[BaseWidgetInfo]:
        ...

class ColumnCorrelationMatrix(DataframeMetric):
    column_name: str
    kind: Literal["auto", "pearson", "spearman", "kendall", "cramer_v"] = "auto"

class LegacyColumnCorrelationsCalculation(LegacyMetricCalculation[...]):
    def legacy_metric(self) -> ColumnCorrelationsMetric:
        ...
    def calculate_value(self, context, legacy_result, render) -> Tuple[DataframeValue, Optional[DataframeValue]]:
        ...

class DatasetCorrelations(MetricContainer):
    def generate_metrics(self, context: "Context") -> Sequence[MetricOrContainer]:
        ...
    def render(self, context, child_widgets=None) -> List[BaseWidgetInfo]:
        ...

class CorrelationMatrix(DataframeMetric):
    kind: Literal["auto", "pearson", "spearman", "kendall", "cramer_v"] = "auto"

class LegacyDatasetCorrelationsCalculation(LegacyMetricCalculation[...]):
    def legacy_metric(self) -> DatasetCorrelationsMetric:
        ...
    def calculate_value(self, context, legacy_result, render) -> Tuple[DataframeValue, Optional[DataframeValue]]:
        ...

Import

from evidently.metrics.data_quality import (
    ColumnCorrelations,
    ColumnCorrelationMatrix,
    DatasetCorrelations,
    CorrelationMatrix,
)

I/O Contract

Inputs

Name Type Required Description
column_name str Yes (for ColumnCorrelations/ColumnCorrelationMatrix) Name of the column to compute correlations for
kind Literal["auto", "pearson", "spearman", "kendall", "cramer_v"] No Correlation method to use (default: "auto", which auto-selects based on column type)
context Context Yes Report context providing data definition and dataset access

Outputs

Name Type Description
ColumnCorrelations generate_metrics Sequence[MetricOrContainer] List of ColumnCorrelationMatrix metrics for appropriate correlation methods based on column type
DatasetCorrelations generate_metrics Sequence[MetricOrContainer] Four CorrelationMatrix metrics (pearson, spearman, kendall, cramer_v)
LegacyColumnCorrelationsCalculation result Tuple[DataframeValue, Optional[DataframeValue]] Current and optional reference correlation DataFrames
LegacyDatasetCorrelationsCalculation result Tuple[DataframeValue, Optional[DataframeValue]] Current and optional reference full-dataset correlation DataFrames

Usage Examples

from evidently.metrics.data_quality import ColumnCorrelations, DatasetCorrelations, ColumnCorrelationMatrix
from evidently.core.report import Report

# Analyze correlations for a specific column
report = Report(metrics=[
    ColumnCorrelations(column_name="age"),
])

# Analyze correlations for the entire dataset
report = Report(metrics=[
    DatasetCorrelations(),
])

# Use a specific correlation method for a single column
report = Report(metrics=[
    ColumnCorrelationMatrix(column_name="income", kind="spearman"),
])

Related Pages

Page Connections

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