autots.models package

Submodules

autots.models.base module

Base model information

@author: Colin

class autots.models.base.ModelObject(name: str = 'Uninitiated Model Name', frequency: str = 'infer', prediction_interval: float = 0.9, regression_type: str = None, fit_runtime=datetime.timedelta(0), holiday_country: str = 'US', random_seed: int = 2020, verbose: int = 0, n_jobs: int = -1)

Bases: object

Generic class for holding forecasting models.

Models should all have methods:

.fit(df, future_regressor = []) (taking a DataFrame with DatetimeIndex and n columns of n timeseries) .predict(forecast_length = int, future_regressor = [], just_point_forecast = False) .get_new_params() - return a dictionary of weighted random selected parameters

Parameters
  • name (str) – Model Name

  • frequency (str) – String alias of datetime index frequency or else ‘infer’

  • prediction_interval (float) – Confidence interval for probabilistic forecast

  • n_jobs (int) – used by some models that parallelize to multiple cores

basic_profile(df)

Capture basic training details.

create_forecast_index(forecast_length: int)

Generate a pd.DatetimeIndex appropriate for a new forecast.

Warning

Requires ModelObject.basic_profile() being called as part of .fit()

get_new_params(method: str = 'random')

Return dict of new parameters for parameter tuning.

get_params()

Return dict of current parameters.

class autots.models.base.PredictionObject(model_name: str = 'Uninitiated', forecast_length: int = 0, forecast_index=nan, forecast_columns=nan, lower_forecast=nan, forecast=nan, upper_forecast=nan, prediction_interval: float = 0.9, predict_runtime=datetime.timedelta(0), fit_runtime=datetime.timedelta(0), model_parameters={}, transformation_parameters={}, transformation_runtime=datetime.timedelta(0), per_series_metrics=nan, per_timestamp=nan, avg_metrics=nan, avg_metrics_weighted=nan, full_mae_error=None)

Bases: object

Generic class for holding forecast information.

model_name
model_parameters
transformation_parameters
forecast
upper_forecast
lower_forecast
long_form_results()

return complete results in long form

total_runtime()

return runtime for all model components in seconds

plot()
evaluate()
evaluate(actual, series_weights: dict = None, df_train=None, per_timestamp_errors: bool = False, full_mae_error: bool = True)

Evalute prediction against test actual. Fills out attributes of base object.

This fails with pd.NA values supplied.

Parameters
  • actual (pd.DataFrame) – dataframe of actual values of (forecast length * n series)

  • series_weights (dict) – key = column/series_id, value = weight

  • df_train (pd.DataFrame) – historical values of series, wide, used for setting scaler for SPL if None, actuals are used instead (suboptimal).

  • per_timestamp (bool) – whether to calculate and return per timestamp direction errors

Returns

contains a column for each series containing accuracy metrics per_timestamp (pandas.DataFrame): smape accuracy for each timestamp, avg of all series avg_metrics (pandas.Series): average values of accuracy across all input series avg_metrics_weighted (pandas.Series): average values of accuracy across all input series weighted by series_weight, if given full_mae_errors (numpy.array): abs(actual - forecast)

Return type

per_series_metrics (pandas.DataFrame)

long_form_results(id_name='SeriesID', value_name='Value', interval_name='PredictionInterval', update_datetime_name=None)

Export forecasts (including upper and lower) as single ‘long’ format output

Parameters
  • id_name (str) – name of column containing ids

  • value_name (str) – name of column containing numeric values

  • interval_name (str) – name of column telling you what is upper/lower

  • update_datetime_name (str) – if not None, adds column with current timestamp and this name

Returns

pd.DataFrame

plot(df_wide=None, series: str = None, ax=None, remove_zeroes: bool = False, start_date: str = None, **kwargs)

Generate an example plot of one series. Does not handle non-numeric forecasts.

Parameters
  • df_wide (str) – historic data for plotting actuals

  • series (str) – column name of series to plot. Random if None.

  • ax – matplotlib axes to pass through to pd.plot()

  • remove_zeroes (bool) – if True, don’t plot any zeroes

  • start_date (str) – Y-m-d string or Timestamp to remove all data before

  • passed to pd.DataFrame.plot() (**kwargs) –

total_runtime()

Combine runtimes.

autots.models.basics module

Naives and Others Requiring No Additional Packages Beyond Numpy and Pandas

class autots.models.basics.AverageValueNaive(name: str = 'AverageValueNaive', frequency: str = 'infer', prediction_interval: float = 0.9, holiday_country: str = 'US', random_seed: int = 2020, verbose: int = 0, method: str = 'Median', **kwargs)

Bases: autots.models.base.ModelObject

Naive forecasting predicting a dataframe of the series’ median values

Parameters
  • name (str) – String to identify class

  • frequency (str) – String alias of datetime index frequency or else ‘infer’

  • prediction_interval (float) – Confidence interval for probabilistic forecast

fit(df, future_regressor=None)

Train algorithm given data supplied.

Parameters

df (pandas.DataFrame) – Datetime Indexed

get_new_params(method: str = 'random')

Returns dict of new parameters for parameter tuning

get_params()

Return dict of current parameters.

predict(forecast_length: int, future_regressor=None, just_point_forecast=False)

Generates forecast data immediately following dates of index supplied to .fit()

Parameters
  • forecast_length (int) – Number of periods of data to forecast ahead

  • regressor (numpy.Array) – additional regressor, not used

  • just_point_forecast (bool) – If True, return a pandas.DataFrame of just point forecasts

Returns

Either a PredictionObject of forecasts and metadata, or if just_point_forecast == True, a dataframe of point forecasts

class autots.models.basics.LastValueNaive(name: str = 'LastValueNaive', frequency: str = 'infer', prediction_interval: float = 0.9, holiday_country: str = 'US', random_seed: int = 2020, **kwargs)

Bases: autots.models.base.ModelObject

Naive forecasting predicting a dataframe of the last series value

Parameters
  • name (str) – String to identify class

  • frequency (str) – String alias of datetime index frequency or else ‘infer’

  • prediction_interval (float) – Confidence interval for probabilistic forecast

fit(df, future_regressor=None)

Train algorithm given data supplied

Parameters

df (pandas.DataFrame) – Datetime Indexed

get_new_params(method: str = 'random')

Returns dict of new parameters for parameter tuning

get_params()

Return dict of current parameters

predict(forecast_length: int, future_regressor=None, just_point_forecast=False)

Generates forecast data immediately following dates of index supplied to .fit()

Parameters
  • forecast_length (int) – Number of periods of data to forecast ahead

  • regressor (numpy.Array) – additional regressor, not used

  • just_point_forecast (bool) – If True, return a pandas.DataFrame of just point forecasts

Returns

Either a PredictionObject of forecasts and metadata, or if just_point_forecast == True, a dataframe of point forecasts

class autots.models.basics.Motif(name: str = 'Motif', frequency: str = 'infer', prediction_interval: float = 0.9, holiday_country: str = 'US', random_seed: int = 2020, verbose: int = 0, n_jobs: int = 1, window: int = 5, point_method: str = 'weighted_mean', distance_metric: str = 'minkowski', k: int = 10, max_windows: int = 5000, multivariate: bool = False, **kwargs)

Bases: autots.models.base.ModelObject

Forecasts using a nearest neighbors type model adapted for probabilistic time series.

Parameters
  • name (str) – String to identify class

  • frequency (str) – String alias of datetime index frequency or else ‘infer’

  • prediction_interval (float) – Confidence interval for probabilistic forecast

  • n_jobs (int) – how many parallel processes to run

  • random_seed (int) – used in selecting windows if max_windows is less than total available

  • window (int) – length of forecast history to match on

  • point_method (int) – how to summarize the nearest neighbors to generate the point forecast “weighted_mean”, “mean”, “median”, “midhinge”

  • distance_metric (str) – all valid values for scipy cdist

  • k (int) – number of closest neighbors to consider

  • max_windows (int) – max number of windows to consider (a speed/accuracy tradeoff)

  • multivariate (bool) – if True, utilizes matches from all provided series for each series forecast. Else just own history of series.

fit(df, future_regressor=None)

Train algorithm given data supplied.

Parameters

df (pandas.DataFrame) – Datetime Indexed

get_new_params(method: str = 'random')

Returns dict of new parameters for parameter tuning

get_params()

Return dict of current parameters

predict(forecast_length: int, future_regressor=None, just_point_forecast=False)

