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§
Sourcefn fit(
&mut self,
timestamps: &[i64],
values: &[f64],
) -> Result<(), ForecastError>
fn fit( &mut self, timestamps: &[i64], values: &[f64], ) -> Result<(), ForecastError>
Fit the model on historical data.
Sourcefn predict(&self, horizon: usize) -> Result<ForecastResult, ForecastError>
fn predict(&self, horizon: usize) -> Result<ForecastResult, ForecastError>
Predict horizon steps ahead.
Sourcefn update(&mut self, timestamp: i64, value: f64) -> Result<(), ForecastError>
fn update(&mut self, timestamp: i64, value: f64) -> Result<(), ForecastError>
Online update with a single new observation.
Sourcefn model_type(&self) -> ModelType
fn model_type(&self) -> ModelType
Returns the model type.
Sourcefn params(&self) -> &ModelParams
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".