DriftForecaster¶
- class omnicast.DriftForecaster[source]
Bases:
BaseForecasterRandom walk with drift between the first and last observations.
Examples
>>> import pandas as pd >>> from omnicast import DriftForecaster >>> y = pd.Series([10.0, 12.0, 11.0, 13.0, 15.0, 14.0]) >>> model = DriftForecaster().fit(y) >>> model.predict(horizon=2).mean.round(2).tolist() [14.8, 15.6]
Notes
When to use this model¶ Best for
A trending series with no seasonality; a much stronger baseline than
NaiveForecasterin that case, at the same costAvoid when
The series has seasonality a straight line can’t capture, or the trend is not roughly linear end-to-end
Handles trend
Yes (linear, extrapolated from the first and last observation)
Handles seasonality
No
Extra dependencies
None
Min. observations
2
- fit(y, X=None)
- Return type:
- Parameters:
- fit_predict(y, horizon, **kwargs)
A random walk with drift: extrapolates the straight line between the first
and last observation. Cheap, closed-form, and a much stronger baseline than
NaiveForecaster on a trending series with no seasonality.
from omnicast import DriftForecaster
model = DriftForecaster().fit(y)
forecast = model.predict(horizon=6, level=[80, 95])
print(forecast.to_frame())
mean lower_80 upper_80 lower_95 upper_95
2026-01 199.68 193.29 206.07 189.90 209.45
2026-02 201.75 192.62 210.89 187.79 215.72
2026-03 203.83 192.53 215.13 186.55 221.11
2026-04 205.91 192.73 219.08 185.76 226.06
2026-05 207.98 193.11 222.86 185.23 230.73
2026-06 210.06 193.61 226.51 184.90 235.22
drift_ is (y[-1] - y[0]) / (n - 1) – the average per-step change over the
whole series – added to the last observation at each step:
model.drift_ # 2.0766... (~2.08 units/month, close to the synthetic trend of 2.2)
Because this series also has yearly seasonality that a straight line can’t
capture, DriftForecaster will systematically over- or under-shoot depending
on where in the cycle the forecast horizon falls; compare against
ThetaForecaster or ETSForecaster when seasonality matters. fit raises
ValueError on a series shorter than two observations, since drift is
undefined otherwise.