Generates forecast data immediately following dates of index supplied to .fit()

Parameters
  • forecast_length (int) – Number of periods of data to forecast ahead

  • regressor (numpy.Array) – additional regressor, not used

  • just_point_forecast (bool) – If True, return a pandas.DataFrame of just point forecasts

Returns

Either a PredictionObject of forecasts and metadata, or if just_point_forecast == True, a dataframe of point forecasts

class autots.models.basics.MotifSimulation(name: str = 'MotifSimulation', frequency: str = 'infer', prediction_interval: float = 0.9, holiday_country: str = 'US', random_seed: int = 2020, phrase_len: str = '5', comparison: str = 'magnitude_pct_change_sign', shared: bool = False, distance_metric: str = 'l2', max_motifs: float = 50, recency_weighting: float = 0.1, cutoff_threshold: float = 0.9, cutoff_minimum: int = 20, point_method: str = 'median', n_jobs: int = -1, verbose: int = 1, **kwargs)

Bases: autots.models.base.ModelObject

More dark magic created by the evil mastermind of this project. Basically a highly-customized KNN

Warning: if you are forecasting many steps (large forecast_length), and interested in probabilistic upper/lower forecasts, then set recency_weighting <= 0, and have a larger cutoff_minimum

Parameters
  • name (str) – String to identify class

  • frequency (str) – String alias of datetime index frequency or else ‘infer’

  • prediction_interval (float) – Confidence interval for probabilistic forecast

  • phrase_len (int) – length of motif vectors to compare as samples

  • comparison (str) – method to process data before comparison, ‘magnitude’ is original data

  • shared (bool) – whether to compare motifs across all series together, or separately

  • distance_metric (str) – passed through to sklearn pairwise_distances

  • max_motifs (float) – number of motifs to compare per series. If less 1, used as % of length training data

  • recency_weighting (float) – amount to the value of more recent data.

  • cutoff_threshold (float) – lowest value of distance metric to allow into forecast

  • cutoff_minimum (int) – minimum number of motif vectors to include in forecast.

  • point_method (str) – summarization method to choose forecast on, ‘sample’, ‘mean’, ‘sign_biased_mean’, ‘median’

fit(df, future_regressor=None)

Train algorithm given data supplied.

Parameters

df (pandas.DataFrame) – Datetime Indexed

get_new_params(method: str = 'random')

Return dict of new parameters for parameter tuning.

get_params()

Return dict of current parameters.

predict(forecast_length: int, future_regressor=None, just_point_forecast=False)

Generates forecast data immediately following dates of index supplied to .fit()

Parameters
  • forecast_length (int) – Number of periods of data to forecast ahead

  • regressor (numpy.Array) – additional regressor, not used

  • just_point_forecast (bool) – If True, return a pandas.DataFrame of just point forecasts

Returns

Either a PredictionObject of forecasts and metadata, or if just_point_forecast == True, a dataframe of point forecasts

class autots.models.basics.NVAR(name: str = 'NVAR', frequency: str = 'infer', prediction_interval: float = 0.9, holiday_country: str = 'US', random_seed: int = 2020, verbose: int = 0, k: int = 1, ridge_param: float = 2.5e-06, warmup_pts: int = 1, seed_pts: int = 1, seed_weighted: str = None, batch_size: int = 5, batch_method: str = 'input_order', **kwargs)

Bases: autots.models.base.ModelObject

Nonlinear Variable Autoregression or ‘Next-Generation Reservoir Computing’

based on https://github.com/quantinfo/ng-rc-paper-code/ Gauthier, D.J., Bollt, E., Griffith, A. et al. Next generation reservoir computing. Nat Commun 12, 5564 (2021). https://doi.org/10.1038/s41467-021-25801-2 with adjustments to make it probabilistic and to scale better

Parameters
  • name (str) – String to identify class

  • frequency (str) – String alias of datetime index frequency or else ‘infer’

  • prediction_interval (float) – Confidence interval for probabilistic forecast

  • k (int) – the AR order (keep this small, larger is slow and usually pointless)

  • ridge_param (float) – standard lambda for ridge regression

  • warmup_pts (int) – in reality, passing 1 here (no warmup) is fine

  • batch_size (int) – nvar scales exponentially, to scale linearly, series are split into batches of size n

  • batch_method (str) – method for collecting series to make batches

fit(df, future_regressor=None)

Train algorithm given data supplied.

Parameters

df (pandas.DataFrame) – Datetime Indexed

get_new_params(method: str = 'random')

Returns dict of new parameters for parameter tuning

get_params()

Return dict of current parameters.

predict(forecast_length: int, future_regressor=None, just_point_forecast=False)

Generates forecast data immediately following dates of index supplied to .fit()

Parameters
  • forecast_length (int) – Number of periods of data to forecast ahead

  • regressor (numpy.Array) – additional regressor, not used

  • just_point_forecast (bool) – If True, return a pandas.DataFrame of just point forecasts

Returns

Either a PredictionObject of forecasts and metadata, or if just_point_forecast == True, a dataframe of point forecasts

class autots.models.basics.SeasonalNaive(name: str = 'SeasonalNaive', frequency: str = 'infer', prediction_interval: float = 0.9, holiday_country: str = 'US', random_seed: int = 2020, verbose: int = 0, lag_1: int = 7, lag_2: int = None, method: str = 'LastValue', **kwargs)

Bases: autots.models.base.ModelObject

Naive forecasting predicting a dataframe with seasonal (lag) forecasts.

Concerto No. 2 in G minor, Op. 8, RV 315

Parameters
  • name (str) – String to identify class

  • frequency (str) – String alias of datetime index frequency or else ‘infer’

  • prediction_interval (float) – Confidence interval for probabilistic forecast

  • method (str) – Either ‘LastValue’ (use last value of lag n) or ‘Mean’ (avg of all lag n)

  • lag_1 (int) – The lag of the seasonality, should int > 1.

  • lag_2 (int) – Optional second lag of seasonality which is averaged with first lag to produce forecast.

fit(df, future_regressor=None)

Train algorithm given data supplied.

Parameters

df (pandas.DataFrame) – Datetime Indexed

get_new_params(method: str = 'random')

Return dict of new parameters for parameter tuning.

get_params()

Return dict of current parameters.

predict(forecast_length: int, future_regressor=None, just_point_forecast: bool = False)

Generate forecast data immediately following dates of .fit().

Parameters
  • forecast_length (int) – Number of periods of data to forecast ahead

  • regressor (numpy.Array) – additional regressor, not used

  • just_point_forecast (bool) – If True, return a pandas.DataFrame of just point forecasts

Returns

Either a PredictionObject of forecasts and metadata, or if just_point_forecast == True, a dataframe of point forecasts

class autots.models.basics.SectionalMotif(name: str = 'SectionalMotif', frequency: str = 'infer', prediction_interval: float = 0.9, holiday_country: str = 'US', random_seed: int = 2020, verbose: int = 0, regression_type: str = None, window: int = 5, point_method: str = 'weighted_mean', distance_metric: str = 'nan_euclidean', include_differenced: bool = False, k: int = 10, stride_size: int = 1, **kwargs)

Bases: autots.models.base.ModelObject

Forecasts using a nearest neighbors type model adapted for probabilistic time series. This version takes the distance metric average for all series at once.

Parameters
  • name (str) – String to identify class

  • frequency (str) – String alias of datetime index frequency or else ‘infer’

  • prediction_interval (float) – Confidence interval for probabilistic forecast

  • regression_type (str) – “User” or None. If used, will be as covariate. The ratio of num_series:num_regressor_series will largely determine the impact

  • window (int) – length of forecast history to match on

  • point_method (int) – how to summarize the nearest neighbors to generate the point forecast “weighted_mean”, “mean”, “median”, “midhinge”

  • distance_metric (str) – all valid values for scipy cdist + “nan_euclidean” from sklearn

  • include_differenced (bool) – True to have the distance metric result be an average of the distance on absolute values as well as differenced values

  • k (int) – number of closest neighbors to consider

  • stride_size (int) – how many obs to skip between each new window. Higher numbers will reduce the number of matching windows and make the model faster.

fit(df, future_regressor=None)

Train algorithm given data supplied.

Parameters
  • df (pandas.DataFrame) – Datetime Indexed

  • regressor (numpy.Array) – additional regressor

get_new_params(method: str = 'random')

Returns dict of new parameters for parameter tuning

get_params()

Return dict of current parameters

