Shrinkage

shrinkage.Lasso

Shrinkage for Python · python · 0.2.0

Lasso(
    lambda_: float,
    *,
    fit_intercept: bool = True,
    normalization: shrinkage.Normalization = "auto",
    stopping: StoppingCriterion | None = None,
    max_iterations: int = 10000
)

Configure Gaussian lasso, then call fit for an owned result.

Minimize P(beta_0, beta) = F(beta_0, beta) + R(beta), where F = ||y - X_tilde @ beta - beta_0||**2 / (2*n) and R = lambda_ * ||beta||_1. The intercept is unpenalized. lambda_ must be finite and nonnegative. normalization="auto" divides columns by population standard deviations and centers by their means when fit_intercept=True. Other presets are independent of the intercept setting. Penalties act on normalized coefficients; results and predictions use the original input scale.

By default, positive penalties use relative duality gap 1e-6 and zero penalty uses absolute KKT violation 1e-6. stopping overrides this choice. max_iterations limits complete sweeps over the current working set and must be positive. Full convergence checks run at initialization, every ten sweeps, and at the iteration limit. Options are validated when fitting.

lambda_

lambda_: float

fit_intercept

fit_intercept: bool = field(default=True, kw_only=True)

normalization

normalization: shrinkage.Normalization = field(default="auto", kw_only=True)

stopping

stopping: StoppingCriterion | None = field(default=None, kw_only=True)

max_iterations

max_iterations: int = field(default=10_000, kw_only=True)

fit

fit(x: object, y: object, *, copy: bool = True) -> shrinkage.LassoFit

Fit exact NumPy float64 arrays of shapes (n, p) and (n,).

Strided, writable, and read-only arrays are supported. Both inputs are copied into Rust-owned storage with the GIL held. Callers must prevent concurrent mutation or resizing until copying finishes. Numerical fitting releases the GIL and calls no Python callbacks. copy=False raises ValueError.

Invalid data or options raise TypeError or ValueError. Nonfinite arithmetic from finite inputs raises FloatingPointError. An exhausted budget returns a fit with termination "iteration_limit".