How to Make an MLflow Model Return Probabilities
Load a scikit-learn classifier from MLflow as a Python function and predict gives you labels: 0, 1, 2. For ranking, alerts or your own cut-off you usually want the probabilities. log_model(pyfunc_predict_fn="predict_proba") makes the logged model's predict return them, wherever it's loaded or served. This guide does it, with real output from MLflow 3.18.0.
Syntax
signature = infer_signature(X, model.predict_proba(X))
mlflow.sklearn.log_model(
sk_model, name="...", signature=signature, pyfunc_predict_fn="predict_proba"
)
| Part | What it means |
|---|---|
pyfunc_predict_fn | Which of the model's methods the MLflow Python-function predict calls. The default is "predict"; the reference also lists "predict_proba", "predict_log_proba", "predict_joint_log_proba" and "score" |
signature | Inferred from predict_proba, so it describes what the model now returns |
Pass the signature yourself: when MLflow infers it from an input example, it uses predict, and the signature then describes labels the model never returns (Fixed: MLflow Signature Says long for a predict_proba Model).
Prerequisites
- An MLflow tracking server at
http://127.0.0.1:8080. MLflow's tracking server guide shows how to start one. mlflowandscikit-learnin your project, for example withuv add mlflow scikit-learn pandas.
Step 1: Log the Classifier to Return Probabilities
The example trains a logistic regression on scikit-learn's iris flowers, three species, and logs it with predict_proba as its prediction function. Then it compares scikit-learn's own predict with the logged model's:

import mlflow
from mlflow.models import infer_signature
from sklearn.datasets import load_iris
from sklearn.linear_model import LogisticRegression
mlflow.set_tracking_uri("http://127.0.0.1:8080")
mlflow.set_experiment("probabilities-demo")
X, y = load_iris(return_X_y=True, as_frame=True)
model = LogisticRegression(max_iter=500).fit(X, y)
# The signature describes what the model returns: one probability per class.
signature = infer_signature(X, model.predict_proba(X))
with mlflow.start_run():
model_info = mlflow.sklearn.log_model(
model, name="iris-model", signature=signature, pyfunc_predict_fn="predict_proba"
)
rows = X.head(2)
print("scikit-learn predict:", model.predict(rows))
print("MLflow pyfunc predict:")
print(mlflow.pyfunc.load_model(model_info.model_uri).predict(rows).round(3))
uv run python probabilities.py
2026/11/21 14:12:13 INFO mlflow.tracking.fluent: Experiment with name 'probabilities-demo' does not exist. Creating a new experiment.
2026/11/21 14:12:14 INFO mlflow.utils.uv_utils: Detected uv project: found uv.lock and pyproject.toml in /Users/you/source/mlflow-demo
2026/11/21 14:12:14 INFO mlflow.utils.uv_utils: Detected uv project: found uv.lock and pyproject.toml in /Users/you/source/mlflow-demo
2026/11/21 14:12:14 INFO mlflow.utils.environment: Detected uv project at /Users/you/source/mlflow-demo. Attempting to export requirements via 'uv export'.
2026/11/21 14:12:14 INFO mlflow.utils.uv_utils: Exported 91 dependencies via uv
2026/11/21 14:12:14 INFO mlflow.utils.environment: Successfully exported 91 requirements from uv project. Skipping package capture based inference.
🏃 View run abrasive-frog-459 at: http://127.0.0.1:8080/#/experiments/7/runs/c8985731fbef496b882250fbd8527d02
🧪 View experiment at: http://127.0.0.1:8080/#/experiments/7
scikit-learn predict: [0 0]
MLflow pyfunc predict:
[[0.982 0.018 0. ]
[0.972 0.028 0. ]]

Same model, same two flowers. scikit-learn's predict says class 0 for both; the logged model's predict returns the three probabilities behind that answer, in the order of the classes, 0, 1 and 2.
Step 2: Check the MLmodel File
Open the model from the experiment's Models tab, then Artifacts and MLmodel:

predict_fn: predict_proba under the python_function flavor is the setting every MLflow tool reads, whether it loads the model in Python or serves it over HTTP. Further down, the signature's output is a tensor of decimals, inferred from predict_proba:
outputs: '[{"type": "tensor", "tensor-spec": {"dtype": "float64", "shape": [-1,
3]}}]'
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
Setting pyfunc_predict_fn but letting MLflow infer the signature from an input example | The signature says the output is a whole number, the label | Infer the signature from predict_proba yourself |
| Expecting the native model to change too | mlflow.sklearn.load_model returns the scikit-learn model, whose predict still returns labels | Call predict_proba on it, or load with mlflow.pyfunc.load_model |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| The served or loaded model returns 0 and 1 | pyfunc_predict_fn wasn't set when it was logged | Log the model again with pyfunc_predict_fn="predict_proba" |
UserWarning: Hint: Inferred schema contains integer column(s)... when logging a classifier | The signature was inferred from the labels | Fixed: MLflow Signature Says long for a predict_proba Model |
FAQ
Can I change predict_fn for a model already logged?
The setting is written into the model's MLmodel file when it's logged, so log the model again with the new value.
Which column is the probability of yes?
For classes 0 and 1, the second: predictions[:, 1]. The columns follow the classifier's classes_.
Conclusion
With pyfunc_predict_fn="predict_proba" and a signature inferred from predict_proba, the logged logistic regression returned three probabilities per flower where scikit-learn's predict gave a label, and its MLmodel file says so for every tool that loads it.
Additional Resources
- mlflow.sklearn —
pyfunc_predict_fninlog_model.