predict(forecast_length: int, future_regressor=None, just_point_forecast=False)

Generates forecast data immediately following dates of index supplied to .fit()

Parameters
  • forecast_length (int) – Number of periods of data to forecast ahead

  • regressor (numpy.Array) – additional regressor

  • just_point_forecast (bool) – If True, return a pandas.DataFrame of just point forecasts

Returns

Either a PredictionObject of forecasts and metadata, or if just_point_forecast == True, a dataframe of point forecasts

class autots.models.basics.ZeroesNaive(name: str = 'ZeroesNaive', frequency: str = 'infer', prediction_interval: float = 0.9, holiday_country: str = 'US', random_seed: int = 2020, verbose: int = 0, **kwargs)

Bases: autots.models.base.ModelObject

Naive forecasting predicting a dataframe of zeroes (0’s)

Parameters
  • name (str) – String to identify class

  • frequency (str) – String alias of datetime index frequency or else ‘infer’

  • prediction_interval (float) – Confidence interval for probabilistic forecast

fit(df, future_regressor=None)

Train algorithm given data supplied

Parameters

df (pandas.DataFrame) – Datetime Indexed

get_new_params(method: str = 'random')

Returns dict of new parameters for parameter tuning

get_params()

Return dict of current parameters

predict(forecast_length: int, future_regressor=None, just_point_forecast=False)

Generates forecast data immediately following dates of index supplied to .fit()

Parameters
  • forecast_length (int) – Number of periods of data to forecast ahead

  • regressor (numpy.Array) – additional regressor, not used

  • just_point_forecast (bool) – If True, return a pandas.DataFrame of just point forecasts

Returns

Either a PredictionObject of forecasts and metadata, or if just_point_forecast == True, a dataframe of point forecasts

autots.models.basics.looped_motif(Xa, Xb, name, r_arr=None, window=10, distance_metric='minkowski', k=10, point_method='mean', prediction_interval=0.9)

inner function for Motif model.

autots.models.basics.predict_reservoir(df, forecast_length, prediction_interval=None, warmup_pts=1, k=2, ridge_param=2.5e-06, seed_pts: int = 1, seed_weighted: str = None)

Nonlinear Variable Autoregression or ‘Next-Generation Reservoir Computing’

based on https://github.com/quantinfo/ng-rc-paper-code/ Gauthier, D.J., Bollt, E., Griffith, A. et al. Next generation reservoir computing. Nat Commun 12, 5564 (2021). https://doi.org/10.1038/s41467-021-25801-2 with adjustments to make it probabilistic

This is very slow and memory hungry when n series/dimensions gets big (ie > 50). Already effectively parallelized by linpack it seems. It’s very sensitive to error in most recent data point! The seed_pts and seed_weighted can help address that.

Parameters
  • name (str) – String to identify class

  • frequency (str) – String alias of datetime index frequency or else ‘infer’

  • prediction_interval (float) – Confidence interval for probabilistic forecast

  • k (int) – the AR order (keep this small, larger is slow and usually pointless)

  • ridge_param (float) – standard lambda for ridge regression

  • warmup_pts (int) – in reality, passing 1 here (no warmup) is fine

  • seed_pts (int) – number of back steps to use to simulate future if > 10, also increases search space of probabilistic forecast

  • seed_weighted (str) – how to summarize most recent points if seed_pts > 1

autots.models.dnn module

Neural Nets.

class autots.models.dnn.KerasRNN(rnn_type: str = 'LSTM', kernel_initializer: str = 'lecun_uniform', hidden_layer_sizes: tuple = (32, 32, 32), optimizer: str = 'adam', loss: str = 'huber', epochs: int = 50, batch_size: int = 32, shape=1, verbose: int = 1, random_seed: int = 2020)

Bases: object

Wrapper for Tensorflow Keras based RNN.

Parameters
  • rnn_type (str) – Keras cell type ‘GRU’ or default ‘LSTM’

  • kernel_initializer (str) – passed to first keras LSTM or GRU layer

  • hidden_layer_sizes (tuple) – of len 1 or 3 passed to first keras LSTM or GRU layers

  • optimizer (str) – Passed to keras model.compile

  • loss (str) – Passed to keras model.compile

  • epochs (int) – Passed to keras model.fit

  • batch_size (int) – Passed to keras model.fit

  • verbose (int) – 0, 1 or 2. Passed to keras model.fit

  • random_seed (int) – passed to tf.random.set_seed()

fit(X, Y)

Train the model on dataframes of X and Y.

predict(X)

Predict on dataframe of X.

class autots.models.dnn.Transformer(head_size=256, num_heads=4, ff_dim=4, num_transformer_blocks=4, mlp_units=[128], mlp_dropout=0.4, dropout=0.25, optimizer: str = 'adam', loss: str = 'huber', epochs: int = 50, batch_size: int = 32, verbose: int = 1, random_seed: int = 2020)

Bases: object

Wrapper for Tensorflow Keras based Transformer.

based on: https://keras.io/examples/timeseries/timeseries_transformer_classification/

Parameters
  • optimizer (str) – Passed to keras model.compile

  • loss (str) – Passed to keras model.compile

  • epochs (int) – Passed to keras model.fit

  • batch_size (int) – Passed to keras model.fit

  • verbose (int) – 0, 1 or 2. Passed to keras model.fit

  • random_seed (int) – passed to tf.random.set_seed()

fit(X, Y)

Train the model on dataframes of X and Y.

predict(X)

Predict on dataframe of X.

autots.models.dnn.transformer_build_model(input_shape, output_shape, head_size, num_heads, ff_dim, num_transformer_blocks, mlp_units, dropout=0, mlp_dropout=0)
autots.models.dnn.transformer_encoder(inputs, head_size, num_heads, ff_dim, dropout=0)

autots.models.ensemble module

Tools for generating and forecasting with ensembles of models.

autots.models.ensemble.BestNEnsemble(ensemble_params, forecasts, lower_forecasts, upper_forecasts, forecasts_runtime: dict, prediction_interval: float = 0.9)

Generate mean forecast for ensemble of models.

Parameters
  • ensemble_params (dict) – BestN ensemble param dict should have “model_weights”: {model_id: weight} where 1 is default weight per model

  • forecasts (dict) – {forecast_id: forecast dataframe} for all models same for lower_forecasts, upper_forecasts

  • forecast_runtime (dict) – dictionary of {forecast_id: timedelta of runtime}

  • prediction_interval (float) – metadata on interval

autots.models.ensemble.DistEnsemble(ensemble_params, forecasts_list, forecasts, lower_forecasts, upper_forecasts, forecasts_runtime, prediction_interval)

Generate forecast for distance ensemble.

autots.models.ensemble.EnsembleForecast(ensemble_str, ensemble_params, forecasts_list, forecasts, lower_forecasts, upper_forecasts, forecasts_runtime, prediction_interval, df_train=None, prematched_series: dict = None)

Return PredictionObject for given ensemble method.

autots.models.ensemble.EnsembleTemplateGenerator(initial_results, forecast_length: int = 14, ensemble: str = 'simple', score_per_series=None)

Generate class 1 (non-horizontal) ensemble templates given a table of results.

autots.models.ensemble.HDistEnsemble(ensemble_params, forecasts_list, forecasts, lower_forecasts, upper_forecasts, forecasts_runtime, prediction_interval)

Generate forecast for per_series per distance ensembling.

autots.models.ensemble.HorizontalEnsemble(ensemble_params, forecasts_list, forecasts, lower_forecasts, upper_forecasts, forecasts_runtime, prediction_interval, df_train=None, prematched_series: dict = None)

Generate forecast for per_series ensembling.

autots.models.ensemble.HorizontalTemplateGenerator(per_series, model_results, forecast_length: int = 14, ensemble: str = 'horizontal', subset_flag: bool = True, per_series2=None)

Generate horizontal ensemble templates given a table of results.

autots.models.ensemble.MosaicEnsemble(ensemble_params, forecasts_list, forecasts, lower_forecasts, upper_forecasts, forecasts_runtime, prediction_interval, df_train=None, prematched_series: dict = None)

Generate forecast for mosaic ensembling.

Parameters

prematched_series (dict) – from outer horizontal generalization, possibly different than params

autots.models.ensemble.generalize_horizontal(df_train, known_matches: dict, available_models: list, full_models: list = None)

generalize a horizontal model trained on a subset of all series

