.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/getting_started/plot_quick_start.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end <sphx_glr_download_auto_examples_getting_started_plot_quick_start.py>` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_getting_started_plot_quick_start.py: .. _example_quick_start: =========== Quick start =========== .. GENERATED FROM PYTHON SOURCE LINES 10-14 Machine learning evaluation and diagnostics =========================================== Evaluate your model using skore's :class:`~skore.CrossValidationReport`: .. GENERATED FROM PYTHON SOURCE LINES 16-26 .. code-block:: Python from sklearn.datasets import make_classification from sklearn.linear_model import LogisticRegression from skore import CrossValidationReport X, y = make_classification(n_classes=2, n_samples=100_000, n_informative=4) clf = LogisticRegression() cv_report = CrossValidationReport(clf, X, y) .. GENERATED FROM PYTHON SOURCE LINES 27-29 Display the help tree to see all the insights that are available to you (skore detected that you are doing binary classification): .. GENERATED FROM PYTHON SOURCE LINES 31-33 .. code-block:: Python cv_report.help() .. rst-class:: sphx-glr-script-out .. code-block:: none ╭─────────────────── Tools to diagnose estimator LogisticRegression ───────────────────╮ │ CrossValidationReport │ │ ├── .metrics │ │ │ ├── .accuracy(...) (↗︎) - Compute the accuracy score. │ │ │ ├── .brier_score(...) (↘︎) - Compute the Brier score. │ │ │ ├── .log_loss(...) (↘︎) - Compute the log loss. │ │ │ ├── .precision(...) (↗︎) - Compute the precision score. │ │ │ ├── .precision_recall(...) - Plot the precision-recall curve. │ │ │ ├── .recall(...) (↗︎) - Compute the recall score. │ │ │ ├── .roc(...) - Plot the ROC curve. │ │ │ ├── .roc_auc(...) (↗︎) - Compute the ROC AUC score. │ │ │ ├── .custom_metric(...) - Compute a custom metric. │ │ │ └── .report_metrics(...) - Report a set of metrics for our estimator. │ │ ├── .cache_predictions(...) - Cache the predictions for sub-estimators │ │ │ reports. │ │ ├── .clear_cache(...) - Clear the cache. │ │ └── Attributes │ │ ├── .X │ │ ├── .y │ │ ├── .estimator_ │ │ ├── .estimator_name_ │ │ ├── .estimator_reports_ │ │ └── .n_jobs │ │ │ │ │ │ Legend: │ │ (↗︎) higher is better (↘︎) lower is better │ ╰──────────────────────────────────────────────────────────────────────────────────────╯ .. GENERATED FROM PYTHON SOURCE LINES 34-35 Display the report metrics that was computed for you: .. GENERATED FROM PYTHON SOURCE LINES 37-40 .. code-block:: Python df_cv_report_metrics = cv_report.metrics.report_metrics() df_cv_report_metrics .. raw:: html <div class="output_subarea output_html rendered_html output_result"> <div> <style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead tr th { text-align: left; } .dataframe thead tr:last-of-type th { text-align: right; } </style> <table border="1" class="dataframe"> <thead> <tr> <th></th> <th></th> <th colspan="5" halign="left">LogisticRegression</th> </tr> <tr> <th></th> <th></th> <th>Split #0</th> <th>Split #1</th> <th>Split #2</th> <th>Split #3</th> <th>Split #4</th> </tr> <tr> <th>Metric</th> <th>Label / Average</th> <th></th> <th></th> <th></th> <th></th> <th></th> </tr> </thead> <tbody> <tr> <th rowspan="2" valign="top">Precision</th> <th>0</th> <td>0.746546</td> <td>0.744155</td> <td>0.740818</td> <td>0.751271</td> <td>0.747534</td> </tr> <tr> <th>1</th> <td>0.719169</td> <td>0.728469</td> <td>0.723992</td> <td>0.724621</td> <td>0.725310</td> </tr> <tr> <th rowspan="2" valign="top">Recall</th> <th>0</th> <td>0.702570</td> <td>0.719372</td> <td>0.714000</td> <td>0.709200</td> <td>0.712400</td> </tr> <tr> <th>1</th> <td>0.761524</td> <td>0.752725</td> <td>0.750200</td> <td>0.765200</td> <td>0.759400</td> </tr> <tr> <th>ROC AUC</th> <th></th> <td>0.800497</td> <td>0.798113</td> <td>0.798477</td> <td>0.802839</td> <td>0.801416</td> </tr> <tr> <th>Brier score</th> <th></th> <td>0.181144</td> <td>0.182536</td> <td>0.182259</td> <td>0.180057</td> <td>0.181266</td> </tr> </tbody> </table> </div> </div> <br /> <br /> .. GENERATED FROM PYTHON SOURCE LINES 41-42 Display the ROC curve that was generated for you: .. GENERATED FROM PYTHON SOURCE LINES 44-50 .. code-block:: Python import matplotlib.pyplot as plt roc_plot = cv_report.metrics.roc() roc_plot.plot() plt.tight_layout() .. image-sg:: /auto_examples/getting_started/images/sphx_glr_plot_quick_start_001.png :alt: plot quick start :srcset: /auto_examples/getting_started/images/sphx_glr_plot_quick_start_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 51-53 Skore project: storing some items ================================= .. GENERATED FROM PYTHON SOURCE LINES 55-56 From your Python code, create and load a skore :class:`~skore.Project`: .. GENERATED FROM PYTHON SOURCE LINES 58-62 .. code-block:: Python import skore my_project = skore.Project("my_project") .. GENERATED FROM PYTHON SOURCE LINES 72-74 This will create a skore project directory named ``my_project.skore`` in your current working directory. .. GENERATED FROM PYTHON SOURCE LINES 76-77 Store some previous results in the skore project for safe-keeping: .. GENERATED FROM PYTHON SOURCE LINES 79-82 .. code-block:: Python my_project.put("df_cv_report_metrics", df_cv_report_metrics) my_project.put("roc_plot", roc_plot) .. GENERATED FROM PYTHON SOURCE LINES 83-84 Retrieve what was stored: .. GENERATED FROM PYTHON SOURCE LINES 86-89 .. code-block:: Python df_get = my_project.get("df_cv_report_metrics") df_get .. raw:: html <div class="output_subarea output_html rendered_html output_result"> <div> <style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; } </style> <table border="1" class="dataframe"> <thead> <tr style="text-align: right;"> <th></th> <th></th> <th>(LogisticRegression, Split #0)</th> <th>(LogisticRegression, Split #1)</th> <th>(LogisticRegression, Split #2)</th> <th>(LogisticRegression, Split #3)</th> <th>(LogisticRegression, Split #4)</th> </tr> <tr> <th>Metric</th> <th>Label / Average</th> <th></th> <th></th> <th></th> <th></th> <th></th> </tr> </thead> <tbody> <tr> <th rowspan="2" valign="top">Precision</th> <th>0</th> <td>0.746546</td> <td>0.744155</td> <td>0.740818</td> <td>0.751271</td> <td>0.747534</td> </tr> <tr> <th>1</th> <td>0.719169</td> <td>0.728469</td> <td>0.723992</td> <td>0.724621</td> <td>0.725310</td> </tr> <tr> <th rowspan="2" valign="top">Recall</th> <th>0</th> <td>0.702570</td> <td>0.719372</td> <td>0.714000</td> <td>0.709200</td> <td>0.712400</td> </tr> <tr> <th>1</th> <td>0.761524</td> <td>0.752725</td> <td>0.750200</td> <td>0.765200</td> <td>0.759400</td> </tr> <tr> <th>ROC AUC</th> <th></th> <td>0.800497</td> <td>0.798113</td> <td>0.798477</td> <td>0.802839</td> <td>0.801416</td> </tr> <tr> <th>Brier score</th> <th></th> <td>0.181144</td> <td>0.182536</td> <td>0.182259</td> <td>0.180057</td> <td>0.181266</td> </tr> </tbody> </table> </div> </div> <br /> <br /> .. GENERATED FROM PYTHON SOURCE LINES 93-96 .. admonition:: What's next? For a more in-depth guide, see our :ref:`example_skore_getting_started` page! .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.685 seconds) .. _sphx_glr_download_auto_examples_getting_started_plot_quick_start.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_quick_start.ipynb <plot_quick_start.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_quick_start.py <plot_quick_start.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_quick_start.zip <plot_quick_start.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_