Predict

Trait Predict 

Source
pub trait Predict {
    type Error: ModelError;

    // Required methods
    fn predict_in_sample_inplace(
        &self,
        level: Option<f64>,
        forecast: &mut Forecast,
    ) -> Result<(), Self::Error>;
    fn predict_inplace(
        &self,
        horizon: usize,
        level: Option<f64>,
        forecast: &mut Forecast,
    ) -> Result<(), Self::Error>;
    fn training_data_size(&self) -> usize;

    // Provided methods
    fn predict(
        &self,
        horizon: usize,
        level: impl Into<Option<f64>>,
    ) -> Result<Forecast, Self::Error> { ... }
    fn predict_in_sample(
        &self,
        level: impl Into<Option<f64>>,
    ) -> Result<Forecast, Self::Error> { ... }
}
Expand description

A fitted time series forecasting model.

Required Associated Types§

Source

type Error: ModelError

The type of error returned when predicting with the model.

Required Methods§

Source

fn predict_in_sample_inplace( &self, level: Option<f64>, forecast: &mut Forecast, ) -> Result<(), Self::Error>

Calculate the in-sample predictions, storing the results in the provided Forecast struct.

The predictions are point forecasts and optionally include prediction intervals at the specified level.

level should be a float between 0 and 1 representing the confidence level of the prediction intervals. If None then no prediction intervals are returned.

§Errors

Any errors returned by the trend model are propagated.

Source

fn predict_inplace( &self, horizon: usize, level: Option<f64>, forecast: &mut Forecast, ) -> Result<(), Self::Error>

Calculate the n-ahead predictions for the given horizon, storing the results in the provided Forecast struct.

The predictions are point forecasts and optionally include prediction intervals at the specified level.

level should be a float between 0 and 1 representing the confidence level of the prediction intervals. If None then no prediction intervals are returned.

§Errors

Any errors returned by the trend model are propagated.

Source

fn training_data_size(&self) -> usize

Return the number of training data points used to fit the model.

This is used for pre-allocating the in-sample forecasts.

Provided Methods§

Source

fn predict( &self, horizon: usize, level: impl Into<Option<f64>>, ) -> Result<Forecast, Self::Error>

Return the n-ahead predictions for the given horizon.

The predictions are point forecasts and optionally include prediction intervals at the specified level.

level should be a float between 0 and 1 representing the confidence level of the prediction intervals. If None then no prediction intervals are returned.

§Errors

Any errors returned by the trend model are propagated.

Source

fn predict_in_sample( &self, level: impl Into<Option<f64>>, ) -> Result<Forecast, Self::Error>

Return the in-sample predictions.

The predictions are point forecasts and optionally include prediction intervals at the specified level.

level should be a float between 0 and 1 representing the confidence level of the prediction intervals. If None then no prediction intervals are returned.

§Errors

Any errors returned by the trend model are propagated.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§