pub struct CrossValidator {
pub mode: CrossValidationMode,
pub min_train_size: usize,
pub horizon: usize,
pub n_folds: usize,
}Expand description
Cross-validation configuration.
Fields§
§mode: CrossValidationModeMode: expanding or sliding window.
min_train_size: usizeMinimum number of training observations.
horizon: usizeNumber of steps to predict (test window).
n_folds: usizeNumber of folds.
Implementations§
Source§impl CrossValidator
impl CrossValidator
Sourcepub fn new(
mode: CrossValidationMode,
min_train_size: usize,
horizon: usize,
n_folds: usize,
) -> Self
pub fn new( mode: CrossValidationMode, min_train_size: usize, horizon: usize, n_folds: usize, ) -> Self
Create a new cross-validator.
Sourcepub fn evaluate<F>(
&self,
timestamps: &[i64],
values: &[f64],
model_factory: F,
) -> Result<CrossValidationResult, ForecastError>
pub fn evaluate<F>( &self, timestamps: &[i64], values: &[f64], model_factory: F, ) -> Result<CrossValidationResult, ForecastError>
Evaluate a forecast model using walk-forward cross-validation.
model_factory is called once per fold to create a fresh model
instance — this avoids carry-over state between folds.
§Errors
Returns an error if the data is too short for the requested configuration or if any fold’s fit/predict fails.
Trait Implementations§
Source§impl Clone for CrossValidator
impl Clone for CrossValidator
Source§fn clone(&self) -> CrossValidator
fn clone(&self) -> CrossValidator
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 moreAuto Trait Implementations§
impl Freeze for CrossValidator
impl RefUnwindSafe for CrossValidator
impl Send for CrossValidator
impl Sync for CrossValidator
impl Unpin for CrossValidator
impl UnsafeUnpin for CrossValidator
impl UnwindSafe for CrossValidator
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more