.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/integrations/plot_skore_hub_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_hub_project.py: .. _example_skore_hub_project: ======================================= Store and retrieve reports on Skore Hub ======================================= This example shows how to use :class:`~skore.Project` in **hub** mode: store reports remotely and inspect them. A key point is that :meth:`~skore.Project.summarize` returns a :class:`~skore.project._summary.Summary`, which is a :class:`pandas.DataFrame`. In Jupyter you get an interactive widget, but you can always inspect and filter the summary as a DataFrame if you prefer. Examples -------- To run this example and push in your own Skore Hub workspace and project, you can run this example with the following command: .. code-block:: bash WORKSPACE= PROJECT= python plot_skore_hub_project.py In this gallery, we are going to push the different reports into a public workspace. .. GENERATED FROM PYTHON SOURCE LINES 29-34 `skore` can communicate with Skore Hub which serves two main purposes: storing and retrieving any reports that you created and a user-friendly interface for you to explore and compare models. First, we need to login to Skore Hub such that later we can push our reports to it. .. GENERATED FROM PYTHON SOURCE LINES 35-42 .. code-block:: Python from skore import login login(mode="hub") .. rst-class:: sphx-glr-script-out .. code-block:: none ╭───────────────────────────────── Login to Skore Hub ─────────────────────────────────╮ │ │ │ Successfully logged in, using API key. │ │ │ ╰──────────────────────────────────────────────────────────────────────────────────────╯ .. GENERATED FROM PYTHON SOURCE LINES 77-79 To illustrate the integration with Skore Hub, we use a binary classification task where the goal is to predict whether a patient has a tumor or not. .. GENERATED FROM PYTHON SOURCE LINES 80-89 .. code-block:: Python import numpy as np import skrub from sklearn.datasets import load_breast_cancer X, y = load_breast_cancer(return_X_y=True, as_frame=True) labels = np.array(["no tumor", "tumor"], dtype=object) y = labels[y] skrub.TableReport(X) .. raw:: html

Please enable javascript

The skrub table reports need javascript to display correctly. If you are displaying a report in a Jupyter notebook and you see this message, you may need to re-execute the cell or to trust the notebook (button on the top right or "File > Trust notebook").



.. GENERATED FROM PYTHON SOURCE LINES 90-98 Store reports on Skore Hub ========================== On this problem, we use a logistic regression classifier with skrub's :func:`~skrub.tabular_pipeline` to preprocess the data if needed. To send several reports to Skore Hub, we send models with different regularization parameters. .. GENERATED FROM PYTHON SOURCE LINES 99-117 .. code-block:: Python from numpy import logspace from sklearn.linear_model import LogisticRegression from skore import Project, evaluate project = Project(f"{WORKSPACE}/{PROJECT}", mode="hub") for regularization in logspace(-3, 3, 5): project.put( f"lr-regularization-{regularization:.1e}", evaluate( skrub.tabular_pipeline(LogisticRegression(C=regularization)), X, y, splitter=0.2, pos_label="tumor", ), ) .. rst-class:: sphx-glr-script-out .. code-block:: none Putting lr-regularization-1.0e-03 0:00:35 Consult your report at https://skore.probabl.ai/skore/example-skore-hub-project-dev/estimators/8701 Putting lr-regularization-3.2e-02 0:00:35 Consult your report at https://skore.probabl.ai/skore/example-skore-hub-project-dev/estimators/8702 Putting lr-regularization-1.0e+00 0:00:37 Consult your report at https://skore.probabl.ai/skore/example-skore-hub-project-dev/estimators/8703 Putting lr-regularization-3.2e+01 0:00:35 Consult your report at https://skore.probabl.ai/skore/example-skore-hub-project-dev/estimators/8704 Putting lr-regularization-1.0e+03 0:00:35 Consult your report at https://skore.probabl.ai/skore/example-skore-hub-project-dev/estimators/8705 .. GENERATED FROM PYTHON SOURCE LINES 118-126 Retrieve report stored on Skore Hub =================================== Retrieving a report on Skore Hub is similar to retrieving a report in local mode. :meth:`~skore.Project.summarize` returns a :class:`~skore.project._summary.Summary`, which subclasses :class:`pandas.DataFrame`. In a Jupyter environment it renders an interactive parallel-coordinates widget by default. .. GENERATED FROM PYTHON SOURCE LINES 126-128 .. code-block:: Python summary = project.summarize() .. GENERATED FROM PYTHON SOURCE LINES 129-131 To see the normal DataFrame table instead of the widget (e.g. in scripts or when you prefer the table), wrap the summary in :class:`pandas.DataFrame`: .. GENERATED FROM PYTHON SOURCE LINES 132-137 .. code-block:: Python import pandas as pd pandas_summary = pd.DataFrame(summary) pandas_summary .. raw:: html
key date learner ml_task report_type dataset rmse log_loss roc_auc fit_time predict_time rmse_mean log_loss_mean roc_auc_mean fit_time_mean predict_time_mean
id
0 skore:report:estimator:8701 lr-regularization-1.0e-03 2026-04-29T16:07:11.000776+00:00 LogisticRegression binary-classification estimator 7887e234e3f622242e475e3da0cb5837 None 0.406397 0.987298 0.055146 0.034120 None None None None None
1 skore:report:estimator:8702 lr-regularization-3.2e-02 2026-04-29T16:07:46.872929+00:00 LogisticRegression binary-classification estimator 7887e234e3f622242e475e3da0cb5837 None 0.137499 0.995237 0.055377 0.033355 None None None None None
2 skore:report:estimator:8703 lr-regularization-1.0e+00 2026-04-29T16:08:24.393737+00:00 LogisticRegression binary-classification estimator 7887e234e3f622242e475e3da0cb5837 None 0.080457 0.995554 0.054876 0.032621 None None None None None
3 skore:report:estimator:8704 lr-regularization-3.2e+01 2026-04-29T16:09:00.004222+00:00 LogisticRegression binary-classification estimator 7887e234e3f622242e475e3da0cb5837 None 0.127249 0.992061 0.057464 0.032930 None None None None None
4 skore:report:estimator:8705 lr-regularization-1.0e+03 2026-04-29T16:09:35.496019+00:00 LogisticRegression binary-classification estimator 7887e234e3f622242e475e3da0cb5837 None 0.249399 0.990156 0.059721 0.033125 None None None None None


