Core Module Documentation#

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

Create a PyTorch dataset of a tabularized time-series

drop_nan_after_init(df, predict_steps, drop_missing)#

Checks if inputs/targets contain any NaN values and drops them, if user opts to.

Parameters:

drop_missing (bool) – whether to automatically drop missing samples from the data

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, config_events=None, config_country_holidays=None)#

Construct arrays of all event features

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

  • config_events (configure.ConfigEvents) – User specified events, each with their upper, lower windows (int), regularization

  • config_country_holidays (configure.ConfigCountryHolidays) – 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, config_regressors)#

Construct arrays of all scalar regressor features

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

  • config_regressors (configure.ConfigFutureRegressors) – 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, config_season)#

Dataframe with seasonality features.

Includes seasonality features, holiday features, and added regressors.

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

  • config_season (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, predict_steps=1, config_season=None, config_events=None, config_country_holidays=None, config_lagged_regressors: Optional[OrderedDict[str, LaggedRegressor]] = None, config_regressors: Optional[OrderedDict[str, Regressor]] = None, config_missing=None)#

Create a tabular dataset from univariate timeseries for supervised forecasting.

Note

Data must have no gaps. If data contains missing values, they are ignored for the creation of the dataset.

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

  • config_season (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

  • config_events (configure.ConfigEvents) – User specified events, each with their upper, lower windows (int) and regularization

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

  • config_lagged_regressors (configure.ConfigLaggedRegressors) – Configurations for lagged regressors

  • config_regressors (configure.ConfigFutureRegressors) – 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)