# shrinkage::ElasticNet

Shrinkage for Rust · 0.3.0

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

```rust
pub struct ElasticNet
```

Complete elastic-net penalty `l1 * ||beta||₁ + l2 * ||beta||² / 2`. 

<a id="impl-85745ffa94908184462a65d54719f27b9e9b544e91529388b33406247a8785ce"></a>

## Inherent implementation

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

```rust
impl ElasticNet
```

<a id="method-alpha-85745ffa94908184462a65d54719f27b9e9b544e91529388b33406247a8785ce"></a>

### `alpha`

```rust
pub fn alpha(&self) -> Option<f64>
```

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

Configured mixing parameter, or its equivalent for positive independent strengths. Two independently supplied zero strengths have no mixing ratio. 

<a id="method-from_alpha-85745ffa94908184462a65d54719f27b9e9b544e91529388b33406247a8785ce"></a>

### `from_alpha`

```rust
pub fn from_alpha(lambda: f64, alpha: f64) -> Self
```

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

Use `lambda * (alpha * ||beta||₁ + (1 - alpha) * ||beta||² / 2)`. Lambda must be finite and nonnegative, and alpha must lie in `[0, 1]`. Validation occurs during evaluation or fitting. Automatic paths retain alpha even when the supplied lambda is zero. 

<a id="method-l1-85745ffa94908184462a65d54719f27b9e9b544e91529388b33406247a8785ce"></a>

### `l1`

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

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

Configured L1 strength. 

<a id="method-l2-85745ffa94908184462a65d54719f27b9e9b544e91529388b33406247a8785ce"></a>

### `l2`

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

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

Configured squared L2 strength. 

<a id="method-new-85745ffa94908184462a65d54719f27b9e9b544e91529388b33406247a8785ce"></a>

### `new`

```rust
pub fn new(l1: f64, l2: f64) -> Self
```

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

Set the L1 and squared L2 strengths independently, checked when used. 

<a id="impl-990c585ae960df97202f9edd831fe8c3d84d5b3e2f6e0bb99c2448561807ec62"></a>

## Implementation of Clone

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

```rust
impl Clone for ElasticNet
```

<a id="method-clone-990c585ae960df97202f9edd831fe8c3d84d5b3e2f6e0bb99c2448561807ec62"></a>

### `clone`

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

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

<a id="impl-115a221caa77bf1825116c9e8ef2cc8d5c0b2898a884a5dcb73751a6f6a0dc1f"></a>

## [Implementation of CoordinatePenalty](<20da77c0be652888a9d06dd14f0baaa185037b5c45513c2454efefbc53d3c0e8>)

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

```rust
impl CoordinatePenalty for shrinkage::ElasticNet
```

<a id="method-coordinate_violation-115a221caa77bf1825116c9e8ef2cc8d5c0b2898a884a5dcb73751a6f6a0dc1f"></a>

### `coordinate_violation`

```rust
fn coordinate_violation(
    &self,
    _: usize,
    value: f64,
    gradient: f64
) -> Result<f64, FitError>
```

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

<a id="method-minimize_coordinate-115a221caa77bf1825116c9e8ef2cc8d5c0b2898a884a5dcb73751a6f6a0dc1f"></a>

### `minimize_coordinate`

```rust
fn minimize_coordinate(
    &self,
    _: usize,
    linear: f64,
    curvature: f64
) -> Result<f64, FitError>
```

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

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

## Implementation of Copy

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

```rust
impl Copy for ElasticNet
```

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

## Implementation of Debug

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

```rust
impl Debug for ElasticNet
```

<a id="method-fmt-b2e9d07f55ac6120bf6a02db09d9d60964a30a5dae462929ccf478e1aba6a48b"></a>

### `fmt`

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

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

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

## [Implementation of PathPenalty](<5696a47a26612eb54b73987df7c9af737a60d396dd77d3c0b67969a3a5f37105>)

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

```rust
impl PathPenalty for shrinkage::ElasticNet
```

<a id="associated-type-AtStrength-faf313e5b4211dfb63ef8a18e8c2b0981da638b0abbabdd374108e848a2673b5"></a>

### `AtStrength`

```rust
type AtStrength = ElasticNet;
```

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

<a id="method-at_strength-faf313e5b4211dfb63ef8a18e8c2b0981da638b0abbabdd374108e848a2673b5"></a>

### `at_strength`

```rust
fn at_strength(&self, lambda: f64) -> Result<Self, FitError>
```

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

