lasso_path – Lasso with CV-selected alpha (LassoCV).#

Back to family axis | Back to L4 | Browse all options

Operational op under axis family, sub-layer L4_A_model_selection, layer l4. 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

X

`np.ndarray

pd.DataFrame`

y

`np.ndarray

pd.Series`

cv

int

5

>=2

Number of cross-validation folds for alpha selection.

max_iter

int

20000

>=1

Maximum coordinate descent iterations per alpha.

random_state

`int

None`

None

Returns#

LassoPathFitResult — frozen dataclass with fit results.

Attribute

Type

Description

.coef_

np.ndarray

Fitted coefficient vector, shape (n_features,).

.intercept_

float

Fitted intercept scalar.

.alpha_selected

float

CV-selected regularisation strength.

.predict(X)

np.ndarray

Predictions for new data X, shape (n_samples,).

.summary()

str

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.’