Skip to main content

Model

Trait Model 

Source
pub trait Model: Send + Sync {
    // Required methods
    fn name(&self) -> String;
    fn description(&self) -> String;
    fn fit(&self, y: Series<'_>) -> Option<Box<dyn Fitted>>;

    // Provided method
    fn forecast(&self, y: Series<'_>, h: usize) -> Option<Vec<f64>> { ... }
}
Expand description

A forecasting method, before seeing any data.

Fitting is separate from forecasting so a fitted model can be inspected and asked for any horizon without being estimated again. Models are plain configuration, shared between the threads of a backtest.

Required Methods§

Source

fn name(&self) -> String

Short identifier, e.g. holt_winters.

Source

fn description(&self) -> String

One-line description of the method.

Source

fn fit(&self, y: Series<'_>) -> Option<Box<dyn Fitted>>

Estimates the model. None when the series is too short or otherwise unsuitable — never a made-up fit.

Provided Methods§

Source

fn forecast(&self, y: Series<'_>, h: usize) -> Option<Vec<f64>>

Fits and forecasts the h periods after the last observation. None also when a forecast is not finite: regressors that do not reach the horizon, or a transformation that cannot be brought back.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§