Skip to content

Comments

Fix Groupby display name for Valuedrift metrics#1785

Open
Sudharsan-T wants to merge 1 commit intoevidentlyai:mainfrom
Sudharsan-T:fix-groupby-display-name
Open

Fix Groupby display name for Valuedrift metrics#1785
Sudharsan-T wants to merge 1 commit intoevidentlyai:mainfrom
Sudharsan-T:fix-groupby-display-name

Conversation

@Sudharsan-T
Copy link

Fix GroupBy display name for ValueDrift metrics

Problem

GroupBy(ValueDrift(...)) does not include the group-by column name and label in the report display name, while other metrics such as MaxValue do.

This results in inconsistent output:

  • GroupBy(MaxValue(...)) → includes group-by column and label
  • GroupBy(ValueDrift(...)) → shows only Drift in column '<column>'

Reported in #1706.


Root cause

GroupByMetricCalculation relied on metric-specific internal display name generation. For ValueDrift, this display name does not carry group-by context, so the column name and label were lost.


Fix

Build the display name explicitly in GroupByMetricCalculation.display_name() using:

  • the base display name of the underlying metric
  • the group-by column name
  • the group label

This makes the behavior consistent across all GroupBy metrics.


Implementation

File:

src/evidently/metrics/group_by.py

The display name construction was moved to the GroupBy calculation layer instead of relying on metric-specific behavior.


Result

GroupBy(ValueDrift(...)) now displays:

Drift in column '<column>' group by '<group_column>' for label: '<label>'

Testing

@DimaAmega
Copy link
Collaborator

Hi @Sudharsan-T
image_2026-01-05_15-12-20 (2)

Here we see less information than before, so this also needs to be fixed

Check html-visual-testing-playwright-report

@Liraim
Copy link
Collaborator

Liraim commented Jan 5, 2026

Hi @Sudharsan-T,

Thanks for the PR and for working on this improvement.

As @DimaAmega mentioned, there is one important issue I want to highlight, and why it occurs:

  • GroupBy wrapper relies on renders of underlying metrics to create a widget in the report. To customize the display name, it replaces the display_name() with a patched version (using _patched_display_name)
  • In this PR, this patched method was removed, which means every metric rendered through GroupBy loses the patched display_name and therefore its group-by-specific label.

To fix this properly, I think the following changes are needed:

  • bring back the use of _patched_display_name in the group-by wrapper
  • update the render method in ValueDriftCalculation (src/evidently/metrics/column_statistics.py:588) to use self.display_name() method instead of the hardcoded string
  • update self.display_name() to return proper string (it seems now it uses a different text from what is used in render).

This should restore the expected behavior for all metrics, and ValueDrift metrics correctly display the group-by text when used inside GroupBy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants