pub struct LeaveOneOutCrossValidation {
pub scheme_name: String,
pub description: String,
}Expand description
Cross-validation using a single observation per validation fold.
Fields§
§scheme_name: StringUnique name identifying a resampling scheme.
description: StringFree-text description.
Implementations§
Source§impl LeaveOneOutCrossValidation
impl LeaveOneOutCrossValidation
Sourcepub fn run(
&self,
n: usize,
fit_score: impl FnMut(&[usize], &[usize]) -> f64,
) -> Result<CvScores>
pub fn run( &self, n: usize, fit_score: impl FnMut(&[usize], &[usize]) -> f64, ) -> Result<CvScores>
Runs leave-one-out cross-validation for this scheme over n observations.
A thin inherent wrapper over loo_cross_validate so the
LeaveOneOutCrossValidation type carries its own numerics: it ignores
the scheme’s descriptive fields and forwards n and fit_score unchanged.
§Arguments
n— the number of observations; must be at least 2.fit_score— invoked asfit_score(train_idx, test_idx)per fold, returning that fold’s score.FnMutso it may carry state across folds.
§Returns
A CvScores with the per-fold scores, their mean, and their standard
error.
§Errors
Returns Error::InsufficientData when n < 2.
§Examples
use stats_claw::resampling::LeaveOneOutCrossValidation;
let scheme = LeaveOneOutCrossValidation::default();
let scores = scheme.run(4, |_train, _test| 1.0)?;
assert_eq!(scores.fold_scores().len(), 4);
assert!((scores.mean() - 1.0).abs() < 1e-12);Trait Implementations§
Source§impl Clone for LeaveOneOutCrossValidation
impl Clone for LeaveOneOutCrossValidation
Source§fn clone(&self) -> LeaveOneOutCrossValidation
fn clone(&self) -> LeaveOneOutCrossValidation
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LeaveOneOutCrossValidation
impl Debug for LeaveOneOutCrossValidation
Source§impl Default for LeaveOneOutCrossValidation
impl Default for LeaveOneOutCrossValidation
Source§fn default() -> LeaveOneOutCrossValidation
fn default() -> LeaveOneOutCrossValidation
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for LeaveOneOutCrossValidation
impl RefUnwindSafe for LeaveOneOutCrossValidation
impl Send for LeaveOneOutCrossValidation
impl Sync for LeaveOneOutCrossValidation
impl Unpin for LeaveOneOutCrossValidation
impl UnsafeUnpin for LeaveOneOutCrossValidation
impl UnwindSafe for LeaveOneOutCrossValidation
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more