Package: autots
AutoTSAutoTS is a time series package for Python designed for rapidly deploying high-accuracy forecasts at scale.In 2023, AutoTS has won in the M6 forecasting competition, delivering the highest performance investment decisions across 12 months of stock market forecasting.There are dozens of forecasting models usable in thesklearnstyle of.fit()and.predict().
These includes naive, statistical, machine learning, and deep learning models.
Additionally, there are over 30 time series specific transforms usable in thesklearnstyle of.fit(),.transform()and.inverse_transform().
All of these function directly on Pandas Dataframes, without the need for conversion to proprietary objects.All models support forecasting multivariate (multiple time series) outputs and also support probabilistic (upper/lower bound) forecasts.
Most models can readily scale to tens and even hundreds of thousands of input series.
Many models also support passing in user-defined exogenous regressors.These models are all designed for integration in an AutoML feature search which automatically finds the best models, preprocessing, and ensembling for a given dataset through genetic algorithms.Horizontal and mosaic style ensembles are the flagship ensembling types, allowing each series to receive the most accurate possible models while still maintaining scalability.A combination of metrics and cross-validation options, the ability to apply subsets and weighting, regressor generation tools, simulation forecasting mode, event risk forecasting, live datasets, template import and export, plotting, and a collection of data shaping parameters round out the available feature set.Table of ContentsInstallationBasic UseTips for Speed and Large DataExtended TutorialGitHuborDocsProduction ExampleInstallationpip install autotsThis includes dependencies for basic models, butadditonal packagesare required for some models and methods.Be advised there are several other projects that have chosen similar names, so make sure you are on the right AutoTS code, papers, and documentation.Basic UseInput data for AutoTS is expected to come in either alongor awideformat:Thewideformat is apandas.DataFramewith apandas.DatetimeIndexand each column a distinct series.Thelongformat has three columns:Date (ideally already in pandas-recognizeddatetimeformat)Series ID. For a single time series, series_id can be= None.ValueForlongdata, the column name for each of these is passed to.fit()asdate_col,id_col, andvalue_col. No parameters are needed forwidedata.Lower-level functions are only designed forwidestyle data.# also load: _hourly, _monthly, _weekly, _yearly, or _live_dailyfromautotsimportAutoTS,load_daily# sample datasets can be used in either of the long or wide import shapeslong=Falsedf=load_daily(long=long)model=AutoTS(forecast_length=21,frequency='infer',prediction_interval=0.9,ensemble='auto',model_list="fast",# "superfast", "default", "fast_parallel"transformer_list="fast",# "superfast",drop_most_recent=1,max_generations=4,num_validations=2,validation_method="backwards")model=model.fit(df,date_col='datetime'iflongelseNone,value_col='value'iflongelseNone,id_col='series_id'iflongelseNone,)prediction=model.predict()# plot a sampleprediction.plot(model.df_wide_numeric,series=model.df_wide_numeric.columns[0],start_date="2019-01-01")# Print the details of the best modelprint(model)# point forecasts dataframeforecasts_df=prediction.forecast# upper and lower forecastsforecasts_up,forecasts_low=prediction.upper_forecast,prediction.lower_forecast# accuracy of all tried model resultsmodel_results=model.results()# and aggregated from cross validationvalidation_results=model.results("validation")The lower-level API, in particular the large section of time series transformers in the scikit-learn style, can also be utilized independently from the AutoML framework.Check outextended_tutorial.mdfor a more detailed guide to features.Also take a look at theproduction_example.pyTips for Speed and Large Data:Use appropriate model lists, especially the predefined lists:superfast(simple naive models) andfast(more complex but still faster models, optimized for many series)fast_parallel(a combination offastandparallel) orparallel, given many CPU cores are availablen_jobsusually gets pretty close with='auto'but adjust as necessary for the environmentsee a dict of predefined lists (some defined for internal use) withfrom autots.models.model_list import model_listsUse thesubsetparameter when there are many similar series,subset=100will often generalize well for tens of thousands of similar series.if usingsubset, passingweightsfor series will weight subset selection towards higher priority series.if limited by RAM, it can be distributed by running multiple instances of AutoTS on different batches of data, having first imported a template pretrained as a starting point for all.Setmodel_interrupt=Truewhich passes over the current model when aKeyboardInterruptiecrtl+cis pressed (although if the interrupt falls between generations it will stop the entire training).Use theresult_filemethod of.fit()which will save progress after each generation - helpful to save progress if a long training is being done. Useimport_resultsto recover.While Transformations are pretty fast, settingtransformer_max_depthto a lower number (say, 2) will increase speed. Also utilizetransformer_list== 'fast' or 'superfast'.Check outthis exampleof using AutoTS with pandas UDF.Ensembles are obviously slower to predict because they run many models, 'distance' models 2x slower, and 'simple' models 3x-5x slower.ensemble='horizontal-max'withmodel_list='no_shared_fast'can scale relatively well given many cpu cores because each model is only run on the series it is needed for.Reducingnum_validationsandmodels_to_validatewill decrease runtime but may lead to poorer model selections.For datasets with many records, upsampling (for example, from daily to monthly frequency forecasts) can reduce training time if appropriate.this can be done by adjustingfrequencyandaggfuncbut is probably best done before passing data into AutoTS.It will be faster if NaN's are already filled. If a search for optimal NaN fill method is not required, then fill any NaN with a satisfactory method before passing to class.Setruntime_weightinginmetric_weightingto a higher value. This will guide the search towards faster models, although it may come at the expense of accuracy.How to Contribute:Give feedback on where you find the documentation confusingUse AutoTS and...Report errors and request features by adding Issues on GitHubPosting the top model templates for your data (to help improve the starting templates)Feel free to recommend different search grid parameters for your favorite modelsAnd, of course, contributing to the codebase directly on GitHub.Also known as Project CATS (Catlin's Automated Time Series) hence the logo.