pub struct ForecastEngine { /* private fields */ }Expand description
Forecast engine — produces predictions from historical data.
Uses a hybrid approach:
- Linear extrapolation from the slope of recent samples
- EWMA smoothing to reduce noise sensitivity
- Confidence from residual variance (how well linear fit matches data)
Implementations§
Source§impl ForecastEngine
impl ForecastEngine
Sourcepub const fn with_alpha(alpha: f32) -> Self
pub const fn with_alpha(alpha: f32) -> Self
Create with a custom EWMA alpha.
Sourcepub fn forecast(
&self,
history: &VecDeque<MetricSample>,
horizon: usize,
) -> Forecast
pub fn forecast( &self, history: &VecDeque<MetricSample>, horizon: usize, ) -> Forecast
Forecast from a history of samples.
Combines linear extrapolation (for trend) with EWMA (for noise resistance). Confidence is derived from how well the linear model fits the data (R²-like measure from residual variance).
Outlier values are clamped to ±3 standard deviations from the mean before fitting, preventing a single extreme spike from dominating the forecast.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ForecastEngine
impl RefUnwindSafe for ForecastEngine
impl Send for ForecastEngine
impl Sync for ForecastEngine
impl Unpin for ForecastEngine
impl UnsafeUnpin for ForecastEngine
impl UnwindSafe for ForecastEngine
Blanket Implementations§
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