CalibrationDisplay#
- class skore.CalibrationDisplay(*, calibration_report, report_type, report_pos_label=None)[source]#
Calibration curve visualization.
- Parameters:
- calibration_reportpandas.DataFrame
Calibration report of the estimator. Its columns are
estimator,data_source,split,label,predicted_probability, andfraction_of_positives.- report_type{“estimator”, “cross-validation”, “comparison-estimator”, “comparison-cross-validation”}
Report type from which the display is created.
- report_pos_labelint, float, bool, str or None, default=None
Positive class label configured on the report.
Examples
>>> from sklearn.datasets import make_classification >>> from sklearn.linear_model import LogisticRegression >>> from skore import evaluate >>> X, y = make_classification( ... n_samples=100_000, n_features=20, n_informative=2, n_redundant=10, ... random_state=42) >>> report = evaluate(LogisticRegression(), X, y, splitter=0.2) >>> display = report.inspection.calibration_curve(n_bins="auto", strategy="uniform") >>> display.frame().head(5) predicted_probability fraction_of_positives data_source label 0 0.013323 0.018338 test 0 1 0.052453 0.049888 test 0 2 0.088494 0.093787 test 0 3 0.124554 0.113264 test 0 4 0.160065 0.145329 test 0
- frame(*, label=<DEFAULT>)[source]#
Return the data used for the display as a DataFrame.
- Parameters:
- labelint, float, bool, str or None, default=report pos_label
The class whose curve to select. Use
Noneto show all classes.
- Returns:
- DataFrame
- The returned frame always contains:
predicted_probability
fraction_of_positives
data_source
- It also contains
labelwhenlabel=None(one-vs-rest view). - When a specific label is selected, the
labelcolumn is dropped from - the output to provide a single-curve table.
- Depending on the report type,
estimatorand/orsplitmetadata may - be removed from the returned frame.
- property labels#
Return the list of labels available in the calibration data.
- plot(*, label=<DEFAULT>)[source]#
Plot the calibration curve.
- Parameters:
- labelint, float, bool, str or None, default=report pos_label
The class whose curve to plot. Use
Noneto show all classes.
- Returns:
- matplotlib.figure.Figure
Examples
>>> from sklearn.datasets import make_classification >>> from sklearn.linear_model import LogisticRegression >>> from skore import evaluate >>> X, y = make_classification( ... n_samples=100_000, n_features=20, n_informative=2, n_redundant=10, ... random_state=42) >>> report = evaluate(LogisticRegression(), X, y, splitter=0.2) >>> display = report.inspection.calibration_curve() >>> display.plot()
- set_style(*, policy='update', line_kwargs=None, ax_set_kwargs=None)[source]#
Set the style parameters for the display.
- Parameters:
- policy{“override”, “update”}, default=”update”
Policy to use when setting the style parameters. If “override”, existing settings are set to the provided values. If “update”, existing settings are not changed; only settings that were previously unset are changed.
- line_kwargsdict, default=None
Keyword arguments passed to
seaborn.lineplot().- ax_set_kwargsdict, default=None
Keyword arguments passed to
matplotlib.axes.Axes.set(). Useful keys includexlabel,ylabel,xlim, andylim.
- Returns:
- None
- static style_plot(plot_func)[source]#
Apply consistent style to skore displays.
This decorator: 1. Applies default style settings 2. Runs
plot_funcunderplt.ioff()so figures are not shown until returned 3. CallsFigure.tight_layout()on the returned figure when applicable 4. Restores the original style settings- Parameters:
- plot_funccallable
The plot function to be decorated.
- Returns:
- callable
The decorated plot function.