Skip to main content

fourier

fourier(df, freq, season_length, k, h=0, id_col='unique_id', time_col='ds')
Compute fourier seasonal terms for training and forecasting Parameters:
NameTypeDescriptionDefault
dfpandas or polars DataFrameDataframe with ids, times and values for the exogenous regressors.required
freqstr or intFrequency of the data. Must be a valid pandas or polars offset alias, or an integer.required
season_lengthintNumber of observations per unit of time. Ex: 24 Hourly data.required
kintMaximum order of the fourier termsrequired
hintForecast horizon. Defaults to 0.0
id_colstrColumn that identifies each serie. Defaults to ‘unique_id’.‘unique_id’
time_colstrColumn that identifies each timestep, its values can be timestamps or integers. Defaults to ‘ds’.‘ds’
Returns:
TypeDescription
Tuple[DFType, DFType]tuple[pandas or polars DataFrame, pandas or polars DataFrame]: A tuple containing the original DataFrame with the computed features and DataFrame with future values.

trend

trend(df, freq, h=0, id_col='unique_id', time_col='ds')
Add a trend column with consecutive integers for training and forecasting Parameters:
NameTypeDescriptionDefault
dfpandas or polars DataFrameDataframe with ids, times and values for the exogenous regressors.required
freqstr or intFrequency of the data. Must be a valid pandas or polars offset alias, or an integer.required
hintForecast horizon. Defaults to 0.0
id_colstrColumn that identifies each serie. Defaults to ‘unique_id’.‘unique_id’
time_colstrColumn that identifies each timestep, its values can be timestamps or integers. Defaults to ‘ds’.‘ds’
Returns:
TypeDescription
Tuple[DFType, DFType]tuple[pandas or polars DataFrame, pandas or polars DataFrame]: A tuple containing the original DataFrame with the computed features and DataFrame with future values.

time_features

time_features(df, freq, features, h=0, id_col='unique_id', time_col='ds')
Compute timestamp-based features for training and forecasting Parameters:
NameTypeDescriptionDefault
dfpandas or polars DataFrameDataframe with ids, times and values for the exogenous regressors.required
freqstr or intFrequency of the data. Must be a valid pandas or polars offset alias, or an integer.required
featureslist of str or callableFeatures to compute. Can be string aliases of timestamp attributes or functions to apply to the times.required
hintForecast horizon. Defaults to 0.0
id_colstrColumn that identifies each serie. Defaults to ‘unique_id’.‘unique_id’
time_colstrColumn that identifies each timestep, its values can be timestamps or integers. Defaults to ‘ds’.‘ds’
Returns:
TypeDescription
Tuple[DFType, DFType]tuple[pandas or polars DataFrame, pandas or polars DataFrame]: A tuple containing the original DataFrame with the computed features and DataFrame with future values.

future_exog_to_historic

future_exog_to_historic(
    df, freq, features, h=0, id_col="unique_id", time_col="ds"
)
Turn future exogenous features into historic by shifting them h steps. Parameters:
NameTypeDescriptionDefault
dfpandas or polars DataFrameDataframe with ids, times and values for the exogenous regressors.required
freqstr or intFrequency of the data. Must be a valid pandas or polars offset alias, or an integer.required
featureslist of strFeatures to be converted into historic.required
hintForecast horizon. Defaults to 0.0
id_colstrColumn that identifies each serie. Defaults to ‘unique_id’.‘unique_id’
time_colstrColumn that identifies each timestep, its values can be timestamps or integers. Defaults to ‘ds’.‘ds’
Returns:
TypeDescription
Tuple[DFType, DFType]tuple[pandas or polars DataFrame, pandas or polars DataFrame]: A tuple containing the original DataFrame with the computed features and DataFrame with future values.

pipeline

pipeline(df, features, freq, h=0, id_col='unique_id', time_col='ds')
Compute several features for training and forecasting Parameters:
NameTypeDescriptionDefault
dfpandas or polars DataFrameDataframe with ids, times and values for the exogenous regressors.required
featureslist of callableList of features to compute. Must take only df, freq, h, id_col and time_col (other arguments must be fixed).required
freqstr or intFrequency of the data. Must be a valid pandas or polars offset alias, or an integer.required
hintForecast horizon. Defaults to 0.0
id_colstrColumn that identifies each serie. Defaults to ‘unique_id’.‘unique_id’
time_colstrColumn that identifies each timestep, its values can be timestamps or integers. Defaults to ‘ds’.‘ds’
Returns:
TypeDescription
Tuple[DFType, DFType]tuple[pandas or polars DataFrame, pandas or polars DataFrame]: A tuple containing the original DataFrame with the computed features and DataFrame with future values.