Skip to content

NeuralProphet

NeuralProphet

class NeuralProphet(freq=None, add_seasonality=None, custom_seasonalities=None, add_country_holidays=None, growth='linear', changepoints=None, n_changepoints=10, changepoints_range=0.8, yearly_seasonality=True, weekly_seasonality=True, daily_seasonality=False, seasonality_mode='additive', seasonality_reg=0, holidays=None, holidays_mode='additive', holidays_reg=0, trend_reg=0, trend_reg_threshold=False, learning_rate=None, epochs=None, batch_size=None, loss_func='Huber', alpha=0.05, uncertainty_samples=1000, verbose=False)[source]

NeuralProphet forecaster by wrapping NeuralProphet algorithm [1].

Direct interface to NeuralProphet, using the sktime interface. All hyper-parameters are exposed via the constructor.

Data can be passed in one of the sktime compatible formats. Like Prophet, NeuralProphet also supports integer/range and period index: * integer/range index is interpreted as days since Jan 1, 2000 * PeriodIndex is converted using the pandas method to_timestamp

Parameters:
freqstr, optional

Frequency of time series (e.g. ‘D’, ‘M’, etc.)

add_seasonalitydict, optional

Additional seasonality component parameters

custom_seasonalitieslist of dict, optional

Custom seasonality components

add_country_holidaysdict, optional

Country holidays to include

growthstr, default=”linear”

Type of trend (‘linear’ or ‘flat’)

changepointslist, optional

List of dates for trend changepoints

n_changepointsint, default=10

Number of potential trend changepoints

changepoints_rangefloat, default=0.8

Proportion of history for changepoints

yearly_seasonalitybool, default=True

Whether to include yearly seasonality

weekly_seasonalitybool, default=True

Whether to include weekly seasonality

daily_seasonalitybool, default=False

Whether to include daily seasonality

seasonality_modestr, default=”additive”

How seasonality is combined (‘additive’ or ‘multiplicative’)

seasonality_regfloat, default=0

Regularization strength for seasonality

holidayspd.DataFrame, optional

Custom holidays DataFrame

holidays_modestr, default=”additive”

How holidays are combined (‘additive’ or ‘multiplicative’)

holidays_regfloat, default=0

Regularization strength for holidays

trend_regfloat, default=0

Regularization strength for trend

trend_reg_thresholdbool, default=False

Threshold for trend regularization

learning_ratefloat, default=None

Maximum learning rate (applicable in quasi-Newton optimization)

epochsint, default=None

Number of training epochs

batch_sizeint, default=None

Number of samples per mini-batch

loss_funcstr, default=”Huber”

Type of loss to use (e.g., “Huber”, “MSE”, “MAE”, etc.)

alphafloat, default=0.05

Width of the uncertainty intervals

uncertainty_samplesint, default=1000

Number of samples for estimating uncertainty intervals

verbosebool, default=False

Whether to print status information during fitting

Attributes:
cutoff

Cut-off = “present time” state of forecaster.

fh

Forecasting horizon that was passed.

is_fitted

Whether fit has been called.

state

State of the estimator.

References

Examples

>>> from sktime.datasets import load_airline
>>> from sktime.forecasting.neuralprophet import NeuralProphet
>>> # NeuralProphet requires data with a pandas.DatetimeIndex
>>> y = load_airline().to_timestamp(freq='M')
>>> forecaster = NeuralProphet(
...     n_changepoints=0,
...     yearly_seasonality=False,
...     weekly_seasonality=False,
...     daily_seasonality=False,
...     epochs=5,
...     uncertainty_samples=0,
...     verbose=False
... )
>>> forecaster.fit(y)
NeuralProphet(...)
>>> y_pred = forecaster.predict(fh=[1,2,3])

Methods

check_is_fitted([method_name])

Check if the estimator has been fitted.

clone()

Obtain a clone of the object with same hyper-parameters and config.

clone_tags(estimator[, tag_names])

Clone tags from another object as dynamic override.

create_test_instance([parameter_set])

Construct an instance of the class, using first test parameter set.

create_test_instances_and_names([parameter_set])

Create list of all test instances and a list of names for them.

fit(y[, X, fh])

Fit forecaster to training data.

fit_predict(y[, X, fh, X_pred])

Fit and forecast time series at future horizon.

get_class_tag(tag_name[, tag_value_default])

Get class tag value from class, with tag level inheritance from parents.

get_class_tags()

Get class tags from class, with tag level inheritance from parent classes.

get_config()

Get config flags for self.

get_fitted_params([deep])

Get fitted parameters.

get_param_defaults()

Get object's parameter defaults.

get_param_names([sort])

Get object's parameter names.

get_params([deep])

Get a dict of parameters values for this object.

get_pretrained_params([deep])

Get pretrained parameters of this estimator.

get_tag(tag_name[, tag_value_default, ...])

Get tag value from instance, with tag level inheritance and overrides.

get_tags()

Get tags from instance, with tag level inheritance and overrides.

get_test_params([parameter_set])

Return testing parameter settings for the estimator.

is_composite()

Check if the object is composed of other BaseObjects.

load_from_path(serial)

Load object from file location.

load_from_serial(serial)

Load object from serialized memory container.

predict([fh, X])

Forecast time series at future horizon.

predict_interval([fh, X, coverage])

Compute/return prediction interval forecasts.

predict_proba([fh, X, marginal])

Compute/return fully probabilistic forecasts.

predict_quantiles([fh, X, alpha])

Compute/return quantile forecasts.

predict_residuals([y, X])

Return residuals of time series forecasts.

predict_var([fh, X, cov])

Compute/return variance forecasts.

pretrain(y[, X, fh])

Pre-train forecaster on panel (global) data.

reset()

Reset the object to a clean post-init state.

save([path, serialization_format])

Save serialized self to bytes-like object or to (.zip) file.

score(y[, X, fh])

Scores forecast against ground truth, using MAPE (non-symmetric).

set_config(**config_dict)

Set config flags to given values.

set_params(**params)

Set the parameters of this object.

set_random_state([random_state, deep, ...])

Set random_state pseudo-random seed parameters for self.

set_tags(**tag_dict)

Set instance level tag overrides to given values.

update(y[, X, update_params])

Update cutoff value and, optionally, fitted parameters.

update_predict(y[, cv, X, update_params, ...])

Make predictions and update model iteratively over the test set.

update_predict_single([y, fh, X, update_params])

Update model with new data and make forecasts.