Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e9c8885

Browse filesBrowse files
ansamzjeremiedbb
authored and
Itay
committed
MAINT parameter validation for d2_absolute_error_score (scikit-learn#26066)
Co-authored-by: jeremiedbb <jeremiedbb@yahoo.fr>
1 parent 6cd7481 commit e9c8885
Copy full SHA for e9c8885

File tree

2 files changed

+14
-3
lines changed
Filter options

2 files changed

+14
-3
lines changed

‎sklearn/metrics/_regression.py

Copy file name to clipboardExpand all lines: sklearn/metrics/_regression.py
+13-3Lines 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

Copy file name to clipboardExpand all lines: sklearn/tests/test_public_functions.py
+1Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.