.. GENERATED FROM PYTHON SOURCE LINES 138-140 Basically, our summary contains metadata related to various information that we need to quickly help filtering the reports. .. GENERATED FROM PYTHON SOURCE LINES 141-143 .. code-block:: Python summary.info() .. rst-class:: sphx-glr-script-out .. code-block:: none MultiIndex: 5 entries, (0, 'skore:report:estimator:8701') to (4, 'skore:report:estimator:8705') Data columns (total 16 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 key 5 non-null object 1 date 5 non-null object 2 learner 5 non-null category 3 ml_task 5 non-null object 4 report_type 5 non-null object 5 dataset 5 non-null object 6 rmse 0 non-null object 7 log_loss 5 non-null float64 8 roc_auc 5 non-null float64 9 fit_time 5 non-null float64 10 predict_time 5 non-null float64 11 rmse_mean 0 non-null object 12 log_loss_mean 0 non-null object 13 roc_auc_mean 0 non-null object 14 fit_time_mean 0 non-null object 15 predict_time_mean 0 non-null object dtypes: category(1), float64(4), object(11) memory usage: 1.1+ KB .. GENERATED FROM PYTHON SOURCE LINES 144-146 Filter reports by metric (e.g. keep only those above a given accuracy) and work with the result as a table. .. GENERATED FROM PYTHON SOURCE LINES 147-149 .. code-block:: Python summary.query("log_loss < 0.2")["key"].tolist() .. rst-class:: sphx-glr-script-out .. code-block:: none ['lr-regularization-3.2e-02', 'lr-regularization-1.0e+00', 'lr-regularization-3.2e+01'] .. GENERATED FROM PYTHON SOURCE LINES 150-152 Use :meth:`~skore.project._summary.Summary.reports` to load the corresponding reports from the project (optionally after filtering the summary). .. GENERATED FROM PYTHON SOURCE LINES 153-156 .. code-block:: Python reports = summary.query("log_loss < 0.2").reports(return_as="comparison") len(reports.reports_) .. rst-class:: sphx-glr-script-out .. code-block:: none 3 .. GENERATED FROM PYTHON SOURCE LINES 157-159 Since we got a :class:`~skore.ComparisonReport`, we can use the metrics accessor to summarize the metrics across the reports. .. GENERATED FROM PYTHON SOURCE LINES 160-162 .. code-block:: Python reports.metrics.summarize().frame() .. raw:: html
Estimator LogisticRegression_1 LogisticRegression_2 LogisticRegression_3
Metric
Accuracy 0.956140 0.964912 0.947368
Precision 0.930556 0.970149 0.955224
Recall 1.000000 0.970149 0.955224
ROC AUC 0.995237 0.995554 0.992061
Log loss 0.137499 0.080457 0.127249
Brier score 0.035253 0.025149 0.029948
Fit time (s) 0.055377 0.054876 0.057464
Predict time (s) 0.033313 0.032726 0.032974


.. GENERATED FROM PYTHON SOURCE LINES 163-165 .. code-block:: Python _ = reports.metrics.roc().plot(subplot_by=None) .. image-sg:: /auto_examples/integrations/images/sphx_glr_plot_skore_hub_project_001.png :alt: ROC Curve Positive label: tumor Data source: Test set :srcset: /auto_examples/integrations/images/sphx_glr_plot_skore_hub_project_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 166-171 Conclusion ========== Skore Hub provides a user-friendly interface for you to explore and compare models. You can easily store reports created using Skore. .. rst-class:: sphx-glr-timing **Total running time of the script:** (3 minutes 13.212 seconds) .. _sphx_glr_download_auto_examples_integrations_plot_skore_hub_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_hub_project.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_skore_hub_project.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_skore_hub_project.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_