Parameters
  • df_train (pd.DataFrame) – time series data

  • known_matches (dict) – series:model dictionary for some to all series

  • available_models (dict) – list of models actually available

  • full_models (dict) – models that are available for every single series

autots.models.ensemble.generate_mosaic_template(initial_results, full_mae_ids, num_validations, col_names, full_mae_errors, **kwargs)

Generate an ensemble template from results.

autots.models.ensemble.horizontal_classifier(df_train, known: dict, method: str = 'whatever')

CLassify unknown series with the appropriate model for horizontal ensembling.

Parameters
  • df_train (pandas.DataFrame) – historical data about the series. Columns = series_ids.

  • known (dict) – dict of series_id: classifier outcome including some but not all series in df_train.

Returns

dict.

autots.models.ensemble.mosaic_classifier(df_train, known)

CLassify unknown series with the appropriate model for mosaic ensembles.

autots.models.ensemble.mosaic_or_horizontal(all_series: dict)

Take a mosaic or horizontal model and return series or models.

Parameters

all_series (dict) – dict of series: model (or list of models)

autots.models.ensemble.mosaic_to_horizontal(ModelParameters, forecast_period: int = 0)

Take a mosaic template and pull a single forecast step as a horizontal model.

Parameters
  • ModelParameters (dict) – the json.loads() of the ModelParameters of a mosaic ensemble template

  • forecast_period (int) – when to choose the model, starting with 0 where 0 would be the first forecast datestamp, 1 would be the second, and so on must be less than forecast_length that the model was trained on.

Returs:

ModelParameters (dict)

autots.models.ensemble.parse_horizontal(all_series: dict, model_id: str = None, series_id: str = None)

Take a mosaic or horizontal model and return series or models.

Parameters
  • all_series (dict) – dict of series: model (or list of models)

  • model_id (str) – name of model to find series for

  • series_id (str) – name of series to find models for

Returns

list

autots.models.ensemble.summarize_series(df)

Summarize time series data. For now just df.describe().

autots.models.gluonts module

GluonTS

Excellent models, released by Amazon, scale well. Except it is really the only thing I use that runs mxnet, and it takes a while to train these guys…

class autots.models.gluonts.GluonTS(name: str = 'GluonTS', frequency: str = 'infer', prediction_interval: float = 0.9, regression_type: str = None, holiday_country: str = 'US', random_seed: int = 2020, verbose: int = 0, gluon_model: str = 'DeepAR', epochs: int = 20, learning_rate: float = 0.001, context_length=10, forecast_length: int = 14, **kwargs)

Bases: autots.models.base.ModelObject

GluonTS based on mxnet.

Parameters
  • name (str) – String to identify class

  • frequency (str) – String alias of datetime index frequency or else ‘infer’

  • prediction_interval (float) – Confidence interval for probabilistic forecast

  • regression_type (str) – Not yet implemented

  • gluon_model (str) – Model Structure to Use - [‘DeepAR’, ‘NPTS’, ‘DeepState’, ‘WaveNet’,’DeepFactor’, ‘Transformer’,’SFF’, ‘MQCNN’, ‘DeepVAR’, ‘GPVAR’, ‘NBEATS’]

  • epochs (int) – Number of neural network training epochs. Higher generally results in better, then over fit.

  • learning_rate (float) – Neural net training parameter

  • context_length (str) – int window, ‘2ForecastLength’, or ‘nForecastLength’

  • forecast_length (int) – Length to forecast. Unlike in other methods, this must be provided before fitting model

fit(df, future_regressor=None)

Train algorithm given data supplied.

Parameters

df (pandas.DataFrame) – Datetime Indexed

get_new_params(method: str = 'random')

Return dict of new parameters for parameter tuning.

get_params()

Return dict of current parameters.

predict(forecast_length: int, future_regressor=[], just_point_forecast=False)

Generates forecast data immediately following dates of index supplied to .fit()

Parameters
  • forecast_length (int) – Number of periods of data to forecast ahead

  • regressor (numpy.Array) – additional regressor, not used

  • just_point_forecast (bool) – If True, return a pandas.DataFrame of just point forecasts

Returns

Either a PredictionObject of forecasts and metadata, or if just_point_forecast == True, a dataframe of point forecasts

autots.models.greykite module

Greykite.

class autots.models.greykite.Greykite(name: str = 'Greykite', frequency: str = 'infer', prediction_interval: float = 0.9, holiday: bool = False, growth: str = None, regression_type: str = None, holiday_country: str = 'US', random_seed: int = 2020, verbose: int = 0, n_jobs: int = None)

Bases: autots.models.base.ModelObject

Parameters
  • name (str) – String to identify class

  • frequency (str) – String alias of datetime index frequency or else ‘infer’

  • prediction_interval (float) – Confidence interval for probabilistic forecast

  • holiday (bool) – If true, include holidays

  • regression_type (str) – type of regression (None, ‘User’)

fit(df, future_regressor=[])

Train algorithm given data supplied.

Parameters

df (pandas.DataFrame) – Datetime Indexed

get_new_params(method: str = 'random')

Return dict of new parameters for parameter tuning.

get_params()

Return dict of current parameters.

predict(forecast_length: int, future_regressor=[], just_point_forecast: bool = False)

Generates forecast data immediately following dates of index supplied to .fit()

Parameters
  • forecast_length (int) – Number of periods of data to forecast ahead

  • regressor (numpy.Array) – additional regressor, not used

  • just_point_forecast (bool) – If True, return a pandas.DataFrame of just point forecasts

Returns

Either a PredictionObject of forecasts and metadata, or if just_point_forecast == True, a dataframe of point forecasts

autots.models.greykite.seek_the_oracle(df_index, series, col, forecast_length, freq, prediction_interval=0.9, model_template='silverkite', growth=None, holiday=True, holiday_country='UnitedStates', regressors=None, verbose=0, inner_n_jobs=1, **kwargs)

Internal. For loop or parallel version of Greykite.

autots.models.model_list module

Lists of models grouped by aspects.

autots.models.model_list.auto_model_list(n_jobs, n_series, frequency)

autots.models.prophet module

Facebook’s Prophet

Since Prophet install can be finicky on Windows, it will be an optional dependency.

class autots.models.prophet.FBProphet(name: str = 'FBProphet', frequency: str = 'infer', prediction_interval: float = 0.9, holiday: bool = False, regression_type: str = None, holiday_country: str = 'US', random_seed: int = 2020, verbose: int = 0, n_jobs: int = None)

Bases: autots.models.base.ModelObject

Facebook’s Prophet

‘thou shall count to 3, no more, no less, 3 shall be the number thou shall count, and the number of the counting shall be 3. 4 thou shall not count, neither count thou 2, excepting that thou then preceed to 3.’ -Python

Parameters
  • name (str) – String to identify class

  • frequency (str) – String alias of datetime index frequency or else ‘infer’

  • prediction_interval (float) – Confidence interval for probabilistic forecast

  • holiday (bool) – If true, include holidays

  • regression_type (str) – type of regression (None, ‘User’)

fit(df, future_regressor=None)

Train algorithm given data supplied.

Parameters

df (pandas.DataFrame) – Datetime Indexed

get_new_params(method: str = 'random')

Return dict of new parameters for parameter tuning.

get_params()

Return dict of current parameters.

predict(forecast_length: int, future_regressor=None, just_point_forecast: bool = False)

Generates forecast data immediately following dates of index supplied to .fit()

Parameters
  • forecast_length (int) – Number of periods of data to forecast ahead

  • regressor (numpy.Array) – additional regressor, not used

  • just_point_forecast (bool) – If True, return a pandas.DataFrame of just point forecasts

Returns

Either a PredictionObject of forecasts and metadata, or if just_point_forecast == True, a dataframe of point forecasts

autots.models.sklearn module

Sklearn dependent models

Decision Tree, Elastic Net, Random Forest, MLPRegressor, KNN, Adaboost

class autots.models.sklearn.ComponentAnalysis(name: str = 'ComponentAnalysis', frequency: str = 'infer', prediction_interval: float = 0.9, holiday_country: str = 'US', random_seed: int = 2020, verbose: int = 0, n_components: int = 10, forecast_length: int = 14, model: str = 'GLS', model_parameters: dict = {}, decomposition: str = 'PCA', n_jobs: int = -1)

Bases: autots.models.base.ModelObject

Forecasting on principle components.

