# shrinkage::LassoFit

Shrinkage for Rust · 0.3.0

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/fit/lasso.rs>)

```rust
pub struct LassoFit
```

Owned original-scale parameters, preprocessing metadata, and diagnostics. 

Check [`Self::termination`](<d7f3cc1c178006da270ca45d4069f972c99a6c736656b6241882f09fbaf163bc#method-termination-b7275ba661ef0fe0bb23beba12f3e5dc0f391154ba6bef5b22ed64b8923407bd>) before treating a fit as converged. Diagnostics refer to the optimization-scale penalty even though coefficients use the original scale. 

<a id="impl-b7275ba661ef0fe0bb23beba12f3e5dc0f391154ba6bef5b22ed64b8923407bd"></a>

## Inherent implementation

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/fit/lasso.rs>)

```rust
impl LassoFit
```

<a id="method-coefficients-b7275ba661ef0fe0bb23beba12f3e5dc0f391154ba6bef5b22ed64b8923407bd"></a>

### `coefficients`

```rust
pub fn coefficients(&self) -> &[f64]
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/fit/lasso.rs>)

Original-scale coefficients, in training-column order. 

<a id="method-dual_certificate-b7275ba661ef0fe0bb23beba12f3e5dc0f391154ba6bef5b22ed64b8923407bd"></a>

### `dual_certificate`

```rust
pub fn dual_certificate(&self) -> &[f64]
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/fit/lasso.rs>)

Feasible dual vector `theta`, with `||X_tilde' theta||_inf <= lambda` and `sum(theta) = 0` when an intercept was fitted, up to floating-point error. At zero penalty, the certificate can be zero and its gap can be loose. 

<a id="method-dual_objective-b7275ba661ef0fe0bb23beba12f3e5dc0f391154ba6bef5b22ed64b8923407bd"></a>

### `dual_objective`

```rust
pub fn dual_objective(&self) -> f64
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/fit/lasso.rs>)

Gaussian dual objective `D(theta) = y' theta - n ||theta||² / 2`. 

<a id="method-duality_gap-b7275ba661ef0fe0bb23beba12f3e5dc0f391154ba6bef5b22ed64b8923407bd"></a>

### `duality_gap`

```rust
pub fn duality_gap(&self) -> f64
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/fit/lasso.rs>)

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

<a id="method-intercept-b7275ba661ef0fe0bb23beba12f3e5dc0f391154ba6bef5b22ed64b8923407bd"></a>

### `intercept`

```rust
pub fn intercept(&self) -> f64
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/fit/lasso.rs>)

Original-scale intercept, including the correction for centering. 

<a id="method-iterations-b7275ba661ef0fe0bb23beba12f3e5dc0f391154ba6bef5b22ed64b8923407bd"></a>

### `iterations`

```rust
pub fn iterations(&self) -> usize
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/fit/lasso.rs>)

Number of coordinate sweeps over the current working set performed. 

<a id="method-kkt_violation-b7275ba661ef0fe0bb23beba12f3e5dc0f391154ba6bef5b22ed64b8923407bd"></a>

### `kkt_violation`

```rust
pub fn kkt_violation(&self) -> f64
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/fit/lasso.rs>)

Maximum absolute KKT violation, as defined by [`crate::Lasso::tolerance`](<15ac14ea52500c664ef11283ff8f8268bb931648138cfb39e6f72b84444fee90#method-tolerance-cfe5dcbd11d6e74acd0dd47480c46376db4c2dee46fb183f17bf0a6df47e334c>). 

<a id="method-objective-b7275ba661ef0fe0bb23beba12f3e5dc0f391154ba6bef5b22ed64b8923407bd"></a>

### `objective`

```rust
pub fn objective(&self) -> f64
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/fit/lasso.rs>)

Final primal objective `P(beta_0, beta) = ||residual||² / (2n) + lambda * ||beta||₁`. 

<a id="method-predict-b7275ba661ef0fe0bb23beba12f3e5dc0f391154ba6bef5b22ed64b8923407bd"></a>

### `predict`

```rust
pub fn predict<M: RawColumns<f64> + ?Sized>(
    &self,
    x: &M
) -> Result<Vec<f64>, FitError>
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/fit/lasso.rs>)

Predict from raw columns in the same order as the training design. 

Uses original-scale parameters, without estimating new centers or scales. Empty prediction batches return an empty vector. 

<a id="method-predict-b7275ba661ef0fe0bb23beba12f3e5dc0f391154ba6bef5b22ed64b8923407bd-documentation-errors"></a>

#### Errors

Returns an error for a feature-count mismatch, nonfinite input, or nonfinite prediction arithmetic. 

<a id="method-preprocessing-b7275ba661ef0fe0bb23beba12f3e5dc0f391154ba6bef5b22ed64b8923407bd"></a>

### `preprocessing`

