Skip to content

Commit

Permalink
MAINT Parameters validation for sklearn.isotonic.isotonic_regression (s…
Browse files Browse the repository at this point in the history
…cikit-learn#26257)

Co-authored-by: jeremie du boisberranger <[email protected]>
  • Loading branch information
2 people authored and punndcoder28 committed Jul 29, 2023
1 parent 6089b20 commit 50f66cb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
12 changes: 11 additions & 1 deletion sklearn/isotonic.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from ._isotonic import _inplace_contiguous_isotonic_regression, _make_unique
from .base import BaseEstimator, RegressorMixin, TransformerMixin, _fit_context
from .utils import check_array, check_consistent_length
from .utils._param_validation import Interval, StrOptions
from .utils._param_validation import Interval, StrOptions, validate_params
from .utils.validation import _check_sample_weight, check_is_fitted

__all__ = ["check_increasing", "isotonic_regression", "IsotonicRegression"]
Expand Down Expand Up @@ -79,6 +79,16 @@ def check_increasing(x, y):
return increasing_bool


@validate_params(
{
"y": ["array-like"],
"sample_weight": ["array-like", None],
"y_min": [Interval(Real, None, None, closed="both"), None],
"y_max": [Interval(Real, None, None, closed="both"), None],
"increasing": ["boolean"],
},
prefer_skip_nested_validation=True,
)
def isotonic_regression(
y, *, sample_weight=None, y_min=None, y_max=None, increasing=True
):
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 @@ -178,6 +178,7 @@ def _check_function_param_validation(
"sklearn.feature_selection.r_regression",
"sklearn.inspection.partial_dependence",
"sklearn.inspection.permutation_importance",
"sklearn.isotonic.isotonic_regression",
"sklearn.linear_model.orthogonal_mp",
"sklearn.linear_model.ridge_regression",
"sklearn.metrics.accuracy_score",
Expand Down

0 comments on commit 50f66cb

Please sign in to comment.