Parameters
  • name (str) – String to identify class

  • frequency (str) – String alias of datetime index frequency or else ‘infer’

  • prediction_interval (float) – Confidence interval for probabilistic forecast

  • model (str) – An AutoTS model str

  • model_parameters (dict) – parameters to pass to AutoTS model

  • n_components (int) – int or ‘NthN’ number of components to use

  • decomposition (str) – decomposition method to use from scikit-learn

fit(df, future_regressor=None)

Train algorithm given data supplied.

Parameters

df (pandas.DataFrame) – Datetime Indexed

get_new_params(method: str = 'random')

Return dict of new parameters for parameter tuning.

get_params()

Return dict of current parameters.

predict(forecast_length: int, future_regressor=None, just_point_forecast: bool = False)

Generate forecast data immediately following dates of .fit().

Parameters
  • forecast_length (int) – Number of periods of data to forecast ahead

  • regressor (numpy.Array) – additional regressor, not used

  • just_point_forecast (bool) – If True, return a pandas.DataFrame of just point forecasts

Returns

Either a PredictionObject of forecasts and metadata, or if just_point_forecast == True, a dataframe of point forecasts

class autots.models.sklearn.DatepartRegression(name: str = 'DatepartRegression', frequency: str = 'infer', prediction_interval: float = 0.9, holiday_country: str = 'US', random_seed: int = 2020, verbose: int = 0, forecast_length: int = 1, n_jobs: int = None, regression_model: dict = {'model': 'DecisionTree', 'model_params': {'max_depth': 5, 'min_samples_split': 2}}, datepart_method: str = 'expanded', regression_type: str = None, **kwargs)

Bases: autots.models.base.ModelObject

Regression not on series but datetime

Parameters
  • name (str) – String to identify class

  • frequency (str) – String alias of datetime index frequency or else ‘infer’

  • prediction_interval (float) – Confidence interval for probabilistic forecast

fit(df, future_regressor=None)

Train algorithm given data supplied.

Parameters

df (pandas.DataFrame) – Datetime Indexed

get_new_params(method: str = 'random')

Return dict of new parameters for parameter tuning.

get_params()

Return dict of current parameters.

predict(forecast_length: int, future_regressor=None, just_point_forecast: bool = False)

Generate forecast data immediately following dates of index supplied to .fit().

Parameters
  • forecast_length (int) – Number of periods of data to forecast ahead

  • future_regressor (pandas.DataFrame or Series) – Datetime Indexed

  • just_point_forecast (bool) – If True, return a pandas.DataFrame of just point forecasts

Returns

Either a PredictionObject of forecasts and metadata, or if just_point_forecast == True, a dataframe of point forecasts

class autots.models.sklearn.MultivariateRegression(name: str = 'MultivariateRegression', frequency: str = 'infer', prediction_interval: float = 0.9, regression_type: str = None, holiday_country: str = 'US', verbose: int = 0, random_seed: int = 2020, forecast_length: int = 7, regression_model: dict = {'model': 'RandomForest', 'model_params': {}}, holiday: bool = False, mean_rolling_periods: int = 30, macd_periods: int = None, std_rolling_periods: int = 7, max_rolling_periods: int = 7, min_rolling_periods: int = 7, ewm_var_alpha: float = None, quantile90_rolling_periods: int = None, quantile10_rolling_periods: int = None, ewm_alpha: float = 0.5, additional_lag_periods: int = 7, abs_energy: bool = False, rolling_autocorr_periods: int = None, datepart_method: str = None, polynomial_degree: int = None, window: int = None, quantile_params: dict = {'learning_rate': 0.1, 'max_depth': 20, 'min_samples_leaf': 4, 'min_samples_split': 5, 'n_estimators': 250}, n_jobs: int = -1, **kwargs)

Bases: autots.models.base.ModelObject

Regression-framed approach to forecasting using sklearn. A multiariate version of rolling regression: ie each series is agged independently but modeled together

Parameters
  • name (str) – String to identify class

  • frequency (str) – String alias of datetime index frequency or else ‘infer’

  • prediction_interval (float) – Confidence interval for probabilistic forecast

  • holiday (bool) – If true, include holiday flags

  • regression_type (str) – type of regression (None, ‘User’)

fit(df, future_regressor=None)

Train algorithm given data supplied.

Parameters
  • df (pandas.DataFrame) – Datetime Indexed

  • future_regressor (pandas.DataFrame or Series) – Datetime Indexed

get_new_params(method: str = 'random')

Return dict of new parameters for parameter tuning.

get_params()

Return dict of current parameters.

predict(forecast_length: int = None, just_point_forecast: bool = False, future_regressor=None)

Generate forecast data immediately following dates of index supplied to .fit().

Parameters
  • forecast_length (int) – Number of periods of data to forecast ahead ignored here for this model, must be set in __init__ before .fit()

  • future_regressor (pd.DataFrame) – additional regressor

  • just_point_forecast (bool) – If True, return a pandas.DataFrame of just point forecasts

Returns

Either a PredictionObject of forecasts and metadata, or if just_point_forecast == True, a dataframe of point forecasts

class autots.models.sklearn.RollingRegression(name: str = 'RollingRegression', frequency: str = 'infer', prediction_interval: float = 0.9, regression_type: str = None, holiday_country: str = 'US', verbose: int = 0, random_seed: int = 2020, regression_model: dict = {'model': 'ExtraTrees', 'model_params': {}}, holiday: bool = False, mean_rolling_periods: int = 30, macd_periods: int = None, std_rolling_periods: int = 7, max_rolling_periods: int = 7, min_rolling_periods: int = 7, ewm_var_alpha: int = None, quantile90_rolling_periods: int = None, quantile10_rolling_periods: int = None, ewm_alpha: float = 0.5, additional_lag_periods: int = 7, abs_energy: bool = False, rolling_autocorr_periods: int = None, add_date_part: str = None, polynomial_degree: int = None, x_transform: str = None, window: int = None, n_jobs: int = -1, **kwargs)

Bases: autots.models.base.ModelObject

General regression-framed approach to forecasting using sklearn.

Who are you who are so wise in the ways of science? I am Arthur, King of the Britons. -Python

Parameters
  • name (str) – String to identify class

  • frequency (str) – String alias of datetime index frequency or else ‘infer’

  • prediction_interval (float) – Confidence interval for probabilistic forecast

  • holiday (bool) – If true, include holiday flags

  • regression_type (str) – type of regression (None, ‘User’)

fit(df, future_regressor=None)

Train algorithm given data supplied.

Parameters
  • df (pandas.DataFrame) – Datetime Indexed

  • future_regressor (pandas.DataFrame or Series) – Datetime Indexed

get_new_params(method: str = 'random')

Return dict of new parameters for parameter tuning.

get_params()

Return dict of current parameters.

predict(forecast_length: int, future_regressor=None, just_point_forecast: bool = False)

Generate forecast data immediately following dates of index supplied to .fit().

Parameters
  • forecast_length (int) – Number of periods of data to forecast ahead

  • regressor (numpy.Array) – additional regressor

  • just_point_forecast (bool) – If True, return a pandas.DataFrame of just point forecasts

Returns

Either a PredictionObject of forecasts and metadata, or if just_point_forecast == True, a dataframe of point forecasts

class autots.models.sklearn.UnivariateRegression(name: str = 'UnivariateRegression', frequency: str = 'infer', prediction_interval: float = 0.9, regression_type: str = None, holiday_country: str = 'US', verbose: int = 0, random_seed: int = 2020, forecast_length: int = 7, regression_model: dict = {'model': 'ExtraTrees', 'model_params': {}}, holiday: bool = False, mean_rolling_periods: int = 30, macd_periods: int = None, std_rolling_periods: int = 7, max_rolling_periods: int = 7, min_rolling_periods: int = 7, ewm_var_alpha: float = None, ewm_alpha: float = 0.5, additional_lag_periods: int = 7, abs_energy: bool = False, rolling_autocorr_periods: int = None, add_date_part: str = None, polynomial_degree: int = None, x_transform: str = None, window: int = None, n_jobs: int = -1, **kwargs)

Bases: autots.models.base.ModelObject

Regression-framed approach to forecasting using sklearn. A univariate version of rolling regression: ie each series is modeled independently

Parameters
  • name (str) – String to identify class

  • frequency (str) – String alias of datetime index frequency or else ‘infer’

  • prediction_interval (float) – Confidence interval for probabilistic forecast

  • holiday (bool) – If true, include holiday flags

  • regression_type (str) – type of regression (None, ‘User’)

fit(df, future_regressor=None)

