.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/integrations/plot_skore_mlflow_project.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_integrations_plot_skore_mlflow_project.py: .. _example_skore_mlflow_project: ========================================== Store and retrieve Skore reports in MLflow ========================================== The primilarly goal of `skore` is to create data science artifacts in the form of structured reports. Those reports can easily be used programmatically via the Python API. A subsequent aim is to store those reports that you create during your experiment cycle in a way that it is easy to retrieve them later on. Skore provides two natives ways to store reports: locally or on Skore Hub. Skore Hub provides additional interactivity features for you to explore, compare and share visual insights. In addition, Skore also provides an MLflow integration to store the content of reports directly as MLflow artifacts. This example shows how to persist reports in MLflow using :class:`~skore.Project` in ``mode="mlflow"``: log reports as MLflow runs and inspect them. To run this example against your own MLflow tracking server, use: .. code-block:: bash TRACKING_URI= PROJECT= python plot_skore_mlflow_project.py To try it locally, start an MLflow server with ``uvx mlflow server`` and set ``TRACKING_URI=http://127.0.0.1:5000``. For more setup details, see the `MLflow quickstart `_. .. GENERATED FROM PYTHON SOURCE LINES 34-39 Create a Skore report ===================== First, we start by creating a Skore report by evaluating a logistic regression model on the iris dataset using some cross-validation. .. GENERATED FROM PYTHON SOURCE LINES 40-51 .. code-block:: Python from sklearn.datasets import load_iris from sklearn.linear_model import LogisticRegression from sklearn.pipeline import make_pipeline from sklearn.preprocessing import StandardScaler from skore import evaluate X, y = load_iris(return_X_y=True, as_frame=True) estimator = make_pipeline(StandardScaler(), LogisticRegression()) report = evaluate(estimator, X, y, splitter=5) .. GENERATED FROM PYTHON SOURCE LINES 52-58 Store the Skore reports as MLflow artifacts =========================================== Now, we will store the different items of the Skore report as MLflow artifacts. For this matter, you need to create a :class:`~skore.Project` in ``mode="mlflow"`` and pass the information regarding the MLflow tracking server. .. GENERATED FROM PYTHON SOURCE LINES 59-73 .. code-block:: Python import io # MLflow/Alembic emits verbose DB initialization logs; silence them so the # example page focuses on skore usage rather than backend startup details. with redirect_stdout(io.StringIO()), redirect_stderr(io.StringIO()): # This creates an MLflow experiment with name `PROJECT`: project = Project( PROJECT, mode="mlflow", tracking_uri=TRACKING_URI, ) .. GENERATED FROM PYTHON SOURCE LINES 99-101 Once the project created, the same API used to store a report locally or on Skore Hub applies. .. GENERATED FROM PYTHON SOURCE LINES 101-103 .. code-block:: Python project.put("logistic-regression", report) .. rst-class:: sphx-glr-script-out .. code-block:: none 2026/06/20 09:44:32 WARNING mlflow.utils.environment: Failed to resolve installed pip version. ``pip`` will be added to conda.yaml environment spec without a version specifier. 2026/06/20 09:44:34 WARNING mlflow.utils.environment: Failed to resolve installed pip version. ``pip`` will be added to conda.yaml environment spec without a version specifier. 2026/06/20 09:44:36 WARNING mlflow.utils.environment: Failed to resolve installed pip version. ``pip`` will be added to conda.yaml environment spec without a version specifier. 2026/06/20 09:44:38 WARNING mlflow.utils.environment: Failed to resolve installed pip version. ``pip`` will be added to conda.yaml environment spec without a version specifier. 2026/06/20 09:44:40 WARNING mlflow.utils.environment: Failed to resolve installed pip version. ``pip`` will be added to conda.yaml environment spec without a version specifier. 2026/06/20 09:44:43 WARNING mlflow.utils.environment: Failed to resolve installed pip version. ``pip`` will be added to conda.yaml environment spec without a version specifier. .. GENERATED FROM PYTHON SOURCE LINES 104-119 Once that you stored the report, the artifacts will be available on the MLflow tracking server at the following URL: ``http:///#//1/runs//artifacts`` To find the run ID attributed by MLflow, you can check the section below. Retrieve the Skore report from MLflow tracking server ===================================================== Like for the other modes (local and Skore Hub), you can access what is stored in the project via the :meth:`~skore.Project.summarize` method. In MLflow mode, :meth:`~skore.Project.summarize` exposes the same :class:`~skore.Summary` API as in local and hub mode: use :meth:`~skore.Summary.frame` to get the underlying :class:`pandas.DataFrame`. .. GENERATED FROM PYTHON SOURCE LINES 119-126 .. code-block:: Python summary = project.summarize() pandas_summary = summary.frame().reset_index() pandas_summary[["id", "key", "report_type", "learner", "dataset"]] .. raw:: html
id key report_type learner dataset
0 a396f25b6000460ab33733c9cc642b36 logistic-regression cross-validation LogisticRegression 8f9eb48c


.. GENERATED FROM PYTHON SOURCE LINES 132-133 Then, you can retrieve a Skore report using the `"id"` column: .. GENERATED FROM PYTHON SOURCE LINES 133-137 .. code-block:: Python (run_id,) = pandas_summary["id"] loaded_report = project.get(run_id) loaded_report.metrics.summarize().frame() .. raw:: html
LogisticRegression
mean std
Metric Label
Score 0.960000 0.043461
Accuracy 0.960000 0.043461
Precision 0 1.000000 0.000000
1 0.945455 0.081312
2 0.944444 0.078567
Recall 0 1.000000 0.000000
1 0.940000 0.089443
2 0.940000 0.089443
ROC AUC 0 1.000000 0.000000
1 0.996000 0.005477
2 0.996000 0.005477
Log loss 0.150357 0.040373
Fit time (s) 0.002438 0.000250
Predict time (s) 0.000336 0.000025


.. GENERATED FROM PYTHON SOURCE LINES 138-140 You can directly use MLflow to access information stored in the MLflow tracking server. .. GENERATED FROM PYTHON SOURCE LINES 140-145 .. code-block:: Python import mlflow mlflow_run = mlflow.get_run(run_id) mlflow_run.data.metrics .. rst-class:: sphx-glr-script-out .. code-block:: none {'accuracy': 0.96, 'accuracy_std': 0.043461349368017654, 'log_loss': 0.1503572043685131, 'log_loss_std': 0.0403727742084397, 'recall': 0.96, 'recall_std': 0.043461349368017654, 'precision': 0.96, 'precision_std': 0.043461349368017654, 'roc_auc': 0.9977777777777778, 'roc_auc_std': 0.0025153847605937046, 'fit_time': 0.002438224000007949, 'fit_time_std': 0.0002496825460605965, 'predict_time': 0.0003314581999973143, 'predict_time_std': 3.2789543088645514e-05} .. GENERATED FROM PYTHON SOURCE LINES 146-155 Conclusion ========== Skore offers native integrations locally and with Skore Hub. However, if you are already using MLflow, you can use the ``mode="mlflow"`` option to store reports as MLflow artifacts directly inside the tracking server. However, you will not benefit from the interactive user interface provided by Skore Hub. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 18.995 seconds) .. _sphx_glr_download_auto_examples_integrations_plot_skore_mlflow_project.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_skore_mlflow_project.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_skore_mlflow_project.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_skore_mlflow_project.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_