Quick start#

Machine learning evaluation and diagnostics#

Evaluate your model using skore’s CrossValidationReport:

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)

Display the help tree to see all the insights that are available to you (skore detected that you are doing binary classification):

╭─────────────────── 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                                             │
╰──────────────────────────────────────────────────────────────────────────────────────╯

Display the report metrics that was computed for you:

LogisticRegression
Split #0 Split #1 Split #2 Split #3 Split #4
Metric Label / Average
Precision 0 0.746546 0.744155 0.740818 0.751271 0.747534
1 0.719169 0.728469 0.723992 0.724621 0.725310
Recall 0 0.702570 0.719372 0.714000 0.709200 0.712400
1 0.761524 0.752725 0.750200 0.765200 0.759400
ROC AUC 0.800497 0.798113 0.798477 0.802839 0.801416
Brier score 0.181144 0.182536 0.182259 0.180057 0.181266


Display the ROC curve that was generated for you:

import matplotlib.pyplot as plt

roc_plot = cv_report.metrics.roc()
roc_plot.plot()
plt.tight_layout()
plot quick start

Skore project: storing some items#

From your Python code, create and load a skore Project:

import skore

my_project = skore.Project("my_project")

This will create a skore project directory named my_project.skore in your current working directory.

Store some previous results in the skore project for safe-keeping:

my_project.put("df_cv_report_metrics", df_cv_report_metrics)
my_project.put("roc_plot", roc_plot)

Retrieve what was stored:

df_get = my_project.get("df_cv_report_metrics")
df_get
(LogisticRegression, Split #0) (LogisticRegression, Split #1) (LogisticRegression, Split #2) (LogisticRegression, Split #3) (LogisticRegression, Split #4)
Metric Label / Average
Precision 0 0.746546 0.744155 0.740818 0.751271 0.747534
1 0.719169 0.728469 0.723992 0.724621 0.725310
Recall 0 0.702570 0.719372 0.714000 0.709200 0.712400
1 0.761524 0.752725 0.750200 0.765200 0.759400
ROC AUC 0.800497 0.798113 0.798477 0.802839 0.801416
Brier score 0.181144 0.182536 0.182259 0.180057 0.181266


What’s next?

For a more in-depth guide, see our Skore: getting started page!

Total running time of the script: (0 minutes 1.685 seconds)

Gallery generated by Sphinx-Gallery