Train algorithm given data supplied.

Parameters
  • df (pandas.DataFrame) – Datetime Indexed

  • future_regressor (pandas.DataFrame or Series) – Datetime Indexed

get_new_params(method: str = 'random')

Return dict of new parameters for parameter tuning.

get_params()

Return dict of current parameters.

predict(forecast_length: int = None, just_point_forecast: bool = False, future_regressor=None)

Generate forecast data immediately following dates of index supplied to .fit().

Parameters
  • forecast_length (int) – Number of periods of data to forecast ahead ignored here for this model, must be set in __init__ before .fit()

  • future_regressor (pd.DataFrame) – additional regressor

  • just_point_forecast (bool) – If True, return a pandas.DataFrame of just point forecasts

Returns

Either a PredictionObject of forecasts and metadata, or if just_point_forecast == True, a dataframe of point forecasts

class autots.models.sklearn.WindowRegression(name: str = 'WindowRegression', frequency: str = 'infer', prediction_interval: float = 0.9, holiday_country: str = 'US', random_seed: int = 2022, verbose: int = 0, window_size: int = 10, regression_model: dict = {'model': 'RandomForest', 'model_params': {}}, input_dim: str = 'univariate', output_dim: str = 'forecast_length', normalize_window: bool = False, shuffle: bool = False, forecast_length: int = 1, max_windows: int = 5000, regression_type: str = None, n_jobs: int = -1, **kwargs)

Bases: autots.models.base.ModelObject

Regression use the last n values as the basis of training data.

