# shrinkage::CrossValidationFit

Shrinkage for Rust · 0.3.0

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

```rust
pub struct CrossValidationFit<F, P>
```

Fold paths, aggregated uncertainty, selected candidate, and full-data refits. 

Fold scores are averaged with equal fold weights, even for unequal sizes. For `K` folds, `SE = sqrt(sum((score - mean)^2) / (K * (K - 1)))`. These conventional fold standard errors do not account for dependence between overlapping training sets. All candidate fits must converge. 

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

## Inherent implementation

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

```rust
impl<F, P> CrossValidationFit<F, P>
```

<a id="method-assignments-5b91b6d1e94b35d012f1489d03ceadad65bb7dea2b4cac17e1c8a7583c2143c5"></a>

### `assignments`

```rust
pub fn assignments(&self) -> &FoldAssignments
```

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

Held-out assignments in original observation order. 

<a id="method-fit-5b91b6d1e94b35d012f1489d03ceadad65bb7dea2b4cac17e1c8a7583c2143c5"></a>

### `fit`

```rust
pub fn fit(&self) -> &F
```

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

Selected fit from the full-data path, with original-scale parameters. 

<a id="method-folds-5b91b6d1e94b35d012f1489d03ceadad65bb7dea2b4cac17e1c8a7583c2143c5"></a>

### `folds`

```rust
pub fn folds(&self) -> &[FoldPath<F, P>]
```

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

Training-fold paths in zero-based fold order. 

<a id="method-lambda-5b91b6d1e94b35d012f1489d03ceadad65bb7dea2b4cac17e1c8a7583c2143c5"></a>

### `lambda`

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

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

Selected full-data scalar strength, when the path supplies one. 

<a id="method-mean_scores-5b91b6d1e94b35d012f1489d03ceadad65bb7dea2b4cac17e1c8a7583c2143c5"></a>

### `mean_scores`

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

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

Equal-weight means of held-out fold losses, aligned with candidates. 

<a id="method-metric-5b91b6d1e94b35d012f1489d03ceadad65bb7dea2b4cac17e1c8a7583c2143c5"></a>

### `metric`

```rust
pub fn metric(&self) -> ValidationMetric
```

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

Family-compatible metric used for validation. 

<a id="method-minimum_index-5b91b6d1e94b35d012f1489d03ceadad65bb7dea2b4cac17e1c8a7583c2143c5"></a>

### `minimum_index`

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

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

First candidate with minimum mean loss. 

<a id="method-one_standard_error_index-5b91b6d1e94b35d012f1489d03ceadad65bb7dea2b4cac17e1c8a7583c2143c5"></a>

### `one_standard_error_index`

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

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

First candidate within one standard error of the minimum-loss point. 

<a id="method-penalty-5b91b6d1e94b35d012f1489d03ceadad65bb7dea2b4cac17e1c8a7583c2143c5"></a>

### `penalty`

```rust
pub fn penalty(&self) -> &P
```

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

Selected complete full-data penalty, including every strength and weight. 

<a id="method-refit_path-5b91b6d1e94b35d012f1489d03ceadad65bb7dea2b4cac17e1c8a7583c2143c5"></a>

### `refit_path`

```rust
pub fn refit_path(&self) -> &PathFit<F, P>
```

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

Fresh path fitted on all observations after validation and selection. 

<a id="method-relative_strengths-5b91b6d1e94b35d012f1489d03ceadad65bb7dea2b4cac17e1c8a7583c2143c5"></a>

### `relative_strengths`

```rust
pub fn relative_strengths(&self) -> Option<&[f64]>
```

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

Shared automatic fractions of each fold's own starting anchor. Explicit paths have no inferred scalar representation. 

<a id="method-selected_index-5b91b6d1e94b35d012f1489d03ceadad65bb7dea2b4cac17e1c8a7583c2143c5"></a>

### `selected_index`

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

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

Candidate chosen by the configured rule. 

<a id="method-selection_rule-5b91b6d1e94b35d012f1489d03ceadad65bb7dea2b4cac17e1c8a7583c2143c5"></a>

### `selection_rule`

```rust
pub fn selection_rule(&self) -> SelectionRule
```

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

Rule used to select the full-data fit. 

<a id="method-standard_errors-5b91b6d1e94b35d012f1489d03ceadad65bb7dea2b4cac17e1c8a7583c2143c5"></a>

### `standard_errors`

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

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

Sample standard deviations of fold losses divided by `sqrt(K)`. 

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

## Implementation of Clone

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

```rust
impl<F: core::clone::Clone, P: core::clone::Clone> Clone for CrossValidationFit<F, P>
```

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

### `clone`

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

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

<a id="impl-9e753e327b5ab60d1b9454910e81727f78e979aeba10766752221adf1bd1ea1e"></a>

## Implementation of Debug

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

```rust
impl<F: core::fmt::Debug, P: core::fmt::Debug> Debug for CrossValidationFit<F, P>
```

<a id="method-fmt-9e753e327b5ab60d1b9454910e81727f78e979aeba10766752221adf1bd1ea1e"></a>

### `fmt`

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

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

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

## Implementation of Freeze

```rust
impl<F, P> Freeze for CrossValidationFit<F, P> where Vec<FoldPath<F, P>>: Freeze, PathFit<F, P>: Freeze
```

<a id="impl-171b0b2b4e9a51b7d8b46c4efb8876a2fc5c65efcff9c2ab4d0164020e822864"></a>

## Implementation of RefUnwindSafe

```rust
impl<F, P> RefUnwindSafe for CrossValidationFit<F, P> where Vec<FoldPath<F, P>>: RefUnwindSafe, PathFit<F, P>: RefUnwindSafe
```

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

## Implementation of Send

```rust
impl<F, P> Send for CrossValidationFit<F, P> where Vec<FoldPath<F, P>>: Send, PathFit<F, P>: Send
```

<a id="impl-9a8f45863742dc50aed8ee94256887e83bb5ef8284ceb9311641433395873d5f"></a>

## Implementation of Sync

```rust
impl<F, P> Sync for CrossValidationFit<F, P> where Vec<FoldPath<F, P>>: Sync, PathFit<F, P>: Sync
```

<a id="impl-7376020b31bd752f956135c52b0a4c723d55c6cb9c533b990a030e8e3d03fccb"></a>

## Implementation of Unpin

```rust
impl<F, P> Unpin for CrossValidationFit<F, P> where Vec<FoldPath<F, P>>: Unpin, PathFit<F, P>: Unpin
```

<a id="impl-3a4d09f856807eecc79c7e30b162377af653c0c77a8fa88fe694a3d2ad66bb64"></a>

## Implementation of UnsafeUnpin

```rust
impl<F, P> UnsafeUnpin for CrossValidationFit<F, P> where Vec<FoldPath<F, P>>: UnsafeUnpin, PathFit<F, P>: UnsafeUnpin
```

<a id="impl-728e57ca69a7fd92390096f08f9dd142531bea79c1f50385fadf44c5dd7ea968"></a>

## Implementation of UnwindSafe

```rust
impl<F, P> UnwindSafe for CrossValidationFit<F, P> where Vec<FoldPath<F, P>>: UnwindSafe, PathFit<F, P>: UnwindSafe
```

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