Skip to content

Commit 70f72c6

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

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

sklearn/linear_model/_coordinate_descent.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,23 @@ def _alpha_grid(
170170
return np.geomspace(alpha_max, alpha_max * eps, num=n_alphas)
171171

172172

173+
@validate_params(
174+
{
175+
"X": ["array-like", "sparse matrix"],
176+
"y": ["array-like", "sparse matrix"],
177+
"eps": [Interval(Real, 0, None, closed="neither")],
178+
"n_alphas": [Interval(Integral, 1, None, closed="left")],
179+
"alphas": ["array-like", None],
180+
"precompute": [StrOptions({"auto"}), "boolean", "array-like"],
181+
"Xy": ["array-like", None],
182+
"copy_X": ["boolean"],
183+
"coef_init": ["array-like", None],
184+
"verbose": ["verbose"],
185+
"return_n_iter": ["boolean"],
186+
"positive": ["boolean"],
187+
},
188+
prefer_skip_nested_validation=True,
189+
)
173190
def lasso_path(
174191
X,
175192
y,
@@ -224,7 +241,7 @@ def lasso_path(
224241
n_alphas : int, default=100
225242
Number of alphas along the regularization path.
226243
227-
alphas : ndarray, default=None
244+
alphas : array-like, default=None
228245
List of alphas where to compute the models.
229246
If ``None`` alphas are set automatically.
230247
@@ -242,7 +259,7 @@ def lasso_path(
242259
copy_X : bool, default=True
243260
If ``True``, X will be copied; else, it may be overwritten.
244261
245-
coef_init : ndarray of shape (n_features, ), default=None
262+
coef_init : array-like of shape (n_features, ), default=None
246263
The initial values of the coefficients.
247264
248265
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
@@ -200,6 +200,7 @@ def _check_function_param_validation(
200200
"sklearn.isotonic.check_increasing",
201201
"sklearn.isotonic.isotonic_regression",
202202
"sklearn.linear_model.enet_path",
203+
"sklearn.linear_model.lasso_path",
203204
"sklearn.linear_model.orthogonal_mp",
204205
"sklearn.linear_model.orthogonal_mp_gram",
205206
"sklearn.linear_model.ridge_regression",

0 commit comments

Comments
 (0)