Skip to content

Commit fc6776d

Browse files
chore(skore)!: Rename scoring to metric (#2189)
Closes #2106 Breaking changes since changes in the API. Plenty of changes to make the naming consistant everywhere, from the API to the variable names and test function names.
1 parent 2f7bd86 commit fc6776d

File tree

17 files changed

+311
-313
lines changed

17 files changed

+311
-313
lines changed

examples/model_evaluation/plot_estimator_report.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,12 @@ def operational_decision_cost(y_true, y_pred, amount):
290290
# that we can compute some additional metrics without having to recompute the
291291
# the predictions.
292292
report.metrics.summarize(
293-
scoring={
293+
metric={
294294
"Precision": "precision",
295295
"Recall": "recall",
296296
"Operational Decision Cost": operational_decision_cost,
297297
},
298-
scoring_kwargs={"amount": amount, "response_method": "predict"},
298+
metric_kwargs={"amount": amount, "response_method": "predict"},
299299
).frame()
300300

301301
# %%
@@ -311,7 +311,7 @@ def operational_decision_cost(y_true, y_pred, amount):
311311
operational_decision_cost, response_method="predict", amount=amount
312312
)
313313
report.metrics.summarize(
314-
scoring={
314+
metric={
315315
"F1 Score": f1_scorer,
316316
"Operational Decision Cost": operational_decision_cost_scorer,
317317
},

examples/use_cases/plot_employee_salaries.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,10 +308,10 @@ def periodic_spline_transformer(period, n_splines=None, degree=3):
308308
# %%
309309
from sklearn.metrics import get_scorer
310310

311-
scoring = {"R²": "r2", "RMSE": "rmse", "MAE": get_scorer("neg_mean_absolute_error")}
312-
scoring_kwargs = {"response_method": "predict"}
311+
metric = {"R²": "r2", "RMSE": "rmse", "MAE": get_scorer("neg_mean_absolute_error")}
312+
metric_kwargs = {"response_method": "predict"}
313313

314-
comparator.metrics.summarize(scoring=scoring, scoring_kwargs=scoring_kwargs).frame()
314+
comparator.metrics.summarize(metric=metric, metric_kwargs=metric_kwargs).frame()
315315

316316
# %%
317317
# Finally, we can even get a deeper understanding by analyzing each split in the

skore/src/skore/_sklearn/_comparison/metrics_accessor.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
from skore._sklearn.types import (
2525
_DEFAULT,
2626
Aggregate,
27+
Metric,
2728
PositiveLabel,
28-
Scoring,
2929
YPlotData,
3030
)
3131
from skore._utils._accessor import (
@@ -56,8 +56,8 @@ def summarize(
5656
data_source: DataSource = "test",
5757
X: ArrayLike | None = None,
5858
y: ArrayLike | None = None,
59-
scoring: Scoring | list[Scoring] | dict[str, Scoring] | None = None,
60-
scoring_kwargs: dict[str, Any] | None = None,
59+
metric: Metric | list[Metric] | dict[str, Metric] | None = None,
60+
metric_kwargs: dict[str, Any] | None = None,
6161
pos_label: PositiveLabel | None = _DEFAULT,
6262
indicator_favorability: bool = False,
6363
flat_index: bool = False,
@@ -84,7 +84,7 @@ def summarize(
8484
New target on which to compute the metric. By default, we use the target
8585
provided when creating the report.
8686
87-
scoring : str, callable, scorer, or list of such instances or dict of such \
87+
metric : str, callable, scorer, or list of such instances or dict of such \
8888
instances, default=None
8989
The metrics to report. The possible values (whether or not in a list) are:
9090
@@ -94,16 +94,16 @@ def summarize(
9494
the built-in metrics or the scikit-learn scorers, respectively.
9595
- if a callable, it should take as arguments `y_true`, `y_pred` as the two
9696
first arguments. Additional arguments can be passed as keyword arguments
97-
and will be forwarded with `scoring_kwargs`. No favorability indicator can
97+
and will be forwarded with `metric_kwargs`. No favorability indicator can
9898
be displayed in this case.
9999
- if the callable API is too restrictive (e.g. need to pass
100100
same parameter name with different values), you can use scikit-learn
101101
scorers as provided by :func:`sklearn.metrics.make_scorer`. In this case,
102102
the metric favorability will only be displayed if it is given explicitly
103103
via `make_scorer`'s `greater_is_better` parameter.
104104
105-
scoring_kwargs : dict, default=None
106-
The keyword arguments to pass to the scoring functions.
105+
metric_kwargs : dict, default=None
106+
The keyword arguments to pass to the metric functions.
107107
108108
pos_label : int, float, bool, str or None, default=_DEFAULT
109109
The label to consider as the positive class when computing the metric. Use
@@ -145,7 +145,7 @@ class is set to the one provided when creating the report. If `None`,
145145
... [estimator_report_1, estimator_report_2]
146146
... )
147147
>>> comparison_report.metrics.summarize(
148-
... scoring=["precision", "recall"],
148+
... metric=["precision", "recall"],
149149
... pos_label=1,
150150
... ).frame()
151151
Estimator LogisticRegression_1 LogisticRegression_2
@@ -158,9 +158,9 @@ class is set to the one provided when creating the report. If `None`,
158158
data_source=data_source,
159159
X=X,
160160
y=y,
161-
scoring=scoring,
161+
metric=metric,
162162
pos_label=pos_label,
163-
scoring_kwargs=scoring_kwargs,
163+
metric_kwargs=metric_kwargs,
164164
indicator_favorability=indicator_favorability,
165165
aggregate=aggregate,
166166
)
@@ -416,7 +416,7 @@ def accuracy(
416416
Accuracy 0.96... 0.96...
417417
"""
418418
return self.summarize(
419-
scoring=["accuracy"],
419+
metric=["accuracy"],
420420
data_source=data_source,
421421
X=X,
422422
y=y,
@@ -518,12 +518,12 @@ class is set to the one provided when creating the report. If `None`,
518518
1 0.96... 0.96...
519519
"""
520520
return self.summarize(
521-
scoring=["precision"],
521+
metric=["precision"],
522522
data_source=data_source,
523523
X=X,
524524
y=y,
525525
pos_label=pos_label,
526-
scoring_kwargs={"average": average},
526+
metric_kwargs={"average": average},
527527
aggregate=aggregate,
528528
).frame()
529529

@@ -623,12 +623,12 @@ class is set to the one provided when creating the report. If `None`,
623623
1 0.977... 0.977...
624624
"""
625625
return self.summarize(
626-
scoring=["recall"],
626+
metric=["recall"],
627627
data_source=data_source,
628628
X=X,
629629
y=y,
630630
pos_label=pos_label,
631-
scoring_kwargs={"average": average},
631+
metric_kwargs={"average": average},
632632
aggregate=aggregate,
633633
).frame()
634634

@@ -691,7 +691,7 @@ def brier_score(
691691
Brier score 0.025... 0.025...
692692
"""
693693
return self.summarize(
694-
scoring=["brier_score"],
694+
metric=["brier_score"],
695695
data_source=data_source,
696696
X=X,
697697
y=y,
@@ -793,11 +793,11 @@ def roc_auc(
793793
ROC AUC 0.99... 0.99...
794794
"""
795795
return self.summarize(
796-
scoring=["roc_auc"],
796+
metric=["roc_auc"],
797797
data_source=data_source,
798798
X=X,
799799
y=y,
800-
scoring_kwargs={"average": average, "multi_class": multi_class},
800+
metric_kwargs={"average": average, "multi_class": multi_class},
801801
aggregate=aggregate,
802802
).frame()
803803

@@ -860,7 +860,7 @@ def log_loss(
860860
Log loss 0.082... 0.082...
861861
"""
862862
return self.summarize(
863-
scoring=["log_loss"],
863+
metric=["log_loss"],
864864
data_source=data_source,
865865
X=X,
866866
y=y,
@@ -937,11 +937,11 @@ def r2(
937937
R² 0.43... 0.43...
938938
"""
939939
return self.summarize(
940-
scoring=["r2"],
940+
metric=["r2"],
941941
data_source=data_source,
942942
X=X,
943943
y=y,
944-
scoring_kwargs={"multioutput": multioutput},
944+
metric_kwargs={"multioutput": multioutput},
945945
aggregate=aggregate,
946946
).frame()
947947

@@ -1015,11 +1015,11 @@ def rmse(
10151015
RMSE 55.726... 55.726...
10161016
"""
10171017
return self.summarize(
1018-
scoring=["rmse"],
1018+
metric=["rmse"],
10191019
data_source=data_source,
10201020
X=X,
10211021
y=y,
1022-
scoring_kwargs={"multioutput": multioutput},
1022+
metric_kwargs={"multioutput": multioutput},
10231023
aggregate=aggregate,
10241024
).frame()
10251025

@@ -1124,7 +1124,7 @@ def custom_metric(
11241124
)
11251125
scoring = {metric_name: scorer} if metric_name is not None else [scorer]
11261126
return self.summarize(
1127-
scoring=scoring,
1127+
metric=scoring,
11281128
data_source=data_source,
11291129
X=X,
11301130
y=y,

0 commit comments

Comments
 (0)