Parameters
  • name (str) – String to identify class

  • frequency (str) – String alias of datetime index frequency or else ‘infer’

  • prediction_interval (float) – Confidence interval for probabilistic forecast

  • regression_type (#) – str = None,

fit(df, future_regressor=None)

Train algorithm given data supplied.

Parameters

df (pandas.DataFrame) – Datetime Indexed

get_new_params(method: str = 'random')

Return dict of new parameters for parameter tuning.

get_params()

Return dict of current parameters.

predict(forecast_length: int, future_regressor=None, just_point_forecast: bool = False)

Generate forecast data immediately following dates of .fit().

Parameters
  • forecast_length (int) – Number of periods of data to forecast ahead

  • regressor (numpy.Array) – additional regressor, not used

  • just_point_forecast (bool) – If True, return a pandas.DataFrame of just point forecasts

Returns

Either a PredictionObject of forecasts and metadata, or if just_point_forecast == True, a dataframe of point forecasts

autots.models.sklearn.generate_regressor_params(model_dict=None)
autots.models.sklearn.retrieve_regressor(regression_model: dict = {'model': 'Adaboost', 'model_params': {'base_estimator': 'DecisionTree', 'learning_rate': 1.0, 'loss': 'linear', 'n_estimators': 50}}, verbose: int = 0, verbose_bool: bool = False, random_seed: int = 2020, n_jobs: int = 1, multioutput: bool = True)

Convert a model param dict to model object for regression frameworks.

autots.models.sklearn.rolling_x_regressor(df, mean_rolling_periods: int = 30, macd_periods: int = None, std_rolling_periods: int = 7, max_rolling_periods: int = None, min_rolling_periods: int = None, quantile90_rolling_periods: int = None, quantile10_rolling_periods: int = None, ewm_alpha: float = 0.5, ewm_var_alpha: float = None, additional_lag_periods: int = 7, abs_energy: bool = False, rolling_autocorr_periods: int = None, add_date_part: str = None, holiday: bool = False, holiday_country: str = 'US', polynomial_degree: int = None, window: int = None)

Generate more features from initial time series.

macd_periods ignored if mean_rolling is None.

Returns a dataframe of statistical features. Will need to be shifted by 1 or more to match Y for forecast.

autots.models.sklearn.rolling_x_regressor_regressor(df, mean_rolling_periods: int = 30, macd_periods: int = None, std_rolling_periods: int = 7, max_rolling_periods: int = None, min_rolling_periods: int = None, quantile90_rolling_periods: int = None, quantile10_rolling_periods: int = None, ewm_alpha: float = 0.5, ewm_var_alpha: float = None, additional_lag_periods: int = 7, abs_energy: bool = False, rolling_autocorr_periods: int = None, add_date_part: str = None, holiday: bool = False, holiday_country: str = 'US', polynomial_degree: int = None, window: int = None, future_regressor=None)

Adds in the future_regressor.

autots.models.statsmodels module

Statsmodels based forecasting models.

Statsmodels documentation can be a bit confusing. And it seems standard at first, but each model likes to do things differently. For example: exog, exog_oos, and exog_fc all sometimes mean the same thing

class autots.models.statsmodels.ARDL(name: str = 'ARDL', frequency: str = 'infer', prediction_interval: float = 0.9, lags: int = 2, trend: str = 'c', order: int = 0, regression_type: str = 'holiday', holiday_country: str = 'US', random_seed: int = 2020, verbose: int = 0, n_jobs: int = None, **kwargs)

Bases: autots.models.base.ModelObject

ARDL from Statsmodels.

Parameters
  • name (str) – String to identify class

  • frequency (str) – String alias of datetime index frequency or else ‘infer’

  • prediction_interval (float) – Confidence interval for probabilistic forecast

  • lags (int) – lags 1 to max

  • trend (str) – n/c/t/ct

  • order (int) – 0 to max

  • regression_type (str) – type of regression (None, ‘User’, or ‘Holiday’)

  • n_jobs (int) – passed to joblib for multiprocessing. Set to none for context manager.

fit(df, future_regressor=None)

Train algorithm given data supplied .

Parameters

df (pandas.DataFrame) – Datetime Indexed

get_new_params(method: str = 'random')

Return dict of new parameters for parameter tuning.

get_params()

Return dict of current parameters.

predict(forecast_length: int, future_regressor=None, just_point_forecast=False)

Generate forecast data immediately following dates of index supplied to .fit().

Parameters
  • forecast_length (int) – Number of periods of data to forecast ahead

  • regressor (numpy.Array) – additional regressor, not used

  • just_point_forecast (bool) – If True, return a pandas.DataFrame of just point forecasts

Returns

Either a PredictionObject of forecasts and metadata, or if just_point_forecast == True, a dataframe of point forecasts

class autots.models.statsmodels.ARIMA(name: str = 'ARIMA', frequency: str = 'infer', prediction_interval: float = 0.9, p: int = 0, d: int = 1, q: int = 0, regression_type: str = None, holiday_country: str = 'US', random_seed: int = 2020, verbose: int = 0, n_jobs: int = None, **kwargs)

Bases: autots.models.base.ModelObject

ARIMA from Statsmodels.

Parameters
  • name (str) – String to identify class

  • frequency (str) – String alias of datetime index frequency or else ‘infer’

  • prediction_interval (float) – Confidence interval for probabilistic forecast

  • p (int) – is the number of autoregressive steps,

  • d (int) – is the number of differences needed for stationarity

  • q (int) – is the number of lagged forecast errors in the prediction.

  • regression_type (str) – type of regression (None, ‘User’, or ‘Holiday’)

  • n_jobs (int) – passed to joblib for multiprocessing. Set to none for context manager.

fit(df, future_regressor=None)

Train algorithm given data supplied .

Parameters

df (pandas.DataFrame) – Datetime Indexed

get_new_params(method: str = 'random')

Return dict of new parameters for parameter tuning.

large p,d,q can be very slow (a p of 30 can take hours)

get_params()

Return dict of current parameters.

predict(forecast_length: int, future_regressor=None, just_point_forecast=False)

Generate forecast data immediately following dates of index supplied to .fit().

Parameters
  • forecast_length (int) – Number of periods of data to forecast ahead

  • regressor (numpy.Array) – additional regressor, not used

  • just_point_forecast (bool) – If True, return a pandas.DataFrame of just point forecasts

Returns

Either a PredictionObject of forecasts and metadata, or if just_point_forecast == True, a dataframe of point forecasts

class autots.models.statsmodels.DynamicFactor(name: str = 'DynamicFactor', frequency: str = 'infer', prediction_interval: float = 0.9, regression_type: str = None, holiday_country: str = 'US', random_seed: int = 2020, verbose: int = 0, k_factors: int = 1, factor_order: int = 0, **kwargs)

Bases: autots.models.base.ModelObject

DynamicFactor from Statsmodels

Parameters
  • name (str) – String to identify class

  • frequency (str) – String alias of datetime index frequency or else ‘infer’

  • prediction_interval (float) – Confidence interval for probabilistic forecast

  • regression_type (str) – type of regression (None, ‘User’, or ‘Holiday’)

fit(df, future_regressor=None)

Train algorithm given data supplied.

Parameters

df (pandas.DataFrame) – Datetime Indexed

get_new_params(method: str = 'random')

Return dict of new parameters for parameter tuning.

get_params()

Return dict of current parameters.

predict(forecast_length: int, future_regressor=None, just_point_forecast=False)

Generates forecast data immediately following dates of index supplied to .fit()

Parameters
  • forecast_length (int) – Number of periods of data to forecast ahead

  • regressor (numpy.Array) – additional regressor

  • just_point_forecast (bool) – If True, return a pandas.DataFrame of just point forecasts

Returns

Either a PredictionObject of forecasts and metadata, or

if just_point_forecast == True, a dataframe of point forecasts

maModel = DynamicFactor(df_train, freq = ‘MS’, k_factors = 2, factor_order=2).fit() maPred = maModel.predict()

class autots.models.statsmodels.ETS(name: str = 'ETS', frequency: str = 'infer', prediction_interval: float = 0.9, damped_trend: bool = False, trend: str = None, seasonal: str = None, seasonal_periods: int = None, holiday_country: str = 'US', random_seed: int = 2020, verbose: int = 0, n_jobs: int = None, **kwargs)

Bases: autots.models.base.ModelObject

Exponential Smoothing from Statsmodels

Parameters
  • name (str) – String to identify class

  • frequency (str) – String alias of datetime index frequency or else ‘infer’

  • prediction_interval (float) – Confidence interval for probabilistic forecast

  • damped_trend (bool) – passed through to statsmodel ETS (formerly just ‘damped’)

  • trend (str) – passed through to statsmodel ETS

  • seasonal (bool) – passed through to statsmodel ETS

  • seasonal_periods (int) – passed through to statsmodel ETS

fit(df, future_regressor=None)

Train algorithm given data supplied

Parameters

df (pandas.DataFrame) – Datetime Indexed

get_new_params(method: str = 'random')

Return dict of new parameters for parameter tuning.

get_params()

Return dict of current parameters.

predict(forecast_length: int, future_regressor=None, just_point_forecast=False)

Generates forecast data immediately following dates of index supplied to .fit()

Parameters
  • forecast_length (int) – Number of periods of data to forecast ahead

  • regressor (numpy.Array) – additional regressor, not used

  • just_point_forecast (bool) – If True, return a pandas.DataFrame of just point forecasts

Returns

Either a PredictionObject of forecasts and metadata, or if just_point_forecast == True, a dataframe of point forecasts

class autots.models.statsmodels.GLM(name: str = 'GLM', frequency: str = 'infer', prediction_interval: float = 0.9, holiday_country: str = 'US', random_seed: int = 2020, regression_type: str = None, family='Gaussian', constant: bool = False, verbose: int = 1, n_jobs: int = None, **kwargs)

Bases: autots.models.base.ModelObject

Simple linear regression from statsmodels

Parameters
  • name (str) – String to identify class

  • frequency (str) – String alias of datetime index frequency or else ‘infer’

  • prediction_interval (float) – Confidence interval for probabilistic forecast

  • regression_type (str) – type of regression (None, ‘User’)

fit(df, future_regressor=None)

Train algorithm given data supplied

Parameters

df (pandas.DataFrame) – Datetime Indexed

get_new_params(method: str = 'random')

Return dict of new parameters for parameter tuning.

get_params()

Return dict of current parameters.

predict(forecast_length: int, future_regressor=None, just_point_forecast=False)

Generates forecast data immediately following dates of index supplied to .fit()

Parameters
  • forecast_length (int) – Number of periods of data to forecast ahead

  • regressor (numpy.Array) – additional regressor, not used

  • just_point_forecast (bool) – If True, return a pandas.DataFrame of just point forecasts

Returns

Either a PredictionObject of forecasts and metadata, or if just_point_forecast == True, a dataframe of point forecasts

class autots.models.statsmodels.GLS(name: str = 'GLS', frequency: str = 'infer', prediction_interval: float = 0.9, holiday_country: str = 'US', random_seed: int = 2020, **kwargs)

Bases: autots.models.base.ModelObject

Simple linear regression from statsmodels

Parameters
  • name (str) – String to identify class

  • frequency (str) – String alias of datetime index frequency or else ‘infer’

  • prediction_interval (float) – Confidence interval for probabilistic forecast

fit(df, future_regressor=None)

Train algorithm given data supplied

Parameters

df (pandas.DataFrame) – Datetime Indexed

get_new_params(method: str = 'random')

Returns dict of new parameters for parameter tuning

get_params()

Return dict of current parameters

predict(forecast_length: int, future_regressor=None, just_point_forecast=False)

Generates forecast data immediately following dates of index supplied to .fit()

Parameters
  • forecast_length (int) – Number of periods of data to forecast ahead

  • regressor (numpy.Array) – additional regressor, not used

  • just_point_forecast (bool) – If True, return a pandas.DataFrame of just point forecasts

Returns

Either a PredictionObject of forecasts and metadata, or if just_point_forecast == True, a dataframe of point forecasts

class autots.models.statsmodels.Theta(name: str = 'Theta', frequency: str = 'infer', prediction_interval: float = 0.9, deseasonalize: bool = True, use_test: bool = True, difference: bool = False, period: int = None, theta: float = 2, use_mle: bool = False, method: str = 'auto', holiday_country: str = 'US', random_seed: int = 2020, verbose: int = 0, n_jobs: int = None, **kwargs)

Bases: autots.models.base.ModelObject

Theta Model from Statsmodels

Parameters
  • name (str) – String to identify class

  • frequency (str) – String alias of datetime index frequency or else ‘infer’

  • prediction_interval (float) – Confidence interval for probabilistic forecast

  • from Theta Model as per statsmodels (params) –

fit(df, future_regressor=None)

Train algorithm given data supplied

Parameters

df (pandas.DataFrame) – Datetime Indexed

get_new_params(method: str = 'random')

Return dict of new parameters for parameter tuning.

get_params()

Return dict of current parameters.

predict(forecast_length: int, future_regressor=None, just_point_forecast=False)

Generates forecast data immediately following dates of index supplied to .fit()

Parameters
  • forecast_length (int) – Number of periods of data to forecast ahead

  • regressor (numpy.Array) – additional regressor, not used

  • just_point_forecast (bool) – If True, return a pandas.DataFrame of just point forecasts

Returns

Either a PredictionObject of forecasts and metadata, or if just_point_forecast == True, a dataframe of point forecasts

class autots.models.statsmodels.UnobservedComponents(name: str = 'UnobservedComponents', frequency: str = 'infer', prediction_interval: float = 0.9, regression_type: str = None, holiday_country: str = 'US', random_seed: int = 2020, verbose: int = 0, n_jobs: int = 1, level: str = 'smooth trend', trend: bool = False, cycle: bool = False, damped_cycle: bool = False, irregular: bool = False, autoregressive: int = None, stochastic_cycle: bool = False, stochastic_trend: bool = False, stochastic_level: bool = False, maxiter: int = 100, cov_type: str = 'opg', method: str = 'lbfgs', model_kwargs: dict = None, **kwargs)

Bases: autots.models.base.ModelObject

UnobservedComponents from Statsmodels.

Parameters
  • name (str) – String to identify class

  • frequency (str) – String alias of datetime index frequency or else ‘infer’

  • prediction_interval (float) – Confidence interval for probabilistic forecast

  • model_kwargs (dict) – additional model params to pass through underlying statsmodel

  • regression_type (str) – type of regression (None, ‘User’, or ‘Holiday’)

fit(df, future_regressor=None)

Train algorithm given data supplied

Parameters

df (pandas.DataFrame) – Datetime Indexed

get_new_params(method: str = 'random')

Return dict of new parameters for parameter tuning.

get_params()

Return dict of current parameters.

predict(forecast_length: int, future_regressor=None, just_point_forecast: bool = False)

Generate forecast data immediately following dates of index supplied to .fit().

Parameters
  • forecast_length (int) – Number of periods of data to forecast ahead

  • regressor (numpy.Array) – additional regressor, not used

  • just_point_forecast (bool) – If True, return a pandas.DataFrame of just point forecasts

Returns

Either a PredictionObject of forecasts and metadata, or if just_point_forecast == True, a dataframe of point forecasts

class autots.models.statsmodels.VAR(name: str = 'VAR', frequency: str = 'infer', prediction_interval: float = 0.9, regression_type: str = None, holiday_country: str = 'US', random_seed: int = 2020, verbose: int = 0, maxlags: int = 15, ic: str = 'fpe', **kwargs)

Bases: autots.models.base.ModelObject

VAR from Statsmodels.

Parameters
  • name (str) – String to identify class

  • frequency (str) – String alias of datetime index frequency or else ‘infer’

  • prediction_interval (float) – Confidence interval for probabilistic forecast

  • regression_type (str) – type of regression (None, ‘User’, or ‘Holiday’)

fit(df, future_regressor=None)

Train algorithm given data supplied.

Parameters

df (pandas.DataFrame) – Datetime Indexed

get_new_params(method: str = 'random')

Return dict of new parameters for parameter tuning.

get_params()

Return dict of current parameters.

predict(forecast_length: int, future_regressor=None, just_point_forecast=False)

Generates forecast data immediately following dates of index supplied to .fit()

Parameters
  • forecast_length (int) – Number of periods of data to forecast ahead

  • regressor (numpy.Array) – additional regressor, not used

  • just_point_forecast (bool) – If True, return a pandas.DataFrame of just point forecasts

Returns

Either a PredictionObject of forecasts and metadata, or if just_point_forecast == True, a dataframe of point forecasts

class autots.models.statsmodels.VARMAX(name: str = 'VARMAX', frequency: str = 'infer', prediction_interval: float = 0.9, regression_type: str = None, holiday_country: str = 'US', random_seed: int = 2020, verbose: int = 0, order: tuple = (1, 0), trend: str = 'c', **kwargs)

Bases: autots.models.base.ModelObject

VARMAX from Statsmodels

Parameters
  • name (str) – String to identify class

  • frequency (str) – String alias of datetime index frequency or else ‘infer’

  • prediction_interval (float) – Confidence interval for probabilistic forecast

  • regression_type (str) – type of regression (None, ‘User’, or ‘Holiday’)

fit(df, future_regressor=None)

Train algorithm given data supplied

Parameters

df (pandas.DataFrame) – Datetime Indexed

get_new_params(method: str = 'random')

Return dict of new parameters for parameter tuning.

get_params()

Return dict of current parameters.

predict(forecast_length: int, future_regressor=None, just_point_forecast=False)

Generate forecast data immediately following dates of index supplied to .fit().

Parameters
  • forecast_length (int) – Number of periods of data to forecast ahead

  • regressor (numpy.Array) – additional regressor, not used

  • just_point_forecast (bool) – If True, return a pandas.DataFrame of just point forecasts

Returns

Either a PredictionObject of forecasts and metadata, or if just_point_forecast == True, a dataframe of point forecasts

class autots.models.statsmodels.VECM(name: str = 'VECM', frequency: str = 'infer', prediction_interval: float = 0.9, regression_type: str = None, holiday_country: str = 'US', random_seed: int = 2020, verbose: int = 0, deterministic: str = 'nc', k_ar_diff: int = 1, **kwargs)

Bases: autots.models.base.ModelObject

VECM from Statsmodels

Parameters
  • name (str) – String to identify class

  • frequency (str) – String alias of datetime index frequency or else ‘infer’

  • prediction_interval (float) – Confidence interval for probabilistic forecast

  • regression_type (str) – type of regression (None, ‘User’, or ‘Holiday’)

fit(df, future_regressor=None)

Train algorithm given data supplied.

Parameters

df (pandas.DataFrame) – Datetime Indexed

get_new_params(method: str = 'random')

Return dict of new parameters for parameter tuning.

get_params()

Return dict of current parameters.

predict(forecast_length: int, future_regressor=None, just_point_forecast=False)

Generates forecast data immediately following dates of index supplied to .fit()

Parameters
  • forecast_length (int) – Number of periods of data to forecast ahead

  • regressor (numpy.Array) – additional regressor, not used

  • just_point_forecast (bool) – If True, return a pandas.DataFrame of just point forecasts

Returns

Either a PredictionObject of forecasts and metadata, or if just_point_forecast == True, a dataframe of point forecasts

autots.models.statsmodels.arima_seek_the_oracle(current_series, args, series)
autots.models.statsmodels.glm_forecast_by_column(current_series, X, Xf, args)

Run one series of GLM and return prediction.

autots.models.tfp module

class autots.models.tfp.TFPRegression(name: str = 'TFPRegression', frequency: str = 'infer', prediction_interval: float = 0.9, holiday_country: str = 'US', random_seed: int = 2020, verbose: int = 1, kernel_initializer: str = 'lecun_uniform', optimizer: str = 'adam', loss: str = 'negloglike', epochs: int = 50, batch_size: int = 32, dist: str = 'normal', regression_type: str = None)

Bases: autots.models.base.ModelObject

Tensorflow Probability regression.

Parameters
  • name (str) – String to identify class

  • frequency (str) – String alias of datetime index frequency or else ‘infer’

  • prediction_interval (float) – Confidence interval for probabilistic forecast

  • regression_type (str) – type of regression (None, ‘User’)

fit(df, future_regressor=[])

Train algorithm given data supplied

Parameters

df (pandas.DataFrame) – Datetime Indexed

get_new_params(method: str = 'random')

Return dict of new parameters for parameter tuning.

get_params()

Return dict of current parameters.

predict(forecast_length: int, future_regressor=[], just_point_forecast=False)

Generates forecast data immediately following dates of index supplied to .fit()

Parameters
  • forecast_length (int) – Number of periods of data to forecast ahead

  • regressor (numpy.Array) – additional regressor, not used

  • just_point_forecast (bool) – If True, return a pandas.DataFrame of just point forecasts

Returns

Either a PredictionObject of forecasts and metadata, or if just_point_forecast == True, a dataframe of point forecasts

class autots.models.tfp.TFPRegressor(kernel_initializer: str = 'lecun_uniform', optimizer: str = 'adam', loss: str = 'negloglike', epochs: int = 50, batch_size: int = 32, dist: str = 'normal', verbose: int = 1, random_seed: int = 2020)

Bases: object

Wrapper for Tensorflow Keras based RNN.

Parameters
  • rnn_type (str) – Keras cell type ‘GRU’ or default ‘LSTM’

  • kernel_initializer (str) – passed to first keras LSTM or GRU layer

  • hidden_layer_sizes (tuple) – of len 1 or 3 passed to first keras LSTM or GRU layers

  • optimizer (str) – Passed to keras model.compile

  • loss (str) – Passed to keras model.compile

  • epochs (int) – Passed to keras model.fit

  • batch_size (int) – Passed to keras model.fit

  • verbose (int) – 0, 1 or 2. Passed to keras model.fit

  • random_seed (int) – passed to tf.random.set_seed()

fit(X, Y)

Train the model on dataframes of X and Y.

predict(X, conf_int: float = None)

Predict on dataframe of X.

class autots.models.tfp.TensorflowSTS(name: str = 'TensorflowSTS', frequency: str = 'infer', prediction_interval: float = 0.9, regression_type: str = None, holiday_country: str = 'US', random_seed: int = 2020, verbose: int = 0, trend: str = 'local', seasonal_periods: int = None, ar_order: int = None, fit_method: str = 'hmc', num_steps: int = 200)

Bases: autots.models.base.ModelObject

STS from TensorflowProbability.

Parameters
  • name (str) – String to identify class

  • frequency (str) – String alias of datetime index frequency or else ‘infer’

  • prediction_interval (float) – Confidence interval for probabilistic forecast

  • regression_type (str) – type of regression (None, ‘User’, or ‘Holiday’)

fit(df, future_regressor=[])

Train algorithm given data supplied.

Parameters

df (pandas.DataFrame) – Datetime Indexed

get_new_params(method: str = 'random')

Return dict of new parameters for parameter tuning.

get_params()

Return dict of current parameters.

predict(forecast_length: int, future_regressor=[], just_point_forecast=False)

Generates forecast data immediately following dates of index supplied to .fit()

Parameters
  • forecast_length (int) – Number of periods of data to forecast ahead

  • regressor (numpy.Array) – additional regressor, not used

  • just_point_forecast (bool) – If True, return a pandas.DataFrame of just point forecasts

Returns

Either a PredictionObject of forecasts and metadata, or if just_point_forecast == True, a dataframe of point forecasts

Module contents

Model Models