8000 MAINT parameter validation for d2_absolute_error_score (#26066) · scikit-learn/scikit-learn@2a139fa · GitHub
[go: up one dir, main page]

Skip to content

Commit 2a139fa

Browse files
ansamzjeremiedbb
andauthored
MAINT parameter validation for d2_absolute_error_score (#26066)
Co-authored-by: jeremiedbb <jeremiedbb@yahoo.fr>
1 parent d4d9801 commit 2a139fa

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

sklearn/metrics/_regression.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,12 +1512,22 @@ def d2_pinball_score(
15121512
return np.average(output_scores, weights=avg_weights)
15131513

15141514

1515+
@validate_params(
1516+
{
1517+
"y_true": ["array-like"],
1518+
"y_pred": ["array-like"],
1519+
"sample_weight": ["array-like", None],
1520+
"multioutput": [
1521+
StrOptions({"raw_values", "uniform_average"}),
1522+
"array-like",
1523+
],
1524+
}
1525+
)
15151526
def d2_absolute_error_score(
15161527
y_true, y_pred, *, sample_weight=None, multioutput="uniform_average"
15171528
):
15181529
"""
1519-
:math:`D^2` regression score function, \
1520-
fraction of absolute error explained.
1530+
:math:`D^2` regression score function, fraction of absolute error explained.
15211531
15221532
Best possible score is 1.0 and it can be negative (because the model can be
15231533
arbitrarily worse). A model that always uses the empirical median of `y_true`
@@ -1536,7 +1546,7 @@ def d2_absolute_error_score(
15361546
y_pred : array-like of shape (n_samples,) or (n_samples, n_outputs)
15371547
Estimated target values.
15381548
1539-
sample_weight : array-like of shape (n_samples,), optional
1549+
sample_weight : array-like of shape (n_samples,), default=None
15401550
Sample weights.
15411551
15421552
multioutput : {'raw_values', 'uniform_average'} or array-like of shape \

sklearn/tests/test_public_functions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ def _check_function_param_validation(
176176
"sklearn.metrics.cohen_kappa_score",
177177
"sklearn.metrics.confusion_matrix",
178178
"sklearn.metrics.coverage_error",
179+
"sklearn.metrics.d2_absolute_error_score",
179180
"sklearn.metrics.d2_pinball_score",
180181
"sklearn.metrics.d2_tweedie_score",
181182
"sklearn.metrics.dcg_score",

0 commit comments

Comments
 (0)
0