8000 MAINT Parameters validation for sklearn.metrics.d2_tweedie_score by A-H-Mansoury · Pull Request #25975 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

MAINT Parameters validation for sklearn.metrics.d2_tweedie_score #25975

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion sklearn/metrics/_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,17 @@ def mean_gamma_deviance(y_true, y_pred, *, sample_weight=None):
return mean_tweedie_deviance(y_true, y_pred, sample_weight=sample_weight, power=2)


@validate_params(
{
"y_true": ["array-like"],
"y_pred": ["array-like"],
"sample_weight": ["array-like", None],
"power": [
Interval(Real, None, 0, closed="right"),
Interval(Real, 1, None, closed="left"),
],
}
)
def d2_tweedie_score(y_true, y_pred, *, sample_weight=None, power=0):
"""D^2 regression score function, fraction of Tweedie deviance explained.

Expand All @@ -1257,7 +1268,7 @@ def d2_tweedie_score(y_true, y_pred, *, sample_weight=None, power=0):
y_pred : array-like of shape (n_samples,)
Estimated target values.

sample_weight : array-like of shape (n_samples,), optional
sample_weight : array-like of shape (n_samples,), default=None
Sample weights.

power : float, default=0
Expand Down
1 change: 1 addition & 0 deletions sklearn/tests/test_public_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ def _check_function_param_validation(
"sklearn.metrics.confusion_matrix",
"sklearn.metrics.coverage_error",
"sklearn.metrics.d2_pinball_score",
"sklearn.metrics.d2_tweedie_score",
"sklearn.metrics.dcg_score",
"sklearn.metrics.det_curve",
"sklearn.metrics.f1_score",
Expand Down
0