Forecasting Different Model Types
Any time you set an estimator, different arguments become available to you when calling manual_forecast or tuning the model. Here is the documentation for all these models:
arima
forecasts with ARIMA (or AR, ARMA, SARIMA, SARIMAX).
- param tune
default False. whether the model is being tuned.
- type tune
bool
- param Xvars
the regressors to predict with. be sure to have added them to the Forecaster object first. None means no Xvars used (unlike sklearn models).
- type Xvars
list-like, str, or None
- param dynamic_testing
default True. always ignored in ARIMA (for now) - everything is set to be dynamic using statsmodels.
- type dynamic_testing
bool
- param **kwargs
passed to the ARIMA() function from statsmodels.
- returns
The evaluated metric value on the validation set if tuning a model otherwise, the list of predictions.
- rtype
(float or list)
Data:
>>> f.set_estimator('arima')
>>> f.manual_forecast() # above args are now available in this function
combo
combines at least two previously evaluted forecasts to create a new model.
- param how
one of {‘simple’,’weighted’,’splice’}, default ‘simple’. the type of combination. if ‘simple’, uses a simple average. if ‘weighted’, uses a weighted average. if ‘splice’, splices several forecasts together at specified splice points.
- type how
str
- param models
default ‘all’. which models to combine. can start with top (‘top_5’).
- type models
list-like or str
- param dynamic_testing
default True. always ignored for combo (for now and possibly forever).
- type dynamic_testing
bool
- param determine_best_by
one of _determine_best_by_, default ‘ValidationMetricValue’. if models does not start with ‘top_’ and how is not ‘weighted’, this is ignored. if how is ‘weighted’ and manual weights are specified, this is ignored.
- type determine_best_by
str
- param rebalance_weights
default 0.1. how to rebalance the weights when how = ‘weighted’. the higher, the closer the weights will be to each other for each model. if 0, the worst-performing model will be weighted with 0. must be greater than or equal to 0.
- type rebalance_weights
float
- param weights
optional. only applicable when how=’weighted’. manually specifies weights. must be the same size as models. if None and how=’weighted’, weights are set automatically. if manually passed weights do not add to 1, will rebalance them.
- type weights
list-like
- param splice_points
optional. only applicable when how=’splice’. elements in array must be str in ‘%Y-%m-%d’ or datetime object. must be exactly one less in length than the number of models. models[0] –> :splice_points[0] models[-1] –> splice_points[-1]:
- type splice_points
list-like
- returns
The predictions.
- rtype
(list)
>>> f.set_estimator('combo')
>>> f.manual_forecast() # above args are now available in this function
hwes
forecasts with holt-winters exponential smoothing.
- param tune
default False. whether the model is being tuned.
- type tune
bool
- param dynamic_testing
default True. always ignored in HWES (for now) - everything is set to be dynamic using statsmodels.
- type dynamic_testing
bool
- param **kwargs
passed to the HWES() function from statsmodels
- returns
The evaluated metric value on the validation set if tuning a model otherwise, the list of predictions.
- rtype
(float or list)
Data:
>>> f.set_estimator('hwes')
>>> f.manual_forecast() # above args are now available in this function
lstm
forecasts with a long-short term memory neural network from TensorFlow. cannot be tuned. only xvar options are the series’ own history (specify in lags argument). always uses minmax normalizer. fitted values are the last fcst_length worth of values only. anything this function can do, rnn can also do. this function is simpler to set up than rnn.
- param dynamic_testing
default True. always ignored for lstm.
- type dynamic_testing
bool
- param lags
greater than 0, default 1. the number of y-variable lags to train the model with.
- type lags
int
- param lstm_layer_sizes
default (25,). the size of each lstm layer to add. the first element is for the input layer. the size of this array minus 1 will equal the number of hidden layers in the resulting model.
- type lstm_layer_sizes
list-like
- param dropout
default (0.0,). the dropout rate for each lstm layer. must be the same size as lstm_layer_sizes.
- type dropout
list-like
- param loss
default ‘mean_absolute_error’. the loss function to minimize. see available options here:
be sure to choose one that is suitable for regression tasks.
- type loss
str
- param activation
default “tanh”. the activation function to use in each lstm layer. see available values here:
- type activation
str
- param optimizer
default “Adam”. the optimizer to use when compiling the model. see available values here:
- type optimizer
str
- param learning_rate
default 0.001. the learning rate to use when compiling the model.
- type learning_rate
float
- param random_seed
optional. set a seed for consistent results. with tensorflow networks, setting seeds does not guarantee consistent results.
- type random_seed
int
- param plot_loss
default False. whether to plot the LSTM loss function stored in history for each epoch. if validation_split passed to kwargs, will plot the validation loss as well. looks better if epochs > 1 passed to **kwargs.
- type plot_loss
bool
- param **kwargs
passed to fit() and can include epochs, verbose, callbacks, validation_split, and more
- returns
The predictions.
- rtype
(list)
>>> f.set_estimator('lstm')
>>> f.manual_forecast() # above args are now available in this function
prophet
forecasts with the prophet model from facebook.
- param tune
default False. whether to tune the forecast. if True, returns a metric. if False, returns a list of forecasted values.
- type tune
bool
- param Xvars
the regressors to predict with. be sure to have added them to the Forecaster object first. None means no Xvars used (unlike sklearn models).
- type Xvars
list-like, str, or None
- param dynamic_testing
default True. always ignored for Prophet (for now).
- type dynamic_testing
bool
- param cap
optional. specific to prophet when using logistic growth – the largest amount the model is allowed to evaluate to.
- type cap
float
- param floor
optional. specific to prophet when using logistic growth – the smallest amount the model is allowed to evaluate to.
- type floor
float
- param **kwargs
passed to the Prophet() function from fbprophet.
- returns
The evaluated metric value on the validation set if tuning a model otherwise, the list of predictions.
- rtype
(float or list)
Data:
>>> f.set_estimator('prophet')
>>> f.manual_forecast() # above args are now available in this function
rnn
forecasts with a recurrent neural network from TensorFlow, such as lstm or simple recurrent. cannot be tuned. only xvar options are the series’ own history (specified in lags argument). always uses minmax normalizer. this is a similar function to _forecast_lstm() but it is more complex to allow more flexibility. fitted values are the last fcst_length worth of values only.
- param dynamic_testing
default True. always ignored for lstm.
- type dynamic_testing
bool
- param lags
greater than 0, default 1. the number of y-variable lags to train the model with.
- type lags
int
- param hidden_layers_struct
default {‘simple’:{‘size’:8,’activation’:’tanh’}}. key is the type of each hidden layer, one of {‘simple’,’lstm’}. val is a dict where:
- key is str representing hyperparameter value: ‘units’,’activation’, etc.
- see all possible here for simple rnn:
https://www.tensorflow.org/api_docs/python/tf/keras/layers/SimpleRNN.
- here for lstm:
https://www.tensorflow.org/api_docs/python/tf/keras/layers/LSTM.
val is the desired hyperparam value. do not pass return_sequences or input_shape as these will be set automatically.
- type hidden_layers_struct
dict[str,dict[str,Union[float,str]]]
- param loss
default ‘mean_absolute_error’. the loss function to minimize. see available options here:
be sure to choose one that is suitable for regression tasks.
- type loss
str
- param optimizer
default “Adam”. the optimizer to use when compiling the model. see available values here:
- type optimizer
str
- param learning_rate
default 0.001. the learning rate to use when compiling the model.
- type learning_rate
float
- param random_seed
optional. set a seed for consistent results. with tensorflow networks, setting seeds does not guarantee consistent results.
- type random_seed
int
- param plot_loss
default False. whether to plot the LSTM loss function stored in history for each epoch. if validation_split passed to kwargs, will plot the validation loss as well. looks better if epochs > 1 passed to **kwargs.
- type plot_loss
bool
- param **kwargs
passed to fit() and can include epochs, verbose, callbacks, validation_split, and more.
- returns
The predictions.
- rtype
(list)
>>> f.set_estimator('rnn')
>>> f.manual_forecast() # above args are now available in this function
silverkite
forecasts with the silverkite model from LinkedIn greykite library.
- param tune
default False. whether to tune the forecast. if True, returns a metric. if False, returns a list of forecasted values.
- type tune
bool
- param dynamic_testing
default True. always ignored for silverkite (for now).
- type dynamic_testing
bool
- param Xvars
the regressors to predict with. be sure to have added them to the Forecaster object first. None means no Xvars used (unlike sklearn models).
- type Xvars
list-like, str, or None
- param **kwargs
passed to the ModelComponentsParam function from greykite.framework.templates.autogen.forecast_config.
- returns
The evaluated metric value on the validation set if tuning a model otherwise, the list of predictions.
- rtype
(float or list)
Data:
>>> f.set_estimator('silverkite')
>>> f.manual_forecast() # above args are now available in this function
sklearn
runs an sklearn forecast start-to-finish.
- param fcster
one of _sklearn_estimators_.
- type fcster
str
- param dynamic_testing
whether to dynamically test the forecast (meaning AR terms will be propogated with predicted values). setting this to False means faster performance, but gives a less-good indication of how well the forecast will perform out x amount of periods. when False, test-set metrics effectively become an average of one-step forecasts.
- type dynamic_testing
bool
- param tune
default False. whether the model is being tuned.
- type tune
bool
- param Xvars
the regressors to predict with. be sure to have added them to the Forecaster object first. None means all Xvars added to the Forecaster object will be used.
- type Xvars
list-like, str, or None
- param normalizer
one of _normalizer_. if not None, normalizer applied to training data only to not leak.
- type normalizer
str
- param **kwargs
treated as model hyperparameters and passed to _sklearn_imports_[model]()
- returns
The evaluated metric value on the validation set if tuning a model otherwise, the list of predictions.
- rtype
(float or list)
Data:
>>> f.set_estimator('mlr')
>>> f.manual_forecast() # above args are now available in this function