summarize#
- CrossValidationReport.metrics.summarize(*, data_source='test', metric=None, metric_kwargs=None, response_method=None)[source]#
Report a set of metrics for our estimator.
- Parameters:
- data_source{“test”, “train”}, 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.
- metricstr, callable, scorer, or list of such instances or dict of such instances, default=None
The metric(s) to report. The possible values 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()orsklearn.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_predas the two first arguments. Additional arguments can be passed as keyword arguments and will be forwarded withmetric_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 viamake_scorer’sgreater_is_betterparameter.if a dict, the keys are used as metric names and the values are the metric functions (strings, callables, or scorers as described above).
if a list, each element can be any of the above types (strings, callables, scorers).
- 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:
MetricsSummaryDisplayA display containing the statistics for the metrics.
Examples
>>> from sklearn.datasets import load_breast_cancer >>> from sklearn.linear_model import LogisticRegression >>> from skore import CrossValidationReport >>> X, y = load_breast_cancer(return_X_y=True) >>> classifier = LogisticRegression(max_iter=10_000) >>> report = CrossValidationReport( ... classifier, X=X, y=y, splitter=2, pos_label=1 ... ) >>> report.metrics.summarize( ... metric=["precision", "recall"], ... ).frame(flat_index=False, favorability=True) LogisticRegression Favorability mean std Metric Precision 0.94... 0.02... (↗︎) Recall 0.96... 0.02... (↗︎)