Forecaster
AutoTS
Auto-ensemble from autots library by winedarksea.
Quickstart
python
from sktime.forecasting.autots import AutoTS
estimator = AutoTS(model_name: str='', model_list: list='superfast', frequency: str='infer', prediction_interval: float=0.9, max_generations: int=10, no_negatives: bool=False, constraint: float=None, ensemble: str='auto', initial_template: str='General+Random', random_seed: int=2022, holiday_country: str='US', subset: int=None, aggfunc: str='first', na_tolerance: float=1, metric_weighting: dict=None, drop_most_recent: int=0, drop_data_older_than_periods: int=100000, transformer_list: dict='auto', transformer_max_depth: int=6, models_mode: str='random', num_validations: int='auto', models_to_validate: float=0.15, max_per_model_class: int=None, validation_method: str='backwards', min_allowed_train_percent: float=0.5, remove_leading_zeroes: bool=False, prefill_na: str=None, introduce_na: bool=None, preclean: dict=None, model_interrupt: bool=True, generation_timeout: int=None, current_model_file: str=None, verbose: int=1, n_jobs: int=-2)Parameters(35)
- model_namestr, optional (default=”fast”)
- The name of the model. NOTE: Overwrites the model_list parameter. For using only one model over a default model_list.
- model_liststr
- The list of models to use. str alias or list of names of model objects to use now can be a dictionary of {“model”: prob} but only affects starting random templates. Genetic algorithm takes from there.
- frequencystr
- ‘infer’ or a specific pandas datetime offset. Can be used to force rollup of data (ie daily input, but frequency ‘M’ will rollup to monthly).
- prediction_interval: float
- 0-1, uncertainty range for upper and lower forecasts. Adjust range, but rarely matches actual containment.
- max_generations: int
- The maximum number of generations for the genetic algorithm. number of genetic algorithms generations to run. More runs = longer runtime, generally better accuracy. It’s called max because someday there will be an auto early stopping option, but for now this is just the exact number of generations to run.
- no_negatives (bool):
- Whether negative values are allowed in the forecast. if True, all negative predictions are rounded up to 0.
- constraint (float):
The constraint on the forecast values. when not None, use this float value * data st dev above max or below min for constraining forecast values. now also instead accepts a dictionary containing the following key/values: constraint_method (str): one of
stdev_min - threshold is min and max of historic data +/- constraint
- st dev of data stdev - threshold is the mean of historic data +/-
constraint
- constraint_regularization (float): 0 to 1
- where 0 means no constraint, 1 is hard threshold cutoff, and in between is penalty term upper_constraint (float): or array, depending on method, None if unused lower_constraint (float): or array, depending on method, None if unused bounds (bool): if True, apply to upper/lower forecast, otherwise False applies only to forecast
- ensemble: str
- The ensemble method to use. None or list or comma-separated string containing: ‘auto’, ‘simple’, ‘distance’, ‘horizontal’, ‘horizontal-min’, ‘horizontal-max’, “mosaic”, “subsample”
- initial_template (str):
- The initial template to use for the forecast. ‘Random’ - randomly generates starting template, ‘General’ uses template included in package, ‘General+Random’ - both of previous. Also can be overridden with import_template()
- random_seed (int):
- The random seed for reproducibility. Random seed allows (slightly) more consistent results.
- holiday_country (str):
- The country for holiday effects. Can be passed through to Holidays package for some models.
- subset (int):
- Maximum number of series to evaluate at once. Useful to speed evaluation when many series are input. takes a new subset of columns on each validation, unless mosaic ensembling, in which case columns are the same in each validation
- aggfunc (str):
- The aggregation function to use. If data is to be rolled up to a higher frequency (daily -> monthly) or duplicate timestamps are included. Default ‘first’ removes duplicates, for rollup try ‘mean’ or np.sum. Beware numeric aggregations like ‘mean’ will not work with non-numeric inputs. Numeric aggregations like ‘sum’ will also change nan values to 0
- na_tolerance (float):
- The tolerance for missing values. 0 to 1. Series are dropped if they have more than this percent NaN. 0.95 here would allow series containing up to 95% NaN values.
- metric_weighting (dict):
- The weights for different forecast evaluation metrics. Weights to assign to metrics, effecting how the ranking score is generated.
- drop_most_recent (int):
- Option to drop n most recent data points. Useful, say, for monthly sales data where the current (unfinished) month is included. occurs after any aggregation is applied, so will be whatever is specified by frequency, will drop n frequencies
- drop_data_older_than_periods (int):
- The threshold for dropping old data points. Will take only the n most recent timestamps.
- transformer_list (dict):
- List of transformers to use, or dict of transformer:probability. Note this does not apply to initial templates. can accept string aliases: “all”, “fast”, “superfast”, ‘scalable’ (scalable is a subset of fast that should have fewer memory issues at scale)
- transformer_max_depth (int):
- maximum number of sequential transformers to generate for new Random Transformers. Fewer will be faster.
- models_mode (str):
- The mode for selecting models. option to adjust parameter options for newly generated models. Only sporadically utilized. Currently includes: ‘default’/’random’, ‘deep’ (searches more params, likely slower), and ‘regressor’ (forces ‘User’ regressor mode in regressor capable models), ‘gradient_boosting’, ‘neuralnets’ (~Regression class models only)
- num_validations (int):
- The number of validations to perform. 0 for just train/test on best split. Possible confusion: num_validations is the number of validations to perform after the first eval segment, so totally eval/validations will be this + 1. Also “auto” and “max” aliases available. Max maxes out at 50.
- models_to_validate (float):
- The fraction of models to validate. Top n models to pass through to cross validation. Or float in 0 to 1 as % of tried. 0.99 is forced to 100% validation. 1 evaluates just 1 model. If horizontal or mosaic ensemble, then additional min per_series models above the number here are added to validation.
- max_per_model_class (int):
- The maximum number of models per class. of the models_to_validate what is the maximum to pass from any one model class/family.
- validation_method (str):
- The method for validation. ‘even’, ‘backwards’, or ‘seasonal n’ where n is an integer of seasonal ‘backwards’ is better for recency and for shorter training sets ‘even’ splits the data into equally-sized slices best for more consistent data, a poetic but less effective strategy than others here ‘seasonal’ most similar indexes ‘seasonal n’ for example ‘seasonal 364’ would test all data on each previous year of the forecast_length that would immediately follow the training data. ‘similarity’ automatically finds the data sections most similar to the most recent data that will be used for prediction ‘custom’ - if used,.fit() needs validation_indexes passed - a list of pd.DatetimeIndex’s, tail of each is used as test
- min_allowed_train_percent (float):
The minimum percentage of data allowed for training. percent of forecast length to allow as min training, else raises error. 0.5 with a forecast length of 10 would mean 5 training points are mandated, for a total of 15 points. Useful in (unrecommended) cases where forecast_ length > training length.
- remove_leading_zeroes (bool):
- Whether to remove leading zeroes from the data. replace leading zeroes with NaN. Useful in data where initial zeroes mean data collection hasn’t started yet.
- prefill_na (str):
- The method for prefilling missing values. The value to input to fill all NaNs with. Leaving as None and allowing model interpolation is recommended. None, 0, ‘mean’, or ‘median’. 0 may be useful in for examples sales cases where all NaN can be assumed equal to zero.
- introduce_na (bool):
- Whether to introduce missing values to the data. whether to force last values in one training validation to be NaN. Helps make more robust models. defaults to None, which introduces NaN in last rows of validations if any NaN in tail of training data. Will not introduce NaN to all series if subset is used. if True, will also randomly change 20% of all rows to NaN in the validations
- preclean (dict):
- The parameters for data pre-cleaning. if not None, a dictionary of Transformer params to be applied to input data {“fillna”: “median”, “transformations”: {}, “transformation_params”: {}} This will change data used in model inputs for fit and predict, and for accuracy evaluation in cross validation!
- model_interrupt (bool):
- Whether the model can be interrupted. If False, KeyboardInterrupts quit entire program. if True, KeyboardInterrupts attempt to only quit current model. if True, recommend use in conjunction with verbose > 0 and result_file in the event of accidental complete termination. if “end_generation”, as True and also ends entire generation of run. Note skipped models will not be tried again.
- generation_timeout (int):
- The timeout for each generation. if not None, this is the number of minutes from start at which the generational search ends, then proceeding to validation This is only checked after the end of each generation, so only offers an ‘approximate’ timeout for searching. It is an overall cap for total generation search time, not per generation.
- current_model_file (str):
- The file containing the current model. file path to write to disk of current model params (for debugging if computer crashes)..json is appended
- verbose (int):
- The verbosity level. setting to 0 or lower should reduce most output. Higher numbers give more output.
- n_jobs (int):
- The number of jobs to run in parallel. Number of cores available to pass to parallel processing. A joblib context manager can be used instead (pass None in this case). Also ‘auto’.