Fixed: MLflow Doesn't Link Evaluation Metrics to the Model When You Evaluate a Registered Model Version
I evaluated a registered model version with mlflow.models.evaluate, using its registry address, models:/tumour-evaluation/1. The evaluation run got its metrics, but the logged model behind the version said Metrics (0). MLflow 3.18.0's open-source registry doesn't store which logged model a version holds, so evaluate couldn't link the metrics; evaluating the version's source, models:/<model ID>, fixed it.
What I Was Doing
I was building the promote command of Part 8 of the MLflow series, which evaluates a new model version with a quality gate before it replaces the one in use. Here is the same step on its own: a logistic regression on scikit-learn's breast cancer data, logged and registered as tumour-evaluation version 1, then evaluated through its registry address:
import mlflow
from mlflow import MlflowClient
from sklearn.datasets import load_breast_cancer
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler
mlflow.set_tracking_uri("http://127.0.0.1:8080")
mlflow.set_experiment("evaluate-version-example")
client = MlflowClient()
name = "tumour-evaluation"
X, y = load_breast_cancer(return_X_y=True, as_frame=True)
y = y == 0 # True when the tumour is malignant
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25, random_state=0)
model = make_pipeline(StandardScaler(), LogisticRegression()).fit(X_train, y_train)
with mlflow.start_run(run_name="train"):
mlflow.sklearn.log_model(model, name="model", registered_model_name=name, input_example=X_train.head(3))
with mlflow.start_run(run_name="evaluate-version-1"):
result = mlflow.models.evaluate(
f"models:/{name}/1",
X_test.assign(malignant=y_test),
targets="malignant",
model_type="classifier",
evaluator_config={"log_model_explainability": False},
)
print("ROC AUC:", round(result.metrics["roc_auc"], 4))
version = client.get_model_version(name, "1")
logged_model = mlflow.get_logged_model(version.source.removeprefix("models:/"))
print("Metrics on the logged model:", sorted({m.key for m in logged_model.metrics}))
uv run python evaluate_version.py
What I Expected
The metrics on the evaluation run, and the same metrics on the logged model behind version 1, with the dataset they were measured on. That's what mlflow.models.evaluate does when it gets a model's own address, models:/<model ID>, as in How to See an Evaluation's Metrics and Plots in the MLflow UI.
What I Got
🏃 View run evaluate-version-1 at: http://127.0.0.1:8080/#/experiments/24/runs/f67d3545a948460b987a8c9fadd99977
🧪 View experiment at: http://127.0.0.1:8080/#/experiments/24
ROC AUC: 0.9914
Metrics on the logged model: []

The evaluation worked, with a ROC AUC of 0.9914, but the logged model has no metrics. Its page in the MLflow UI agrees:

Metrics (0), no dataset, and only the training run: the evaluation isn't linked to the model at all.
What I Checked
What the version records. A short script prints the version's source and its model_id:
import mlflow
from mlflow import MlflowClient
mlflow.set_tracking_uri("http://127.0.0.1:8080")
version = MlflowClient().get_model_version("tumour-evaluation", "1")
print("source: ", version.source)
print("model_id:", version.model_id)
uv run python check_version.py
source: models:/m-81517773c84e455c85f726bb59a063e8
model_id: None
The version knows its logged model through source, but its model_id is empty.
How evaluate finds the model. The reference for mlflow.models.evaluate says of its model_id argument: "The ID of the MLflow LoggedModel or Model Version to which the evaluation results (e.g. metrics and traces) will be linked. If model_id is not specified but model is specified, the ID from model will be used." In MLflow 3.18.0, that ID comes from _parse_model_id_if_present in mlflow/store/artifact/utils/models.py: a models:/<model ID> address carries it, and for models:/<name>/<version> the function asks the registry for the version and returns its model_id.
What the registry stores. The open-source registry keeps its versions in a SQL table, defined in mlflow/store/model_registry/dbmodels/models.py, and that table has no column for a model ID. So every version comes back with model_id set to None, and the logged model is only in source.
Why It Happens
models:/tumour-evaluation/1 gives evaluate a name and a version number. To link the metrics, it asks the registry which logged model that version holds, and an open-source MLflow server answers None. With no model ID, the metrics stay on the evaluation run only. I reported it to MLflow as issue #28119.
The Fix
Evaluate the logged model the version was registered from: its source, which is a models:/<model ID> address. Only the model address changes; the version is loaded from the same files either way:

