.. 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.Summary` object that holds the metadata and metrics of every report. In Jupyter it renders as an interactive table with different views where you can filter and pick rows to build a query string; outside of Jupyter you can work with the underlying :class:`pandas.DataFrame` via its :meth:`~skore.Summary.frame` method. 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= HOST= 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 31-45 `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. Authentication uses an API key, in this order: - the ``SKORE_HUB_API_KEY`` environment variable, which always wins. The key is bound to a workspace; using it against another workspace fails at runtime. - otherwise the local credentials registry for the hub host and workspace: .. code-block:: bash $ skore hub api-key generate --host https://skore.probabl.ai --workspace .. GENERATED FROM PYTHON SOURCE LINES 46-49 .. code-block:: Python :dedent: 1 .. GENERATED FROM PYTHON SOURCE LINES 87-89 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 90-99 .. 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 100-108 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 109-127 .. code-block:: Python from numpy import logspace from sklearn.linear_model import LogisticRegression from skore import Project, evaluate project = Project(name=PROJECT, mode="hub", workspace=WORKSPACE, host=HOST) 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 /home/runner/work/skore/skore/skore/venv/lib/python3.14/site-packages/skore/_plugins/hub/artifact/environment.py:48: UserWarning: Package matplotlib_skore_scraper seems to be an editable or local install (loaded from outside site-packages). It will not be recorded in the inferred requirements. for requirement in infer() Putting lr-regularization-1.0e-03 0:00:18 Consult your report at https://skore.probabl.ai/skore/example-skore-hub-project-dev/estimators/92477 /home/runner/work/skore/skore/skore/venv/lib/python3.14/site-packages/skore/_plugins/hub/artifact/environment.py:48: UserWarning: Package matplotlib_skore_scraper seems to be an editable or local install (loaded from outside site-packages). It will not be recorded in the inferred requirements. for requirement in infer() Putting lr-regularization-3.2e-02 0:00:15 Consult your report at https://skore.probabl.ai/skore/example-skore-hub-project-dev/estimators/92478 /home/runner/work/skore/skore/skore/venv/lib/python3.14/site-packages/skore/_plugins/hub/artifact/environment.py:48: UserWarning: Package matplotlib_skore_scraper seems to be an editable or local install (loaded from outside site-packages). It will not be recorded in the inferred requirements. for requirement in infer() Putting lr-regularization-1.0e+00 0:00:15 Consult your report at https://skore.probabl.ai/skore/example-skore-hub-project-dev/estimators/92479 /home/runner/work/skore/skore/skore/venv/lib/python3.14/site-packages/skore/_plugins/hub/artifact/environment.py:48: UserWarning: Package matplotlib_skore_scraper seems to be an editable or local install (loaded from outside site-packages). It will not be recorded in the inferred requirements. for requirement in infer() Putting lr-regularization-3.2e+01 0:00:15 Consult your report at https://skore.probabl.ai/skore/example-skore-hub-project-dev/estimators/92480 /home/runner/work/skore/skore/skore/venv/lib/python3.14/site-packages/sklearn/linear_model/_logistic.py:599: ConvergenceWarning: lbfgs failed to converge after 100 iteration(s) (status=1): STOP: TOTAL NO. OF ITERATIONS REACHED LIMIT Increase the number of iterations to improve the convergence (max_iter=100). You might also want to scale the data as shown in: https://scikit-learn.org/stable/modules/preprocessing.html Please also refer to the documentation for alternative solver options: https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression n_iter_i = _check_optimize_result( /home/runner/work/skore/skore/skore/venv/lib/python3.14/site-packages/skore/_plugins/hub/artifact/environment.py:48: UserWarning: Package matplotlib_skore_scraper seems to be an editable or local install (loaded from outside site-packages). It will not be recorded in the inferred requirements. for requirement in infer() Putting lr-regularization-1.0e+03 0:00:14 Consult your report at https://skore.probabl.ai/skore/example-skore-hub-project-dev/estimators/92481 .. GENERATED FROM PYTHON SOURCE LINES 128-137 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.Summary` object. In a Jupyter environment it renders as an interactive table where you can filter rows and pick reports across the different views; the selection produces a query string ready to pass to :meth:`~skore.Summary.query`. .. GENERATED FROM PYTHON SOURCE LINES 137-140 .. code-block:: Python summary = project.summarize() summary .. raw:: html


