lasso_path – Lasso with CV-selected alpha (LassoCV).#
Back to family axis | Back to L4 | Browse all options
Operational op under axis
family, sub-layerL4_A_model_selection, layerl4. Standalone callable:mf.functions.lasso_path_fit.
Function signature#
mf.functions.lasso_path_fit(
X: np.ndarray | pd.DataFrame,
y: np.ndarray | pd.Series,
*,
cv: int = 5,
max_iter: int = 20000,
random_state: int | None = None,
) -> LassoPathFitResult
Parameters#
name |
type |
default |
constraint |
description |
|---|---|---|---|---|
|
`np.ndarray |
pd.DataFrame` |
— |
— |
|
`np.ndarray |
pd.Series` |
— |
— |
|
|
|
>=2 |
Number of cross-validation folds for alpha selection. |
|
|
|
>=1 |
Maximum coordinate descent iterations per alpha. |
|
`int |
None` |
|
— |
Returns#
LassoPathFitResult — frozen dataclass with fit results.
Attribute |
Type |
Description |
|---|---|---|
|
|
Fitted coefficient vector, shape (n_features,). |
|
|
Fitted intercept scalar. |
|
|
CV-selected regularisation strength. |
|
|
Predictions for new data X, shape (n_samples,). |
|
|
Human-readable text table of fit results. |
Behavior#
Wraps sklearn’s LassoCV. Picks α automatically from a regularisation path via k-fold CV (params.cv). Equivalent to setting family: lasso, search_algorithm: cv_path.
When to use
When the recipe wants automatic α selection without an explicit search_algorithm.
In recipe context#
Set params.family = "lasso_path" in the relevant layer to activate this op within a recipe:
# Layer L4 recipe fragment
params:
family: lasso_path
References#
macroforecast design Part 2, L4: ‘forecasting model is the layer where every authoring iteration ends – pick family, tune, repeat.’