summarize#

ComparisonReport.metrics.summarize(*, data_source='test', metric=None, metric_kwargs=None, response_method=None)[source]#

Report a set of metrics for the estimators.

Parameters:
data_source{“test”, “train”, “both”}, default=”test”

The data source to use.

  • “test” : use the test set provided when creating the report.

  • “train” : use the train set provided when creating the report.

  • “both” : use both the train and test sets to compute the metrics and present them side-by-side.

metricstr, callable, scorer, or list of such instances or dict of such instances, default=None

The metrics to report. The possible values (whether or not in a list) are:

  • if a string, either one of the built-in metrics or a scikit-learn scorer name. You can get the possible list of string using report.metrics.help() or sklearn.metrics.get_scorer_names() for the built-in metrics or the scikit-learn scorers, respectively.

  • if a callable, it should take as arguments y_true, y_pred as the two first arguments. Additional arguments can be passed as keyword arguments and will be forwarded with metric_kwargs. No favorability indicator can be displayed in this case.

  • if the callable API is too restrictive (e.g. need to pass same parameter name with different values), you can use scikit-learn scorers as provided by sklearn.metrics.make_scorer(). In this case, the metric favorability will only be displayed if it is given explicitly via make_scorer’s greater_is_better parameter.

metric_kwargsdict, default=None

The keyword arguments to pass to the metric functions.

response_method{“predict”, “predict_proba”, “predict_log_proba”, “decision_function”} or list of such str, default=None

The estimator’s method to be invoked to get the predictions. Only necessary for custom metrics.

Returns:
MetricsSummaryDisplay

A display containing the statistics for the metrics.

Examples

>>> from sklearn.datasets import load_breast_cancer
>>> from sklearn.linear_model import LogisticRegression
>>> from skore import train_test_split
>>> from skore import ComparisonReport, EstimatorReport
>>> X, y = load_breast_cancer(return_X_y=True)
>>> split_data = train_test_split(X=X, y=y, random_state=42, as_dict=True)
>>> estimator_1 = LogisticRegression(max_iter=10000, random_state=42)
>>> estimator_report_1 = EstimatorReport(estimator_1, **split_data, pos_label=1)
>>> estimator_2 = LogisticRegression(max_iter=10000, random_state=43)
>>> estimator_report_2 = EstimatorReport(estimator_2, **split_data, pos_label=1)
>>> comparison_report = ComparisonReport(
...     [estimator_report_1, estimator_report_2]
... )
>>> comparison_report.metrics.summarize(
...     metric=["precision", "recall"],
... ).frame()
Estimator       LogisticRegression_1  LogisticRegression_2
Metric
Precision                    0.96...               0.96...
Recall                       0.97...               0.97...