import mlflow
from mlflow import MlflowClient
from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split
mlflow.set_tracking_uri("http://127.0.0.1:8080")
mlflow.set_experiment("evaluate-version-example")
client = MlflowClient()
name = "tumour-evaluation"
X, y = load_breast_cancer(return_X_y=True, as_frame=True)
y = y == 0 # True when the tumour is malignant
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25, random_state=0)
# The version's source is the logged model it was registered from: models:/<model ID>.
version = client.get_model_version(name, "1")
with mlflow.start_run(run_name="evaluate-version-1-source"):
result = mlflow.models.evaluate(
version.source,
X_test.assign(malignant=y_test),
targets="malignant",
model_type="classifier",
evaluator_config={"log_model_explainability": False},
)
print("ROC AUC:", round(result.metrics["roc_auc"], 4))
logged_model = mlflow.get_logged_model(version.source.removeprefix("models:/"))
print("Metrics on the logged model:", sorted({m.key for m in logged_model.metrics}))
It splits the data the same way, with random_state=0, so it evaluates on the same 143 test tumours.
After the Fix
uv run python evaluate_version_source.py
🏃 View run evaluate-version-1-source at: http://127.0.0.1:8080/#/experiments/24/runs/4e7c5ff2064a47398907d3c133e3ff88
🧪 View experiment at: http://127.0.0.1:8080/#/experiments/24
ROC AUC: 0.9914
Metrics on the logged model: ['accuracy_score', 'example_count', 'f1_score', 'false_negatives', 'false_positives', 'log_loss', 'precision_recall_auc', 'precision_score', 'recall_score', 'roc_auc', 'score', 'true_negatives', 'true_positives']

Same ROC AUC, and all thirteen metrics now sit on the logged model. Its page lists them with the dataset and the run that measured them:

The page counts 26 because MLflow 3.18.0's evaluate writes each of the 13 metrics twice when it links them to a model, as How to See an Evaluation's Metrics and Plots in the MLflow UI explains; the values are the same.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
Evaluating models:/<name>/<version> and checking the model's page | The page shows no evaluation metrics | Evaluate the version's source |
Reading version.model_id to find the logged model | It's None on an open-source MLflow server | Read version.source |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
A logged model says Metrics (0) after an evaluation | The evaluation got a registry address | Evaluate version.source |
version.model_id is None | The open-source registry doesn't store it | Use version.source, which holds models:/<model ID> |
FAQ
Are the metrics from the first evaluation lost?
No: they're on the evaluate-version-1 run, where the run's page lists them. Only the link to the model is missing.
Does evaluating an alias, such as models:/<name>@champion, link them?
No. In MLflow 3.18.0 an alias address doesn't link the metrics either. Evaluate the source of the version the alias points to.
Is there another way to link them?
The reference documents the model_id argument quoted above, which names the model to link the results to. Evaluating the version's source needs no extra argument, so that's what I used.
Conclusion
mlflow.models.evaluate("models:/tumour-evaluation/1", ...) logged its metrics to the run only, because an open-source MLflow 3.18.0 registry returns model_id as None for every version, and evaluate takes the model ID from there. Evaluating the version's source, the models:/<model ID> address of the logged model it was registered from, linked all thirteen metrics to that model.
Additional Resources
- mlflow.models.evaluate — the
modelandmodel_idarguments. - MLflow Model Registry — versions, sources and model addresses.