```rust
pub fn preprocessing(&self) -> &Preprocessing
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/fit/lasso.rs>)

Fitted training-column centers and scales. 

<a id="method-reference_loss-b7275ba661ef0fe0bb23beba12f3e5dc0f391154ba6bef5b22ed64b8923407bd"></a>

### `reference_loss`

```rust
pub fn reference_loss(&self) -> f64
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/fit/lasso.rs>)

Averaged loss at zero coefficients and the optimal enabled intercept. 

<a id="method-stopping_criterion-b7275ba661ef0fe0bb23beba12f3e5dc0f391154ba6bef5b22ed64b8923407bd"></a>

### `stopping_criterion`

```rust
pub fn stopping_criterion(&self) -> StoppingCriterion
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/fit/lasso.rs>)

Criterion selected for this fit. 

<a id="method-stopping_threshold-b7275ba661ef0fe0bb23beba12f3e5dc0f391154ba6bef5b22ed64b8923407bd"></a>

### `stopping_threshold`

```rust
pub fn stopping_threshold(&self) -> f64
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/fit/lasso.rs>)

Threshold applied to the selected criterion. 

<a id="method-stopping_value-b7275ba661ef0fe0bb23beba12f3e5dc0f391154ba6bef5b22ed64b8923407bd"></a>

### `stopping_value`

```rust
pub fn stopping_value(&self) -> f64
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/fit/lasso.rs>)

Final value of the selected criterion. 

<a id="method-termination-b7275ba661ef0fe0bb23beba12f3e5dc0f391154ba6bef5b22ed64b8923407bd"></a>

### `termination`

```rust
pub fn termination(&self) -> Termination
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/fit/lasso.rs>)

Whether the fit converged or exhausted its iteration budget. 

<a id="method-working_set_diagnostics-b7275ba661ef0fe0bb23beba12f3e5dc0f391154ba6bef5b22ed64b8923407bd"></a>

### `working_set_diagnostics`

```rust
pub fn working_set_diagnostics(&self) -> &shrinkage::WorkingSetDiagnostics
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/fit/lasso.rs>)

Work performed by heuristic feature selection, separate from safe screening. 

<a id="impl-e2549d27b6911fc6ed53b8da4836e9dcb3c0764baec143157dcf1fb042b89b5d"></a>

## Implementation of Clone

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/fit/lasso.rs>)

```rust
impl Clone for LassoFit
```

<a id="method-clone-e2549d27b6911fc6ed53b8da4836e9dcb3c0764baec143157dcf1fb042b89b5d"></a>

### `clone`

```rust
fn clone(&self) -> Self
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/fit/lasso.rs>)

<a id="impl-618e61a899b0fb532e00ac957bada1218710fedf5a05820006f8a3283f5a909b"></a>

## Implementation of Debug

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/fit/lasso.rs>)

```rust
impl Debug for LassoFit
```

<a id="method-fmt-618e61a899b0fb532e00ac957bada1218710fedf5a05820006f8a3283f5a909b"></a>

### `fmt`

```rust
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/fit/lasso.rs>)

<a id="impl-0b07e3e1005408666cca17c9b1a292c0f44bafddb0b2216c67fa16d59f41dbcd"></a>

## [Implementation of ValidationFit](<5d173ce7dcb2d06e349b61bf9258286c35ff88ac41d7933ce0fe0553c3337dce>)

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/cross_validation.rs>)

```rust
impl ValidationFit for shrinkage::LassoFit
```

<a id="method-predict-0b07e3e1005408666cca17c9b1a292c0f44bafddb0b2216c67fa16d59f41dbcd"></a>

### `predict`

```rust
fn predict<M: RawColumns<f64> + ?Sized>(
    &self,
    design: &M
) -> Result<Vec<f64>, FitError>
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/cross_validation.rs>)

<a id="method-termination-0b07e3e1005408666cca17c9b1a292c0f44bafddb0b2216c67fa16d59f41dbcd"></a>

### `termination`