<a id="method-maximum_penalty-faf313e5b4211dfb63ef8a18e8c2b0981da638b0abbabdd374108e848a2673b5"></a>

### `maximum_penalty`

```rust
fn maximum_penalty(&self, gradient: &[f64]) -> Result<PenaltyMaximum, FitError>
```

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

<a id="method-path_anchor-faf313e5b4211dfb63ef8a18e8c2b0981da638b0abbabdd374108e848a2673b5"></a>

### `path_anchor`

```rust
fn path_anchor(&self, gradient: &[f64]) -> Result<f64, FitError>
```

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

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

## [Implementation of Penalty](<a4f4243001e8d9121fca7a92bcb924b17aa5375aba23987fae95b2a05faf5245>)

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

```rust
impl Penalty for ElasticNet
```

<a id="associated-type-Error-f31547e2f57959a7f01859e121168ecdd9fad958189c4b434a2c61a85a5c658b"></a>

### `Error`

```rust
type Error = FitError;
```

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

<a id="method-validate_input-f31547e2f57959a7f01859e121168ecdd9fad958189c4b434a2c61a85a5c658b"></a>

### `validate_input`

```rust
fn validate_input(&self, coefficients: &[f64]) -> Result<(), FitError>
```

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

<a id="method-value-f31547e2f57959a7f01859e121168ecdd9fad958189c4b434a2c61a85a5c658b"></a>

### `value`

```rust
fn value(&self, coefficients: &[f64]) -> Result<f64, FitError>
```

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

<a id="impl-45cdfd2a1bad32f0464e23503eca0925292c491b0dd809c9255cefd7056bc08a"></a>

## [Implementation of ProximalPenalty](<45434a0394c5d718086e7e777f7db8271e2fb2b568e2519720168e5ea2877ed0>)

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

```rust
impl ProximalPenalty for ElasticNet
```

<a id="method-prox-45cdfd2a1bad32f0464e23503eca0925292c491b0dd809c9255cefd7056bc08a"></a>

### `prox`

```rust
fn prox(
    &self,
    input: &[f64],
    step: f64,
    output: &mut [f64]
) -> Result<(), FitError>
```

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

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

## [Implementation of RestrictedProximalPenalty](<6e81c84ae32917d40a6711abfffe4b252008f5265d347b3a8b6129238b41dffe>)

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

```rust
impl RestrictedProximalPenalty for shrinkage::ElasticNet
```

<a id="method-prox_restricted-eb31e4e45f5a880af771a4acdd6ef6dda13630d36444110457ff5bc5c3808998"></a>

### `prox_restricted`

```rust
fn prox_restricted(
    &self,
    input: &[f64],
    unpenalized: &[bool],
    step: f64,
    output: &mut [f64]
) -> Result<(), FitError>
```

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

<a id="method-value_restricted-eb31e4e45f5a880af771a4acdd6ef6dda13630d36444110457ff5bc5c3808998"></a>

### `value_restricted`

```rust
fn value_restricted(
    &self,
    coefficients: &[f64],
    unpenalized: &[bool]
) -> Result<f64, FitError>
```

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

<a id="impl-395dc478f6c55cc6f08c8c4b060d6d4bb18b683533a9f334afff5999e6fb889c"></a>

## Implementation of Freeze

```rust
impl Freeze for ElasticNet
```

<a id="impl-45212a9fe30675c212e89b64e8f94df22c9ae3152d45b03df2487390b9f05c3b"></a>

## Implementation of RefUnwindSafe

```rust
impl RefUnwindSafe for ElasticNet
```

<a id="impl-87694631abf5cb173285035db8efdfd7f0c5704b6d9ca9f035bb0e7d87e262fa"></a>

## Implementation of Send

```rust
impl Send for ElasticNet
```

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

## Implementation of Sync

```rust
impl Sync for ElasticNet
```

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

## Implementation of Unpin

```rust
impl Unpin for ElasticNet
```

<a id="impl-2e5107e4e49cf0b28c9a7834ed62fd39649c10f787ea810373c3e7b71439d584"></a>

## Implementation of UnsafeUnpin

```rust
impl UnsafeUnpin for ElasticNet
```

<a id="impl-78698f61de5423357cd8ea37b9ef06ffce814215946b497bf0bd87bad6a02b8f"></a>

## Implementation of UnwindSafe

```rust
impl UnwindSafe for ElasticNet
```

<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>
```
