Core Module Documentation

class neuralprophet.time_dataset.GlobalTimeDataset(uncombined_dataset, transform=None)
class neuralprophet.time_dataset.TimeDataset(*args, **kwargs)

Create a PyTorch dataset of a tabularized time-series

init_after_tabularized(inputs, targets=None)

Create Timedataset with data.

Parameters
  • inputs (ordered dict) – identical to returns from tabularize_univariate_datetime

  • targets (np.array, float) – identical to returns from tabularize_univariate_datetime

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.

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

Provides Fourier series components with the specified frequency and order.

Note: Identical to OG Prophet.

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.

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) – a list of years

  • country (string) – country name

Returns

pd.DataFrame with ‘ds’ and ‘holiday’.

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

all additive event features (both user specified and country specific) multiplicative_events (np.array): all multiplicative event features (both user specified and country specific)

Return type

additive_events (np.array)

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

all additive regressor features multiplicative_regressors (np.array): all multiplicative regressor features

Return type

additive_regressors (np.array)

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 (Season) – configuration from NeuralProphet

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)

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

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 (OrderedDict<configure.Covar>) – configuration for covariates

  • regressors_config (OrderedDict) – configuration for regressors

  • predict_mode (bool) – False (default) includes target values. True does not include targets but includes entire dataset as input

Returns

model inputs, each of len(df) but with varying dimensions

time (np.array, float), dims: (num_samples, 1) seasonalities (OrderedDict), named seasonalities, each with features

(np.array, float) of 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)

targets (np.array, float): targets to be predicted of same length as each of the model inputs,

dims: (num_samples, n_forecasts)

Return type

inputs (OrderedDict)