.. GENERATED FROM PYTHON SOURCE LINES 141-143 To work with the underlying table (e.g. in scripts or when you prefer a :class:`pandas.DataFrame`), use the :meth:`~skore.Summary.frame` method: .. GENERATED FROM PYTHON SOURCE LINES 144-146 .. code-block:: Python summary.frame() .. raw:: html
report_id key date learner report_type dataset log_loss roc_auc fit_time predict_time
id
0 skore:report:estimator:92477 01a1d034-13b1-7167-9725-897dd4bb13b6 lr-regularization-1.0e-03 2026-11-12 14:40:55.637074+00:00 LogisticRegression estimator 7887e234e3f622242e475e3da0cb5837 0.406397 0.987298 0.065353 0.028194
1 skore:report:estimator:92478 01a1d034-5fa7-7590-9ba4-d81837813067 lr-regularization-3.2e-02 2026-11-12 14:41:11.057558+00:00 LogisticRegression estimator 7887e234e3f622242e475e3da0cb5837 0.137499 0.995237 0.062283 0.028911
2 skore:report:estimator:92479 01a1d034-9bdc-7304-b33f-d74b504cf922 lr-regularization-1.0e+00 2026-11-12 14:41:26.505979+00:00 LogisticRegression estimator 7887e234e3f622242e475e3da0cb5837 0.080457 0.995554 0.062823 0.028417
3 skore:report:estimator:92480 01a1d034-d83a-75d4-a0cc-9631db553d32 lr-regularization-3.2e+01 2026-11-12 14:41:41.960973+00:00 LogisticRegression estimator 7887e234e3f622242e475e3da0cb5837 0.127250 0.992061 0.065401 0.028655
4 skore:report:estimator:92481 01a1d035-149c-7249-82f0-36a9a05e1f2d lr-regularization-1.0e+03 2026-11-12 14:41:56.915755+00:00 LogisticRegression estimator 7887e234e3f622242e475e3da0cb5837 0.240827 0.990156 0.068449 0.029275


.. GENERATED FROM PYTHON SOURCE LINES 147-149 Basically, our summary contains metadata related to various information that we need to quickly help filtering the reports. .. GENERATED FROM PYTHON SOURCE LINES 150-152 .. code-block:: Python summary.frame().info() .. rst-class:: sphx-glr-script-out .. code-block:: none MultiIndex: 5 entries, (0, 'skore:report:estimator:92477') to (4, 'skore:report:estimator:92481') Data columns (total 10 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 report_id 5 non-null str 1 key 5 non-null string 2 date 5 non-null datetime64[us, UTC] 3 learner 5 non-null category 4 report_type 5 non-null string 5 dataset 5 non-null string 6 log_loss 5 non-null float64 7 roc_auc 5 non-null float64 8 fit_time 5 non-null float64 9 predict_time 5 non-null float64 dtypes: category(1), datetime64[us, UTC](1), float64(4), str(1), string(3) memory usage: 1.3 KB .. GENERATED FROM PYTHON SOURCE LINES 153-155 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 156-158 .. code-block:: Python summary.query("log_loss < 0.2").frame()["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 159-162 Use :meth:`~skore.Summary.compare` to load the corresponding reports from the project (optionally after filtering the summary). Passing ``return_as="report"`` returns a :class:`~skore.ComparisonReport` built from those reports. .. GENERATED FROM PYTHON SOURCE LINES 163-166 .. code-block:: Python reports = summary.query("log_loss < 0.2").compare(return_as="report") len(reports.reports_) .. rst-class:: sphx-glr-script-out .. code-block:: none 3 .. GENERATED FROM PYTHON SOURCE LINES 167-169 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 170-172 .. code-block:: Python reports.metrics.summarize().frame() .. raw:: html
estimator LogisticRegression_1 LogisticRegression_2 LogisticRegression_3
metric
default_score 0.956140 0.964912 0.947368
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.127250
brier_score 0.035253 0.025149 0.029948
fit_time 0.062283 0.062823 0.065401
predict_time 0.031179 0.028253 0.028822


.. GENERATED FROM PYTHON SOURCE LINES 173-175 .. 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 176-181 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:** (1 minutes 32.117 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 `_