Shrinkage

shrinkage.Problem

Shrinkage for Python · python · 0.2.0

Problem(
    x: object,
    datafit: Gaussian | Binomial,
    penalty: ClusteredLasso | ChainFusedLasso | Slope,
    *,
    normalization: shrinkage.Normalization = "auto"
)

A dense single-response problem, fitted with an explicit solver.

x and the datafit's response are retained by reference until fitting. Each fit_with call independently copies them into Rust-owned storage. The input contract and normalization presets match shrinkage.Lasso. Penalties act on optimization-scale coefficients. Returned coefficients, intercepts, and predictions use the original input scale.

x

x: object = field(repr=False)

datafit

datafit: Gaussian | Binomial

penalty

penalty: ClusteredLasso | ChainFusedLasso | Slope

normalization

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

fit_with

fit_with(
    solver: shrinkage.HybridCoordinateDescent,
    *,
    copy: bool = True
) -> shrinkage.HybridFit
fit_with(
    solver: shrinkage.ProximalGradient,
    *,
    copy: bool = True
) -> shrinkage.ProximalFit

Fit with Rust, releasing the GIL after copying all inputs.

Inputs must remain unchanged until this call returns. copy=False is unsupported. Invalid inputs or incompatible stopping rules raise TypeError or ValueError. Nonfinite arithmetic raises FloatingPointError, and line-search failures raise RuntimeError. Iteration limits return finite results with termination equal to "iteration_limit". Results retain no problem or training arrays.

fit_path_with

fit_path_with(
    solver: shrinkage.HybridCoordinateDescent,
    penalties: collections.abc.Iterable[ClusteredLasso | ChainFusedLasso | Slope],
    *,
    copy: bool = True
) -> shrinkage.PathFit[shrinkage.HybridFit]
fit_path_with(
    solver: shrinkage.ProximalGradient,
    penalties: collections.abc.Iterable[ClusteredLasso | ChainFusedLasso | Slope],
    *,
    copy: bool = True
) -> shrinkage.PathFit[shrinkage.ProximalFit]

Fit complete penalties in caller order with Rust workspace reuse.

All points must match the problem penalty's type. Both strengths and weights may change independently. Empty, repeated, and nonmonotone sequences are accepted. The problem's own penalty supplies only the type for explicit paths. HybridCoordinateDescent auto working sets resolve to ever_active. Each point has its own solver budget, and finite iteration-limit fits warm-start subsequent points. Errors raise without returning a partial path. Dense input and GIL rules match fit.

fit_regularization_path_with

fit_regularization_path_with(
    solver: shrinkage.HybridCoordinateDescent,
    options: PathOptions | None = None,
    *,
    copy: bool = True
) -> shrinkage.PathFit[shrinkage.HybridFit]
fit_regularization_path_with(
    solver: shrinkage.ProximalGradient,
    options: PathOptions | None = None,
    *,
    copy: bool = True
) -> shrinkage.PathFit[shrinkage.ProximalFit]

Generate and warm-fit a decreasing sequence from Rust's null model.

Scalar strengths multiply both clustered or chain strengths, or all SLOPE rank weights. Chain edge weights stay fixed. Paths with no finite zero threshold require an explicit lambda_start. Free-intercept binomial paths reject all-zero or all-one responses because their null optimum is not finite. Inputs are copied once for the whole path.