Skip to content

Commit 4772ea8

Browse files
jiawei-zhang-aglemaitrejeremiedbb
authored
MAINT Parameters validation for sklearn.linear_model.enet_path (scikit-learn#26379)
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com> Co-authored-by: jeremie du boisberranger <jeremiedbb@yahoo.fr>
1 parent 9cabb12 commit 4772ea8

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

sklearn/linear_model/_coordinate_descent.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from ..base import MultiOutputMixin, RegressorMixin, _fit_context
2020
from ..model_selection import check_cv
2121
from ..utils import check_array, check_scalar
22-
from ..utils._param_validation import Interval, StrOptions
22+
from ..utils._param_validation import Interval, StrOptions, validate_params
2323
from ..utils.extmath import safe_sparse_dot
2424
from ..utils.parallel import Parallel, delayed
2525
from ..utils.validation import (
@@ -344,6 +344,25 @@ def lasso_path(
344344
)
345345

346346

347+
@validate_params(
348+
{
349+
"X": ["array-like", "sparse matrix"],
350+
"y": ["array-like", "sparse matrix"],
351+
"l1_ratio": [Interval(Real, 0.0, 1.0, closed="both")],
352+
"eps": [Interval(Real, 0.0, None, closed="neither")],
353+
"n_alphas": [Interval(Integral, 1, None, closed="left")],
354+
"alphas": ["array-like", None],
355+
"precompute": [StrOptions({"auto"}), "boolean", "array-like"],
356+
"Xy": ["array-like", None],
357+
"copy_X": ["boolean"],
358+
"coef_init": ["array-like", None],
359+
"verbose": ["verbose"],
360+
"return_n_iter": ["boolean"],
361+
"positive": ["boolean"],
362+
"check_input": ["boolean"],
363+
},
364+
prefer_skip_nested_validation=True,
365+
)
347366
def enet_path(
348367
X,
349368
y,
@@ -408,7 +427,7 @@ def enet_path(
408427
n_alphas : int, default=100
409428
Number of alphas along the regularization path.
410429
411-
alphas : ndarray, default=None
430+
alphas : array-like, default=None
412431
List of alphas where to compute the models.
413432
If None alphas are set automatically.
414433
@@ -426,7 +445,7 @@ def enet_path(
426445
copy_X : bool, default=True
427446
If ``True``, X will be copied; else, it may be overwritten.
428447
429-
coef_init : ndarray of shape (n_features, ), default=None
448+
coef_init : array-like of shape (n_features, ), default=None
430449
The initial values of the coefficients.
431450
432451
verbose : bool or int, default=False

sklearn/tests/test_public_functions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ def _check_function_param_validation(
199199
"sklearn.inspection.permutation_importance",
200200
"sklearn.isotonic.check_increasing",
201201
"sklearn.isotonic.isotonic_regression",
202+
"sklearn.linear_model.enet_path",
202203
"sklearn.linear_model.orthogonal_mp",
203204
"sklearn.linear_model.orthogonal_mp_gram",
204205
"sklearn.linear_model.ridge_regression",

0 commit comments

Comments
 (0)