Download the model
Export a model as a Python script, notebook, joblib, pickle, ONNX, MLflow format or a bundle.
You can take a trained model out of mlflow as a file and use it in your own application, notebook or job. Nothing else has to run: the file holds the whole fitted pipeline, preprocessing included.
Export formats
In the app, open the Download tab of the Deploy & export panel. Each format has a card with a Download button. To open the panel, select Deploy best model on a run page, or open the Deploy & export tab of a model candidate page.
| Card | File | Use it for |
|---|---|---|
| joblib | <model>.joblib | The recommended Python file for scikit-learn models. |
| pickle | <model>.pkl | A plain Python pickle of the fitted pipeline. |
| ONNX | <model>.onnx | A portable format that other runtimes can load, when the model family supports it. |
| Full bundle (zip) | <model>_bundle.zip | The pipeline, a Python script, pinned requirements, the input schema and a README, in one file. |
The Full bundle is the best starting point if you are not sure. It contains:
| File | Purpose |
|---|---|
pipeline.joblib | The fitted model. |
predict.py | A runnable script that loads the model and prints predictions as JSON. |
requirements.txt | Pinned versions of the libraries the model needs. |
input_schema.json | The feature columns the model expects, plus one real example row. |
model.onnx | The model as an ONNX graph, when the conversion works. |
README.md | Commands, the schema, the metrics recorded at training time, and notes about ONNX. |
Only load files you trust
joblib and pickle files run code when they are loaded. Load a model file only if it came from mlflow or from someone you trust, and never from an unknown source.
Exporting works for any candidate that trained successfully and has a stored model. Baseline models are reference points and cannot be exported. Anyone who can view the run can download from it. A candidate page also has a Download pipeline button that saves the stored model as a .pkl file.
Formats available from the API only
Three more formats are available through the API but have no button in the app. Request them with an API key that has at least the read scope.
format | Result |
|---|---|
python_script | A standalone Python script (<model>_export.py) that loads the model file and predicts on a sample row. |
notebook | A Jupyter notebook (<model>_export.ipynb) with the same steps explained in cells. It needs a notebook component on the server, and the request is refused with status 422 when that is missing. |
mlflow | A zip (<model>_mlflow_model.zip) in the standard MLflow model-directory layout, with MLmodel, model.pkl and environment files. |
The same route serves the formats in the table above under the names joblib, pickle, onnx and bundle. An unknown format answers 400. The script and the notebook do not contain the model itself: they load pipeline.joblib, which you download separately from the same route. The MLflow-format file is created by mlflow without needing the MLflow package. To use it, install MLflow on your own machine and run mlflow models serve -m <unzipped folder>, or load it in Python with mlflow.pyfunc.load_model.
curl -s -H "X-API-Key: $MLFLOW_API_KEY" \
-o my-model_export.py \
"https://app.mlflow.es/api/v1/runs/<RUN_ID>/trials/<TRIAL_ID>/export/python_script"On a self-hosted server, replace https://app.mlflow.es with your server's address.
Load the model in Python
The model is a scikit-learn pipeline. It includes the preprocessing you configured, so you pass raw rows, not prepared features.
import joblib
import pandas as pd
pipeline = joblib.load("pipeline.joblib")
row = {"age": 41, "plan": "pro", "monthly_usage": 18.5} # use your own columns
frame = pd.DataFrame.from_records([row])
predictions = pipeline.predict(frame)
print(predictions)
if hasattr(pipeline, "predict_proba"):
print(pipeline.predict_proba(frame))Always pass a pandas DataFrame with the exact column names listed in input_schema.json, not a bare array. The pipeline selects columns by name, so a guessed column order can fail or, worse, silently use the wrong column. The predict.py script in the bundle does the same thing and also accepts your own CSV file:
python -m venv .venv && . .venv/bin/activate
pip install -r requirements.txt
python predict.py --input your_rows.csvIt prints one JSON object with predictions and, for classification models, probabilities.
ONNX
ONNX is a portable model format. Runtimes for many languages can load it without Python, which is useful for a Java, C# or JavaScript application.
The conversion is best effort. These model families cannot be converted: XGBoost, LightGBM, CatBoost, anomaly-detection models and time-series models. When a model cannot be converted, the ONNX card shows the reason and its button is disabled. A server may also lack the ONNX component. In that case the reason says so, and an administrator can install it. The full bundle is not affected: it simply leaves out model.onnx and says why in its README.md.
An ONNX model made by mlflow takes one input per feature column, not one matrix. Each input has shape [None, 1]. Numeric columns are sent as 32-bit floats and the other columns as strings. Column names are cleaned because ONNX does not allow spaces or parentheses, so age (years) becomes age__years_. Bind the inputs in the order of input_schema.json:
import numpy as np
import onnxruntime as ort
import pandas as pd
session = ort.InferenceSession("model.onnx")
frame = pd.DataFrame.from_records([row]) # same columns as the schema
feed = {}
for inp, col in zip(session.get_inputs(), frame.columns):
values = frame[col].to_numpy()
if np.issubdtype(values.dtype, np.number):
values = values.astype(np.float32)
feed[inp.name] = values.reshape(-1, 1)
labels = session.run(None, feed)[0]ONNX computes in 32-bit floats while scikit-learn uses 64-bit, so probabilities agree to about six decimal places, not to the last digit.
Python script and notebook
The python_script and notebook formats are for people who want to read how the model is used, not for retraining. They do not rebuild the pipeline from code, because a model's learned values (coefficients, tree splits, scaling statistics) cannot be recovered from settings alone. Instead they load the fitted pipeline.joblib, show the expected columns and the metrics from training, and run a prediction on a real example row so you can see the whole flow work. Save pipeline.joblib next to the file before you run it. Replace the example row with your own data to predict on something else.
To get a model you can retrain, build a pipeline in mlflow, which records every step and setting.
Version compatibility
A model file is tied to the library versions that created it. Loading it with different versions can fail, or give slightly different results.
requirements.txtin the bundle pins the exact versions that were installed where the model was trained, for every library the model uses. It also records the Python version in a comment (the line that starts with# python==).- Create a new virtual environment and install from this file before loading the model.
- Use the same major Python version as the comment says. The deployment kits already do this: their
Dockerfileuses a Python image with the matching version. - A model trained again is a new candidate with its own export. Keep the bundle you deploy, so you can reproduce its results later. The lesson linked at the end of this page explains why this matters.
Next steps
Learn the theory
Lessons on learning.mlflow.es that explain the ideas behind this page.
Updated 2026-11-22