Skip to content

Lesson 5 ยท Experiment Tracking

Artifacts, Tags and Datasets

Save plots, reports and files as MLflow artifacts, organize runs with tags and notes, and record which dataset each run used so you can trace results.

Numbers do not tell the whole story. You also want the confusion matrix picture, the list of features, the error report and a note about the data. This lesson covers artifacts, tags and dataset tracking.

Artifacts: files that belong to a run

An artifact is any file attached to a run. MLflow copies it to the artifact store.

Python
import json
import mlflow

with mlflow.start_run():
    with open("features.json", "w") as f:
        json.dump(["age", "plan", "visits"], f)

    mlflow.log_artifact("features.json")                       # one file
    mlflow.log_artifacts("reports/", artifact_path="reports")  # a whole folder

There are also helpers that skip the temporary file:

Python
    mlflow.log_dict({"threshold": 0.4, "labels": ["stay", "leave"]}, "config.json")
    mlflow.log_text("Trained on data version 7.", "notes.txt")
    mlflow.log_figure(fig, "plots/roc.png")   # fig is a matplotlib figure

To get a file back, use mlflow.artifacts.download_artifacts with the run ID and the artifact path.

Artifacts are copies of real files. Do not upload raw customer records, keys or private documents unless the store has proper access control and your data rules allow it. A "small debug sample" is still personal data if it describes real people.

Tags and notes

Tags are key and value strings for searching and organizing. Set them during or after a run.

Python
mlflow.set_tags({
    "owner": "data-team",
    "data_version": "2026-11-30",
    "purpose": "baseline",
})
mlflow.set_tag("mlflow.note.content", "Baseline with default settings.")

The special tag mlflow.note.content holds a run description that the UI shows. Use a short note to explain why you ran something. Numbers record what happened, and notes record intent.

Dataset tracking

"Which data did this model see?" is a question you will get. MLflow can record a dataset as an input of a run:

Python
import mlflow
import pandas as pd

frame = pd.read_csv("train.csv")
dataset = mlflow.data.from_pandas(frame, source="train.csv", name="churn-train")

with mlflow.start_run():
    mlflow.log_input(dataset, context="training")

The record describes the data, with items such as its schema, a profile and a digest, which is a fingerprint. It is not a backup of the data. To recreate a run, keep the actual data in versioned storage and record where it is.

Why fingerprints matter

A fingerprint changes when the content changes. This stand-in uses SHA-256 from the standard library. MLflow computes its digest in its own way, so the values will not match.

Python Stand-in: detect that a dataset changed

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

This simple version treats a new row order as a new dataset. Whether that is right depends on your project, so always know what your fingerprint covers.

What to attach to every run

A practical starter set:

Item Where
Data version or path Tag and dataset input
Code version (Git commit) Tag (MLflow can set some source tags itself)
Feature list and config Artifact
Evaluation plots Artifact
Reason for the run Note tag

You can read the Git commit with git rev-parse HEAD and set it as a tag. Also record whether you had uncommitted changes, because a commit hash alone cannot describe edited files.

Size and cost

Large artifacts fill storage quickly. Save what you will use. Training checkpoints are a common source of bloat, so keep the useful ones and delete the rest according to a plan. The teams lesson covers cleaning up old runs.

Organize artifact folders

As projects grow, a flat list of files gets confusing. Pick a small layout and keep it for all runs:

TEXT
config/     settings used by the run
plots/      charts, such as ROC or error curves
reports/    text or HTML summaries
data_info/  column lists and statistics (not raw data)

Use the artifact_path argument to place a file in a folder, for example mlflow.log_artifact("summary.txt", artifact_path="reports").

A readable run report

A short text report helps people who do not want to dig through metrics. It can list the goal, the data version, the main results and any known problem. This stand-in builds such a report as a string, which you could then log with mlflow.log_text.

Python
def build_report(goal, data_version, metrics, warnings):
    lines = [f"Goal: {goal}", f"Data version: {data_version}", "Results:"]
    lines += [f"  {name}: {value}" for name, value in metrics.items()]
    lines += ["Known issues:"] + [f"  - {w}" for w in warnings]
    return "\n".join(lines)

text = build_report("predict churn", "7", {"val_f1": 0.81}, ["few new-user rows"])
mlflow.log_text(text, "reports/summary.txt")

The values are invented. The habit of writing known issues down is valuable. A model with a documented weak spot is far safer than one whose weak spot is forgotten.

Handle datasets with care

Dataset logging records metadata. Even metadata can be sensitive: column names or profile statistics may reveal something about your data. Before you share a tracking server widely, look at what a logged dataset shows in the UI.

Also record the split. Log training, validation and test data with different context names, so it is obvious which is which. If your split is random, record the seed too, otherwise the same dataset version can produce different splits.

Tags versus parameters

Beginners sometimes ask where a value belongs. Use this guide:

  • If it changes how the model is trained, it is usually a parameter.
  • If it helps you find or manage runs, it is a tag.
  • If it is a number you measured, it is a metric.
  • If it is a file, it is an artifact.

Tags can be edited after the run, which makes them good for review status. Do not use that ability to rewrite history.

Common mistakes

Do not overwrite a local file between runs and assume that the earlier run changed too. Each run holds the copy that existed when you logged it. If you edit a file after logging, log it again in a new run. Also avoid logging a whole project folder, which can sweep in virtual environments, credentials files or raw data.

Before you upload a folder, list what is in it. A short look prevents most accidents. If something sensitive does reach the store, treat it as exposed and follow your incident process instead of only hiding the run.

Check your understanding

Quick check ยท 3 questions

of 3 answered You scored / 3 ยท perfect!

  1. 1. Which call uploads the contents of a folder to a run?

    log_artifacts takes a local directory and uploads its contents.
  2. 2. What does logging a dataset with log_input mainly give you?

    It is a description and fingerprint. Keep the data itself in versioned storage.
  3. 3. Which is the best place for a short reason for running an experiment?

    The mlflow.note.content tag stores a description shown with the run.

Summary

  • Artifacts are files copied to the artifact store.
  • Tags organize runs, and a note tag explains intent.
  • Dataset logging records what data a run used, but does not back it up.
  • Protect sensitive data and watch artifact size.

Next: Search and Query Runs

Your progress is saved in this browser. No account needed.