Skip to content

Commit

Permalink
MAINT Parameters validation for sklearn.utils.resample (#26139)
Browse files Browse the repository at this point in the history
elabongaatuo authored Apr 14, 2023
1 parent d8b05e0 commit 10344f9
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions sklearn/tests/test_public_functions.py
Original file line number Diff line number Diff line change
@@ -254,6 +254,7 @@ def _check_function_param_validation(
"sklearn.tree.export_text",
"sklearn.tree.plot_tree",
"sklearn.utils.gen_batches",
"sklearn.utils.resample",
]


8 changes: 8 additions & 0 deletions sklearn/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -465,6 +465,14 @@ def _get_column_indices(X, key):
)


@validate_params(
{
"replace": ["boolean"],
"n_samples": [Interval(numbers.Integral, 1, None, closed="left"), None],
"random_state": ["random_state"],
"stratify": ["array-like", None],
}
)
def resample(*arrays, replace=True, n_samples=None, random_state=None, stratify=None):
"""Resample arrays or sparse matrices in a consistent way.

0 comments on commit 10344f9

Please sign in to comment.