Skip to main content
You can build fully custom Metrics/Tests to handle any column- or dataset-level evaluations. This lets you implement business metrics, weighted scores, etc.
There are ways to customize your evals that do not require creating Metrics from scratch:
Creating a custom Metric involves:
  • (Required). Implementing the Metric calculation method.
  • (Optional). Defining the default Test conditions that apply when you run Tests for this Metric (with or without Reference) without passing a custom condition.
  • (Optional). Creating a custom visualization for this Metric using Plotly. If you skip this, the Metric will appear as a simple counter in the Report.
Once you implement the Metric, you can use it as usual: include in Reports, view in the Evidently Cloud (or a self-hosted UI), and visualize over time on the Dashboard.

Example implementation

This is advanced functionality that assumes you’re comfortable working with the codebase. Refer to existing metrics for examples. To implement the visualization, you must be familiar with Plotly.
Let’s implement MyMaxMetric which calculates the maximum value in a column. Imports:
Implementation:
The default Test will checks if the max value is 0 (or within ±10% of the reference value). This applies if you invoke the Tests without setting a custom threshold. This implementation uses the default (counter) render. Alternatively, you can define the widget as a Plotly figure. In this case, set the result.widget as shown in the code.

Example use

Once implemented, you can reference your custom Metric in a Report as usual. Let’s create a sample toy dataset:
Add my MyMaxMetric to the Report:
Want a Metric added to the core library? Share your idea or feature request by opening a GitHub issue.