# shrinkage.LassoFit

Shrinkage for Python · 0.2.0

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

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

```python
LassoFit(_native: shrinkage._shrinkage._LassoFit)
```

Owned lasso parameters, fitted preprocessing, and final diagnostics.

Check `termination` before treating a fit as converged. Properties are read-only, and returned arrays are independent copies. The result retains neither the training arrays nor their Rust snapshots.

<a id="coefficients"></a>

## `coefficients`

```python
coefficients(self) -> FloatArray
```

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

Original-scale coefficients with shape `(n_features,)`.

<a id="intercept"></a>

## `intercept`

```python
intercept(self) -> float
```

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

Original-scale intercept, including the correction for centering.

<a id="preprocessing"></a>

## `preprocessing`

```python
preprocessing(self) -> shrinkage.Preprocessing
```

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

Training transformations; prediction never estimates new ones.

<a id="termination"></a>

## `termination`

```python
termination(self) -> shrinkage.Termination
```

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

`"converged"` or `"iteration_limit"` from the Rust solver.

<a id="iterations"></a>

## `iterations`

```python
iterations(self) -> int
```

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

Complete coordinate sweeps; initially optimal fits take zero.

<a id="objective"></a>

## `objective`

```python
objective(self) -> float
```

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

Final average squared loss plus the optimization-scale L1 penalty.

<a id="kkt_violation"></a>

## `kkt_violation`

```python
kkt_violation(self) -> float
```

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

Maximum KKT violation, including the free intercept derivative.

<a id="dual_certificate"></a>

## `dual_certificate`

```python
dual_certificate(self) -> FloatArray
```

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

Feasible Gaussian dual vector `theta` with shape `(n_samples,)`.

<a id="dual_objective"></a>

## `dual_objective`

```python
dual_objective(self) -> float
```

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

Dual objective `D(theta) = y @ theta - n * ||theta||**2 / 2`.

<a id="duality_gap"></a>

## `duality_gap`

```python
duality_gap(self) -> float
```

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

Gap `G(beta_0, beta, theta) = P(beta_0, beta) - D(theta)`.

The nonnegative gap can be loose at zero penalty.

<a id="reference_loss"></a>

## `reference_loss`

```python
reference_loss(self) -> float
```

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

Fixed average loss at zero coefficients and the optimal free intercept.

<a id="stopping"></a>

## `stopping`

```python
stopping(self) -> shrinkage.StoppingCriterion
```

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

Resolved criterion, including the default selected for this penalty.

<a id="stopping_value"></a>

## `stopping_value`

```python
stopping_value(self) -> float
```

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

Final value of the selected convergence check on refreshed state.

<a id="stopping_threshold"></a>

## `stopping_threshold`

```python
stopping_threshold(self) -> float
```

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

Threshold applied to the selected convergence check.

<a id="predict"></a>

## `predict`

```python
predict(x: object, *, copy: bool = True) -> FloatArray
```

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

Predict raw NumPy float64 rows, returning shape `(n_samples,)`.

Use training-column order. The dense input contract also applies here, with empty batches allowed. Prediction copies inputs before releasing the GIL, uses original-scale parameters, and never refits preprocessing. Invalid shapes or values raise `TypeError` or `ValueError`; nonfinite prediction arithmetic raises `FloatingPointError`.
