Skip to main content

MLflow Artifacts, Model Logging, and Autologging

Updated 2 min readMarkdown
Part of seriesMLOPS
MLflow Artifacts, Model Logging, and Autologging

Metrics tell us how a model performed, but they do not contain everything needed to inspect or reuse an experiment. MLflow artifacts provide a place to store files associated with a run.

Log artifacts

An artifact can be a JSON report, CSV file, image, or model file.

mlflow.log_artifact("reports/metrics.json")

The file becomes associated with the active MLflow run and can be inspected from the UI.

Log a model

For scikit-learn models:

mlflow.sklearn.log_model(model, name="model")

This stores the model in MLflow's artifact storage with model metadata. The exact serialization behavior can vary by MLflow version and environment. In some newer MLflow/scikit-learn setups, the skops serialization mechanism may require explicitly trusting a known scikit-learn type. Only do that when you understand and trust the model's source.

Autologging

Instead of manually recording every supported detail, MLflow can automatically capture information from supported libraries.

mlflow.set_experiment("autolog-demo")
mlflow.sklearn.autolog()

with mlflow.start_run(run_name="rf-training"):
    model.fit(X_train, y_train)

Depending on the library integration and configuration, autologging can capture parameters, metrics, and model artifacts.

Tags and run names

A run name identifies an execution in the UI. Tags add searchable metadata:

mlflow.set_tag("review-status", "shortlisted")

These are different concepts. A run name is not a replacement for a tag.

Takeaway: use metrics for numerical comparisons, artifacts for files, model logging for reusable model packages, and autologging when it captures the information you need.

No comments yet. Be the first to comment.