Evidently and MLflow
Log Evidently metrics in the MLflow UI.
TL;DR: You can use Evidently to calculate metrics, and MLflow Tracking to log and view the results.
Jupyter notebook with en example:
Overview
Many machine learning teams use MLflow for experiment management, deployment, and as a model registry. If you are already familiar with MLflow, you can integrate it with Evidently to track the performance of your models.
In this case, you use Evidently to calculate the metrics and MLflow to log the results. You can then access the metrics in the MLflow interface.
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 MLflow Tracking.
Tutorial 1: Evaluating Data Drift with MLFlow and Evidently
In this tutorial, you will use Evidently to check input features for Data Drift and log and visualize the results with MLflow.
Here is a Jupyter notebook with the example:
In case of any discrepancies refer to the example notebook as a source of truth.
Step 1. Install MLflow and Evidently
Evidently is available as a PyPI package:
To install MLflow, run:
Or install MLflow with scikit-learn via
For more details, refer to MLflow documentation.
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.
This is how it looks:
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 MLflow
Initiate the experiments and log the metrics calculated with Evidently on each run.
Step 7. View the results in MLflow web UI
You can then use the MLflow UI to see the results of the runs. You can use the menu to select which metrics calculated by Evidently you'd want to see. In this example, you can choose drift for which features to display:
Tutorial 2: Evaluating Historical Data Drift with Evidently, Plotly and MLflow
This is an additional tutorial that demonstrates how you can evaluate historical drift in your data. It also shows how to log experiments with MLflow in a similar fashion. In this example, instead of logging drift scores for individual features, it logs the "Dataset drift" metric:
Refer to the blog with the tutorial and example notebook.
Last updated