Skip to main content

ForecastModel

Trait ForecastModel 

Source
pub trait ForecastModel: Send + Sync {
    // Required methods
    fn fit(
        &mut self,
        timestamps: &[i64],
        values: &[f64],
    ) -> Result<(), ForecastError>;
    fn predict(&self, horizon: usize) -> Result<ForecastResult, ForecastError>;
    fn update(
        &mut self,
        timestamp: i64,
        value: f64,
    ) -> Result<(), ForecastError>;
    fn model_type(&self) -> ModelType;
    fn params(&self) -> &ModelParams;
}
Expand description

Core forecasting abstraction.

All forecast models implement this trait for uniform dispatch, persistence, and online updating.

Required Methods§

Source

fn fit( &mut self, timestamps: &[i64], values: &[f64], ) -> Result<(), ForecastError>

Fit the model on historical data.

Source

fn predict(&self, horizon: usize) -> Result<ForecastResult, ForecastError>

Predict horizon steps ahead.

Source

fn update(&mut self, timestamp: i64, value: f64) -> Result<(), ForecastError>

Online update with a single new observation.

Source

fn model_type(&self) -> ModelType

Returns the model type.

Source

fn params(&self) -> &ModelParams

Returns the fitted parameters.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§