.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/technical_details/plot_skore_local_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_technical_details_plot_skore_local_project.py: .. _example_skore_local_project: =================== Local skore Project =================== This example shows how to use :class:`~skore.Project` in **local** mode: store reports on your machine and inspect them. A key point is that :meth:`~skore.Project.summarize` returns a ``Summary`` object that holds the metadata and metrics of every report. In Jupyter it renders as an interactive table with three views (Table, parallel-coordinates Plot, and Trend) where you can filter and pick reports to build a query string; the underlying :class:`pandas.DataFrame` is accessible through its ``frame`` method. .. GENERATED FROM PYTHON SOURCE LINES 18-24 Create a local project and store reports ========================================= We use a temporary directory as the workspace so the example is self-contained. In practice you can omit ``workspace`` to use the default (e.g. a ``skore/`` directory in your user cache). .. GENERATED FROM PYTHON SOURCE LINES 24-33 .. code-block:: Python from pathlib import Path from tempfile import TemporaryDirectory from skore import Project tmp_dir = TemporaryDirectory() tmp_path = Path(tmp_dir.name) project = Project("example-project", workspace=tmp_path) .. GENERATED FROM PYTHON SOURCE LINES 34-41 .. code-block:: Python from sklearn.datasets import load_breast_cancer from sklearn.linear_model import LogisticRegression from skrub import tabular_pipeline X, y = load_breast_cancer(return_X_y=True, as_frame=True) estimator = tabular_pipeline(LogisticRegression(max_iter=1_000)) .. GENERATED FROM PYTHON SOURCE LINES 42-56 .. code-block:: Python import numpy as np from sklearn.base import clone from skore import evaluate for regularization in np.logspace(-7, 7, 31): report = evaluate( clone(estimator).set_params(logisticregression__C=regularization), X, y, splitter=0.2, pos_label=1, ) project.put(f"lr-regularization-{regularization:.1e}", report) .. GENERATED FROM PYTHON SOURCE LINES 57-64 Summarize: you get a Summary ============================ :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 64-67 .. code-block:: Python summary = project.summarize() summary .. raw:: html


.. GENERATED FROM PYTHON SOURCE LINES 68-70 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 70-72 .. code-block:: Python summary.query("log_loss < 0.1") .. rst-class:: sphx-glr-script-out .. code-block:: none /home/runner/work/skore/skore/skore/src/skore/_project/_summary.py:67: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy dataframe["date"] = to_datetime(dataframe["date"], errors="coerce") /home/runner/work/skore/skore/skore/src/skore/_project/_summary.py:68: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy dataframe["learner"] = Categorical(dataframe["learner"]) /home/runner/work/skore/skore/skore/src/skore/_project/_summary.py:70: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy dataframe[column] = dataframe[column].astype("string") /home/runner/work/skore/skore/skore/src/skore/_project/_summary.py:70: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy dataframe[column] = dataframe[column].astype("string") /home/runner/work/skore/skore/skore/src/skore/_project/_summary.py:70: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy dataframe[column] = dataframe[column].astype("string") /home/runner/work/skore/skore/skore/src/skore/_project/_summary.py:70: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy dataframe[column] = dataframe[column].astype("string") .. raw:: html


.. GENERATED FROM PYTHON SOURCE LINES 73-76 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 76-79 .. code-block:: Python reports = summary.query("log_loss < 0.1").compare(return_as="report") reports .. rst-class:: sphx-glr-script-out .. code-block:: none /home/runner/work/skore/skore/skore/src/skore/_project/_summary.py:67: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy dataframe["date"] = to_datetime(dataframe["date"], errors="coerce") /home/runner/work/skore/skore/skore/src/skore/_project/_summary.py:68: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy dataframe["learner"] = Categorical(dataframe["learner"]) /home/runner/work/skore/skore/skore/src/skore/_project/_summary.py:70: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy dataframe[column] = dataframe[column].astype("string") /home/runner/work/skore/skore/skore/src/skore/_project/_summary.py:70: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy dataframe[column] = dataframe[column].astype("string") /home/runner/work/skore/skore/skore/src/skore/_project/_summary.py:70: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy dataframe[column] = dataframe[column].astype("string") /home/runner/work/skore/skore/skore/src/skore/_project/_summary.py:70: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy dataframe[column] = dataframe[column].astype("string") .. raw:: html
Pipeline(steps=[('tablevectorizer',
                     TableVectorizer(datetime=DatetimeEncoder(periodic_encoding='spline'))),
                    ('simpleimputer', SimpleImputer(add_indicator=True)),
                    ('squashingscaler', SquashingScaler(max_absolute_value=5)),
                    ('logisticregression',
                     LogisticRegression(C=np.float64(0.11659144011798311),
                                        max_iter=1000))])
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.

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").

1 issue(s), 1 tip(s), 4 passed, 5 not applicable, 0 ignored.
Pipeline(steps=[('tablevectorizer',
                     TableVectorizer(datetime=DatetimeEncoder(periodic_encoding='spline'))),
                    ('simpleimputer', SimpleImputer(add_indicator=True)),
                    ('squashingscaler', SquashingScaler(max_absolute_value=5)),
                    ('logisticregression',
                     LogisticRegression(C=np.float64(0.34145488738336005),
                                        max_iter=1000))])
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.

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").

1 issue(s), 1 tip(s), 4 passed, 5 not applicable, 0 ignored.
Pipeline(steps=[('tablevectorizer',
                     TableVectorizer(datetime=DatetimeEncoder(periodic_encoding='spline'))),
                    ('simpleimputer', SimpleImputer(add_indicator=True)),
                    ('squashingscaler', SquashingScaler(max_absolute_value=5)),
                    ('logisticregression',
                     LogisticRegression(C=np.float64(1.0), max_iter=1000))])
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.

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").

1 issue(s), 1 tip(s), 4 passed, 5 not applicable, 0 ignored.
Pipeline(steps=[('tablevectorizer',
                     TableVectorizer(datetime=DatetimeEncoder(periodic_encoding='spline'))),
                    ('simpleimputer', SimpleImputer(add_indicator=True)),
                    ('squashingscaler', SquashingScaler(max_absolute_value=5)),
                    ('logisticregression',
                     LogisticRegression(C=np.float64(2.9286445646252375),
                                        max_iter=1000))])
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.

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").

1 issue(s), 1 tip(s), 4 passed, 5 not applicable, 0 ignored.


.. GENERATED FROM PYTHON SOURCE LINES 80-82 .. code-block:: Python _ = reports.metrics.roc().plot(subplot_by=None) .. image-sg:: /auto_examples/technical_details/images/sphx_glr_plot_skore_local_project_001.png :alt: ROC Curve Positive label: 1 Data source: Test set :srcset: /auto_examples/technical_details/images/sphx_glr_plot_skore_local_project_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 83-85 .. code-block:: Python project.delete("example-project", workspace=tmp_path) tmp_dir.cleanup() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 15.217 seconds) .. _sphx_glr_download_auto_examples_technical_details_plot_skore_local_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_local_project.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_skore_local_project.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_skore_local_project.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_