Getting Started with MLflow

In this unit, we install MLflow, start its local UI, and add the first tracking calls to the duration prediction notebook. The video uses Jupyter inside VS Code, but the same Python code works in a browser notebook on the VM from Module 1.

Create the environment

Create and activate a separate environment so the tracking packages don't change the rest of your Python installation. Then install the module requirements.

conda create -n experiment-tracking python=3.9
conda activate experiment-tracking
pip install -r requirements.txt

The MLflow environment and package setup

Start the MLflow UI

For a useful local setup, store the tracking metadata in SQLite:

mlflow ui --backend-store-uri sqlite:///mlflow.db

Open the URL printed by MLflow. The UI lists experiments and runs, and the backend store also enables the model registry tab.

The local MLflow server and tracking UI

Configure the notebook

Point the client at the same SQLite database and select an experiment:

import mlflow

mlflow.set_tracking_uri('sqlite:///mlflow.db')
mlflow.set_experiment('nyc-taxi-experiment')

MLflow creates the experiment when it doesn't exist and adds later runs to it. Before saving a trained model, create the models directory so the notebook has a destination for its files.

The notebook creating an MLflow experiment

We still change model parameters manually in the initial notebook, so the next unit wraps those changes in tracked runs.

Optional analytics

Optional analytics are off unless you allow them. Your choice does not affect access to DataTalks.Club, Slack, events, or courses.

Current choice: not chosen.

Privacy Policy

If you allow analytics, self-hosted Umami counts anonymous public pageviews without analytics cookies. Private account and learning pages are excluded. Read the Privacy Policy for the complete data boundary.