The skore API#

This example illustrates the consistent API shared by skore reports and displays. Reports expose the same accessors (data, metrics, inspection), and each method that produces a visualization returns a Display object. All displays implement a common interface: plot(), frame(), set_style(), and help().

Reports share the same accessor structure#

EstimatorReport, CrossValidationReport, and ComparisonReport all expose the same accessors where applicable:

  • data: dataset analysis

  • metrics: performance metrics and related displays (e.g. ROC, confusion matrix)

  • inspection: model inspection (e.g. coefficients, feature importance)

The data accessor is only available on EstimatorReport and CrossValidationReport because when comparing models, the input data can be different and thus one can access the underlying reports to inspect the data.

Calling a method on these accessors returns a Display object. The same pattern holds across report types, so once you know one, you know them all.

Minimal setup: one report and one display#

We build a simple EstimatorReport and use it to show how accessors return displays and how those displays behave.

from sklearn.datasets import load_breast_cancer
from sklearn.linear_model import LogisticRegression
from skore import EstimatorReport, train_test_split
from skrub import tabular_pipeline

X, y = load_breast_cancer(return_X_y=True, as_frame=True)
split_data = train_test_split(X=X, y=y, random_state=42, as_dict=True)
estimator = tabular_pipeline(LogisticRegression())

report = EstimatorReport(estimator, **split_data)
╭────────────────────── HighClassImbalanceTooFewExamplesWarning ───────────────────────╮
│ It seems that you have a classification problem with at least one class with fewer   │
│ than 100 examples in the test set. In this case, using train_test_split may not be a │
│ good idea because of high variability in the scores obtained on the test set. We     │
│ suggest three options to tackle this challenge: you can increase test_size, collect  │
│ more data, or use skore's CrossValidationReport with the `splitter` parameter of     │
│ your choice.                                                                         │
╰──────────────────────────────────────────────────────────────────────────────────────╯
╭───────────────────────────────── ShuffleTrueWarning ─────────────────────────────────╮
│ We detected that the `shuffle` parameter is set to `True` either explicitly or from  │
│ its default value. In case of time-ordered events (even if they are independent),    │
│ this will result in inflated model performance evaluation because natural drift will │
│ not be taken into account. We recommend setting the shuffle parameter to `False` in  │
│ order to ensure the evaluation process is really representative of your production   │
│ release process.                                                                     │
╰──────────────────────────────────────────────────────────────────────────────────────╯

Data accessor: report.data.analyze() returns a display#

The data accessor provides dataset summaries. Its analyze() method returns a TableReportDisplay.



Every display implements the same API. You can:

  • Plot it (with optional backend and style):

data_display.plot(kind="dist", x="mean radius", y="mean texture")
plot skore api

You can set the style of the plot via set_style() and then call plot():

data_display.set_style(scatterplot_kwargs={"color": "orange", "alpha": 1.0})
data_display.plot(kind="dist", x="mean radius", y="mean texture")
plot skore api
  • Export the underlying data as a DataFrame:

