Evidently and DVCLive
Log Evidently metrics with DVC via DVCLive.
This is a community-contributed integration. Author: Francesco Calcavecchia.
TL;DR: You can use Evidently to calculate metrics, and DVCLive to log and view the results.
Jupyter notebook with en example:
Overview
DVCLive can be used to track the results of Evidently. In the following we demonstrate it through an example.
How it works
Evidently calculates a rich set of metrics and statistical tests. You can choose any of the pre-built reports or combine individual metrics to define what you want to measure. For example, you can evaluate prediction drift and feature drift together.
You can then generate the calculation output in a Python dictionary format. You should explicitly define which parts of the output to send to DVCLive Tracking.
Step 1. Install DVCLive and Evidently
Install DVCLive, Evidently, and pandas (to handle the data) in your Python environment:
Step 2. Load the data
Load the data from UCI repository and save it locally. For demonstration purposes, we treat this data as the input data for a live model. To use with production models, you should make your prediction logs available.
Step 3. Define column mapping
You should specify the categorical and numerical features so that Evidently performs the correct statistical test for each of them. While Evidently can parse the data structure automatically, manually specifying the column type can minimize errors.
Step 4. Define what to log
Specify which metrics you want to calculate. In this case, you can generate the Data Drift report and log the drift score for each feature.
You can adapt what you want to calculate by selecting a different Preset or Metric from those available in Evidently.
Step 5. Define the comparison windows
Specify the period that is considered reference: Evidently will use it as the base for the comparison. Then, you should choose the periods to treat as experiments. This emulates the production model runs.
Step 6. Run and log experiments in DVC
There are two ways to track the results of Evidently with DVCLive:
you can save the results of each item in the batch in one single experiment (each experiment corresponds to a git commit), in separate steps
or you can save the result of each item in the batch as a separate experiment
We will demonstrate both, and show you how to inspect the results regardless of your IDE. However, if you are using VSCode, we recommend using the DVC extension for VS Code to inspect the results.
Step 7
Option 1. One single experiment
You can then inspect the results using
In a Jupyter notebook environment, you can show the plots as a cell output simply by using Live(report="notebook")
.
Option 2. Multiple experiments
You can the inspect the results using
In a Jupyter notebook environment, you can access the experiments results using the Python DVC api:
Last updated