_DeadlineMovingAverageModel¶
- class _DeadlineMovingAverageModel(window: int = 3, seasonality: str = 'month')[source]¶
Bases:
object
Moving average model that uses exact previous dates to predict.
Initialize deadline moving average model.
Length of the context is equal to the number of
window
months or years, depending on theseasonality
.- Parameters
window (int) – Number of values taken for forecast for each point.
seasonality (str) – Only allowed monthly or annual seasonality.
- Inherited-members
Methods
fit
(df, regressors)Fit DeadlineMovingAverageModel model.
forecast
(df, prediction_size)Compute autoregressive forecasts.
predict
(df, prediction_size)Compute predictions using true target data as context.
Attributes
Upper bound to context size of the model.
- fit(df: pandas.core.frame.DataFrame, regressors: List[str]) etna.models.deadline_ma._DeadlineMovingAverageModel [source]¶
Fit DeadlineMovingAverageModel model.
- Parameters
df (pd.DataFrame) – Data to fit on
regressors (List[str]) – List of the columns with regressors(ignored in this model)
- Raises
ValueError – If freq of dataframe is not supported
ValueError – If series is too short for chosen shift value
- Returns
Fitted model
- Return type
- forecast(df: pandas.core.frame.DataFrame, prediction_size: int) numpy.ndarray [source]¶
Compute autoregressive forecasts.
- Parameters
df (pandas.core.frame.DataFrame) – Features dataframe.
prediction_size (int) – Number of last timestamps to leave after making prediction. Previous timestamps will be used as a context for models that require it.
- Returns
Array with predictions.
- Raises
ValueError: – if context isn’t big enough
ValueError: – if forecast context contains NaNs
- Return type
numpy.ndarray
- predict(df: pandas.core.frame.DataFrame, prediction_size: int) numpy.ndarray [source]¶
Compute predictions using true target data as context.
- Parameters
df (pandas.core.frame.DataFrame) – Features dataframe.
prediction_size (int) – Number of last timestamps to leave after making prediction. Previous timestamps will be used as a context for models that require it.
- Returns
Array with predictions.
- Raises
ValueError: – if context isn’t big enough
ValueError: – if there are NaNs in a target column on timestamps that are required to make predictions
- Return type
numpy.ndarray
- property context_size: int¶
Upper bound to context size of the model.