mean radius mean texture mean perimeter mean area mean smoothness mean compactness mean concavity mean concave points mean symmetry mean fractal dimension radius error texture error perimeter error area error smoothness error compactness error concavity error concave points error symmetry error fractal dimension error worst radius worst texture worst perimeter worst area worst smoothness worst compactness worst concavity worst concave points worst symmetry worst fractal dimension target
0 12.89 13.12 81.89 515.9 0.06955 0.03729 0.02260 0.01171 0.1337 0.05581 0.1532 0.4690 1.115 12.68 0.004731 0.013450 0.016520 0.005905 0.01619 0.002081 13.62 15.54 87.40 577.0 0.09616 0.1147 0.11860 0.05366 0.2309 0.06915 1
1 13.40 20.52 88.64 556.7 0.11060 0.14690 0.14450 0.08172 0.2116 0.07325 0.3906 0.9306 3.093 33.67 0.005414 0.022650 0.034520 0.013340 0.01705 0.004005 16.41 29.66 113.30 844.4 0.15740 0.3856 0.51060 0.20510 0.3585 0.11090 0
2 12.96 18.29 84.18 525.2 0.07351 0.07899 0.04057 0.01883 0.1874 0.05899 0.2357 1.2990 2.397 20.21 0.003629 0.037130 0.034520 0.010650 0.02632 0.003705 14.13 24.61 96.31 621.9 0.09329 0.2318 0.16040 0.06608 0.3207 0.07247 1
3 17.75 28.03 117.30 981.6 0.09997 0.13140 0.16980 0.08293 0.1713 0.05916 0.3897 1.0770 2.873 43.95 0.004714 0.020150 0.036970 0.011100 0.01237 0.002556 21.53 38.54 145.40 1437.0 0.14010 0.3762 0.63990 0.19700 0.2972 0.09075 0
4 20.58 22.14 134.70 1290.0 0.09090 0.13480 0.16400 0.09561 0.1765 0.05024 0.8601 1.4800 7.029 111.70 0.008124 0.036110 0.054890 0.027650 0.03176 0.002365 23.24 27.84 158.30 1656.0 0.11780 0.2920 0.38610 0.19200 0.2909 0.05865 0
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
564 14.64 15.24 95.77 651.9 0.11320 0.13390 0.09966 0.07064 0.2116 0.06346 0.5115 0.7372 3.814 42.76 0.005508 0.044120 0.044360 0.016230 0.02427 0.004841 16.34 18.24 109.40 803.6 0.12770 0.3089 0.26040 0.13970 0.3151 0.08473 1
565 14.45 20.22 94.49 642.7 0.09872 0.12060 0.11800 0.05980 0.1950 0.06466 0.2092 0.6509 1.446 19.42 0.004044 0.015970 0.020000 0.007303 0.01522 0.001976 18.33 30.12 117.90 1044.0 0.15520 0.4056 0.49670 0.18380 0.4753 0.10130 0
566 11.04 16.83 70.92 373.2 0.10770 0.07804 0.03046 0.02480 0.1714 0.06340 0.1967 1.3870 1.342 13.54 0.005158 0.009355 0.010560 0.007483 0.01718 0.002198 12.41 26.44 79.93 471.4 0.13690 0.1482 0.10670 0.07431 0.2998 0.07881 1
567 19.81 22.15 130.00 1260.0 0.09831 0.10270 0.14790 0.09498 0.1582 0.05395 0.7582 1.0170 5.865 112.40 0.006494 0.018930 0.033910 0.015210 0.01356 0.001997 27.32 30.88 186.80 2398.0 0.15120 0.3150 0.53720 0.23880 0.2768 0.07615 0
568 10.26 12.22 65.75 321.6 0.09996 0.07542 0.01923 0.01968 0.1800 0.06569 0.1911 0.5477 1.348 11.88 0.005682 0.013650 0.008496 0.006929 0.01938 0.002371 11.38 15.65 73.23 394.5 0.13430 0.1650 0.08615 0.06696 0.2937 0.07722 1

569 rows × 31 columns



Metrics accessor: same idea, same display API#

The metrics accessor exposes methods such as confusion_matrix(), roc_curve(), precision_recall(), and prediction_error(). Each returns a display (e.g. ConfusionMatrixDisplay) with the same interface: plot(), frame(), set_style(), help().

metrics_display = report.metrics.confusion_matrix()
metrics_display.help()


true_label predicted_label value threshold split estimator data_source
356 0 0 53 0.527467 None LogisticRegression test
357 0 1 1 0.527467 None LogisticRegression test
358 1 0 0 0.527467 None LogisticRegression test
359 1 1 89 0.527467 None LogisticRegression test


Draw the confusion matrix by calling plot():

Confusion Matrix Decision threshold: 0.50 Data source: Test set

Inspection accessor#

The inspection accessor exposes model-specific displays (e.g. coefficients() for linear models, impurity_decrease() for trees). These also return Display objects with the same plot(), frame(), set_style(), and help() methods.

inspection_display = report.inspection.coefficients()
inspection_display.plot(select_k=15, sorting_order="descending")
Coefficients of LogisticRegression

Same API with CrossValidationReport#

The same accessors and display API apply to CrossValidationReport. We use the same dataset and model; only the report type changes.

Again: data, metrics, and inspection return displays with plot(), frame(), and set_style().

cv_report.data.analyze().plot(kind="dist", x="mean radius", y="mean texture")
plot skore api
cv_report.metrics.confusion_matrix().plot()
Confusion Matrix Decision threshold: 0.50 Data source: Test set
cv_report.inspection.coefficients().plot(select_k=10, sorting_order="descending")
Coefficients of LogisticRegression

The same accessors and display API apply to ComparisonReport (metrics and inspection; no data accessor when comparing reports).

Summary#

  • Reports (Estimator, CrossValidation, Comparison) use the same accessor layout: report.data, report.metrics, report.inspection (where applicable).

  • Accessor methods that produce figures or tables return Display objects.

  • Displays share a single, predictable API:

    • plot(**kwargs) — render the visualization

    • frame(**kwargs) — return the data as a pandas.DataFrame

    • set_style(policy=..., **kwargs) — customize appearance

    • help() — show available options

This consistency makes it easy to switch between report types and to reuse the same workflow across data, metrics, and inspection.

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

Gallery generated by Sphinx-Gallery