Core Module Documentation

class neuralprophet.time_dataset.GlobalTimeDataset(df_dict, **kwargs)
class neuralprophet.time_dataset.TimeDataset(df, name, **kwargs)

Create a PyTorch dataset of a tabularized time-series

init_after_tabularized(inputs, targets=None)

Create Timedataset with data.

Parameters
neuralprophet.time_dataset.fourier_series(dates, period, series_order)

Provides Fourier series components with the specified frequency and order.

Note

Identical to OG Prophet.

Parameters
  • dates (pd.Series) – Containing timestamps

  • period (float) – Number of days of the period

  • series_order (int) – Number of fourier components

Returns

Matrix with seasonality features

Return type

np.array

neuralprophet.time_dataset.fourier_series_t(t, period, series_order)

Provides Fourier series components with the specified frequency and order.

Note

This function is identical to Meta AI’s Prophet Library

Parameters
  • t (pd.Series, float) – Containing time as floating point number of days

  • period (float) – Number of days of the period

  • series_order (int) – Number of fourier components

Returns

Matrix with seasonality features

Return type

np.array

neuralprophet.time_dataset.make_country_specific_holidays_df(year_list, country)

Make dataframe of country specific holidays for given years and countries

Parameters
  • year_list (list) – List of years

  • country (string) – Country name

Returns

Containing country specific holidays df with columns ‘ds’ and ‘holiday’

Return type

pd.DataFrame

neuralprophet.time_dataset.make_events_features(df, events_config=None, country_holidays_config=None)

Construct arrays of all event features

Parameters
  • df (pd.DataFrame) – Dataframe with all values including the user specified events (provided by user)

  • events_config (OrderedDict) – User specified events, each with their upper, lower windows (int), regularization

  • country_holidays_config (configure.Holidays) – Configurations (holiday_names, upper, lower windows, regularization) for country specific holidays

Returns

  • np.array – All additive event features (both user specified and country specific)

  • np.array – All multiplicative event features (both user specified and country specific)

neuralprophet.time_dataset.make_regressors_features(df, regressors_config)

Construct arrays of all scalar regressor features

Parameters
  • df (pd.DataFrame) – Dataframe with all values including the user specified regressors

  • regressors_config (OrderedDict) – User specified regressors config

Returns

  • np.array – All additive regressor features

  • np.array – All multiplicative regressor features

neuralprophet.time_dataset.seasonal_features_from_dates(dates, season_config)

Dataframe with seasonality features.

Includes seasonality features, holiday features, and added regressors.

Parameters
  • dates (pd.Series) – With dates for computing seasonality features

  • season_config (configure.Season) – Configuration for seasonalities

Returns

Dictionary with keys for each period name containing an np.array with the respective regression features. each with dims: (len(dates), 2*fourier_order)

Return type

OrderedDict

neuralprophet.time_dataset.tabularize_univariate_datetime(df, predict_mode=False, n_lags=0, n_forecasts=1, season_config=None, events_config=None, country_holidays_config=None, covar_config=None, regressors_config=None)

Create a tabular dataset from univariate timeseries for supervised forecasting.

Note

Data must be clean and have no gaps.

Parameters
  • df (pd.DataFrame) – Sequence of observations with original ds, y and normalized t, y_scaled columns

  • season_config (configure.Season) – Configuration for seasonalities

  • n_lags (int) – Number of lagged values of series to include as model inputs (aka AR-order)

  • n_forecasts (int) – Number of steps to forecast into future

  • events_config (OrderedDict)) – User specified events, each with their upper, lower windows (int) and regularization

  • country_holidays_config (OrderedDict)) – Configurations (holiday_names, upper, lower windows, regularization) for country specific holidays

  • covar_config (configure.Covar) – Configuration for covariates

  • regressors_config (OrderedDict) – Configuration for regressors

  • predict_mode (bool) –

    Chooses the prediction mode

    Options
    • (default) False: Includes target values

    • True: Does not include targets but includes entire dataset as input

Returns

  • OrderedDict – Model inputs, each of len(df) but with varying dimensions

    Note

    Contains the following data:

    Model Inputs
    • time (np.array, float), dims: (num_samples, 1)

    • seasonalities (OrderedDict), named seasonalities

    each with features (np.array, float) - dims: (num_samples, n_features[name]) * lags (np.array, float), dims: (num_samples, n_lags) * covariates (OrderedDict), named covariates, each with features (np.array, float) of dims: (num_samples, n_lags) * events (OrderedDict), events, each with features (np.array, float) of dims: (num_samples, n_lags) * regressors (OrderedDict), regressors, each with features (np.array, float) of dims: (num_samples, n_lags)

  • np.array, float – Targets to be predicted of same length as each of the model inputs, dims: (num_samples, n_forecasts)