Sometimes you need to generate multiple column-level Tests or Metrics. To simplify this, you can use metric generator helper functions.

Pre-requisites:

Imports

Imports

from evidently import Report
from evidently.metrics import *
from evidently.generators import ColumnMetricGenerator

Metric generators

Example 1. Apply the selected metric (ValueDrift) to all columns in the dataset.

report = Report([
    ColumnMetricGenerator(ValueDrift)
])

my_eval = report.run(eval_data_1, eval_data_2)
my_eval

Example 2. Apply the selected metric (ValueDrift) to the listed columns in the dataset. Use metric_kwargs to pass any applicable metric parameters.

report = Report([
    ColumnMetricGenerator(ValueDrift, 
                          columns=["EducationLevel", "Salary"],
                          metric_kwargs={"method":"psi"}), # metric parameters
])

my_eval = report.run(eval_data_1, eval_data_2)
my_eval

Example 3. Apply the selected metric (ValueDrift) only to the categorical (cat) columns in the dataset.

report = Report([
    ColumnMetricGenerator(UniqueValueCount, 
                          column_types='cat'),  #apply to categorical columns only 
])

my_eval = report.run(eval_data_1, eval_data_2)
my_eval

Available:

  • num - numerical
  • cat - categorical
  • all - all

Test generators

You can use the same approach to generate Tests. Use metric_kwargs to pass test conditions.

Example. Generate the same Test for all the columns in the dataset. It will use defaults if you do not specify the test condition.

from evidently.future.tests import *

report = Report([
    ColumnMetricGenerator(MinValue, 
                          column_types='num',
                          metric_kwargs={"tests":[gt(0)]}), 
])

my_eval = report.run(eval_data_1, eval_data_2)
my_eval

This will apply the minimum value test to all numerical columns in the dataset and check that they are above 0.