# shrinkage.Problem

Shrinkage for Python · 0.2.0

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/packages/python/src/shrinkage/problem.py>)

<a id="constructor"></a>

```python
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`](<72117a8837149fd66fd98093cc15a966b8ba732b3859e6f1dc370d0fa3458085>). Penalties act on optimization-scale coefficients. Returned coefficients, intercepts, and predictions use the original input scale.

<a id="x"></a>

## `x`

```python
x: object = field(repr=False)
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/packages/python/src/shrinkage/problem.py>)

<a id="datafit"></a>

## `datafit`

```python
datafit: Gaussian | Binomial
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/packages/python/src/shrinkage/problem.py>)

<a id="penalty"></a>

## `penalty`

```python
penalty: ClusteredLasso | ChainFusedLasso | Slope
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/packages/python/src/shrinkage/problem.py>)

<a id="normalization"></a>

## `normalization`

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

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/packages/python/src/shrinkage/problem.py>)

<a id="fit_with"></a>

## `fit_with`

<a id="overload-1dd6aaa5f33d1e563fd5fb976027c21acfa4d6053665e5482e81eadc6067b645"></a>

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

<a id="overload-ca676e1fe38a949d460e451afa4acfcc16dcdcf86d7fc56d5b49fb5e3a99587f"></a>

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

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/packages/python/src/shrinkage/problem.py>)

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.

<a id="fit_path_with"></a>

## `fit_path_with`

<a id="overload-45ed5f5bd206912dbf82169e733881d48c399319fe5ddc429b3f4c8c9d2cf4c4"></a>

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

<a id="overload-dd637865a1463de41fa3623ca214285099dfffdf98e7f994e1e772c7e856ca8b"></a>

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

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/packages/python/src/shrinkage/problem.py>)

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.

<a id="fit_regularization_path_with"></a>

## `fit_regularization_path_with`

<a id="overload-74cf7b9db43e48e0bd559435f9b1b74afb6a937ddb531eef5a09954f2fe3b10b"></a>

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

<a id="overload-be7fb16f6597320f01587dbecb3c6811e9025ae08651e5ffcf02f154832e63b2"></a>

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

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/packages/python/src/shrinkage/problem.py>)

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.