```rust
fn termination(&self) -> Termination
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/cross_validation.rs>)

<a id="impl-951b46fc7e0f2d95342174c3b199ac88258502de3f4fa9183f30af30e2548892"></a>

## Implementation of Freeze

```rust
impl Freeze for LassoFit
```

<a id="impl-77b5dada7664643216999bc9075b0c248c2900755fa31056a1fda229ba30d29b"></a>

## Implementation of RefUnwindSafe

```rust
impl RefUnwindSafe for LassoFit
```

<a id="impl-fc8b9e12f864e6c5b64dc6491432081656fb6de51ab57fb2c3be30f9304b23bc"></a>

## Implementation of Send

```rust
impl Send for LassoFit
```

<a id="impl-cc540ed61f07f6e4155f7d37bd74b7e1bb6f7897ce04519e3572491503c61cf6"></a>

## Implementation of Sync

```rust
impl Sync for LassoFit
```

<a id="impl-0c4dfe65c2ad52948a82337734fbc7c9585d5dc586a1e468121899722a8902e5"></a>

## Implementation of Unpin

```rust
impl Unpin for LassoFit
```

<a id="impl-be6ab6a08e42a9f83a97d5d8f90dd1c2f729422566cb2747c190ae31da9c5451"></a>

## Implementation of UnsafeUnpin

```rust
impl UnsafeUnpin for LassoFit
```

<a id="impl-af72cad07897c9f242ef41cfe614b67c9cfe73f188f66b1c6449c97bc530ee4d"></a>

## Implementation of UnwindSafe

```rust
impl UnwindSafe for LassoFit
```

<a id="impl-1e5682dc18e03c648aa9b125290c107c1e8d96ce8a179a8532e4057da4daf0cd"></a>

## Implementation of Any

```rust
impl<T> Any for T where T: 'static + ?Sized
```

<a id="impl-6c0b25c2c92cdb117802d9c0a4c70afc9a8bfb0da875bc6e66191e2349fcdf3f"></a>

## Implementation of Borrow

```rust
impl<T> Borrow<T> for T where T: ?Sized
```

<a id="impl-796e80d926348273a22b04d8e84f510693b11c06ec57c3c3e2e8c1524094a85c"></a>

## Implementation of BorrowMut

```rust
impl<T> BorrowMut<T> for T where T: ?Sized
```

<a id="impl-8360e4092e7ec4a05a26dd304cd739398f0cacc50c8d08dd5be0223d1a08d02e"></a>

## Implementation of ByRef

```rust
impl<T> ByRef<T> for T
```

<a id="impl-dbb1293b7b5dd80c4d9a98cfdd6843dc7470224c0b1387731cd418da07046d7b"></a>

## Implementation of CastableFrom

```rust
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT where ST: ?Sized, DT: ?Sized
```

<a id="impl-97b65e7dfc44b5ecaa495a3a19fe737914a1e9f8532200cf8f46191314e7d777"></a>

## Implementation of CastableFrom

```rust
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT where ST: ?Sized, DT: ?Sized
```

<a id="impl-86d7da2bfd1140cc1675dfe6a975e6a2762338ab32731152da0723858ef3aa81"></a>

## Implementation of CloneToUninit

```rust
impl<T> CloneToUninit for T where T: Clone
```

<a id="impl-c22bdd3b1b677b66eb32d1c182cc1410c7f0c46491dd74e6a659647c238d19ec"></a>

## Implementation of From

```rust
impl<T> From<T> for T
```

<a id="impl-5adf6ca1830f30fbbac655ab8ff394d254954df7ededc7cc833c72fdc87d6f00"></a>

## Implementation of Imply

```rust
impl<T, U> Imply<T> for U where T: ?Sized, U: ?Sized
```

<a id="impl-85eec431edd188129f88290bbcb748e4d2fdc97f7efef3c162b8c252286ffec0"></a>

## Implementation of Into

```rust
impl<T, U> Into<U> for T where U: From<T>
```

<a id="impl-c40268dd59dd3329202d3c0544c62372e98ff3baa8ec442ec00752e024ec1d06"></a>

## Implementation of IntoEither

```rust
impl<T> IntoEither for T
```

<a id="impl-5655b1ef858b34a584cb80104f040c8a4063ced0d281311a0833ed12aefde86e"></a>

## Implementation of Pointable

```rust
impl<T> Pointable for T
```

<a id="impl-8cc2aa01198fc9fa44f08b889f62988d70d2a7f4f0f11f4666d4c08bdaddb22a"></a>

## Implementation of Read

```rust
impl<T> Read<Exclusive, BecauseExclusive> for T where T: ?Sized
```

<a id="impl-5ea09131039c62dd92b119d480a35c7e2b33d2b81dccf0b849f6b1f19f4bda24"></a>

## Implementation of Same

```rust
impl<T> Same for T
```

<a id="impl-7ee6ff38d6674f5edfe4734359062c2a67a572cff5899a89704764822b931c7f"></a>

## Implementation of SupersetOf

```rust
impl<SS, SP> SupersetOf<SS> for SP where SS: SubsetOf<SP>
```

<a id="impl-a8ef6e94191301c3685488478f4905086c47137bac2d606ea4d09631d5472b06"></a>

## Implementation of ToOwned

```rust
impl<T> ToOwned for T where T: Clone
```

<a id="impl-83960135d00d98080c95a08867729696e36811280c2dd9cf34c1b4fe21c81e18"></a>

## Implementation of TryFrom

```rust
impl<T, U> TryFrom<U> for T where U: Into<T>
```

<a id="impl-1cc495bcaa5112ffb304e7f0de674feca391fd97f47bec86033a9225b72ac05c"></a>

## Implementation of TryInto

```rust
impl<T, U> TryInto<U> for T where U: TryFrom<T>
```
