# shrinkage::CoordinatePenalty

Shrinkage for Rust · 0.3.0

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

```rust
pub trait CoordinatePenalty: Penalty<Error = shrinkage::FitError>
```

A convex separable penalty with exact scalar updates and KKT checks. 

The complete value must equal the sum of its coordinate terms. Coupled penalties, such as SLOPE and group lasso, do not satisfy this contract. 

<a id="methods"></a>

## Methods

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

### `coordinate_violation`

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

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

Return the distance of zero from `loss_gradient + subgradient_j(value)`. The result must be finite and nonnegative, in gradient units. 

<a id="method-coordinate_violation-documentation-errors"></a>

#### Errors

Reject invalid parameters, indices, inputs, or nonfinite arithmetic. 

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

### `minimize_coordinate`

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

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

Minimize `curvature * value² / 2 - linear * value + penalty_j(value)`. Curvature must be finite and nonnegative. At zero curvature, return a finite minimizer when one exists, or an error for an unbounded subproblem. 

<a id="method-minimize_coordinate-documentation-errors"></a>

#### Errors

Reject invalid parameters, indices, inputs, or nonfinite arithmetic. 

<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="impl-42635ee035e62c74e7d277223d35e6868bddcde14b3ecf48412228deea7f7a3e"></a>

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

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

```rust
impl CoordinatePenalty for shrinkage::L1
```

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

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

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

```rust
impl CoordinatePenalty for shrinkage::Ridge
```
