AutoTS


NameAutoTS JSON
Version 0.5.4 PyPI version JSON
download
home_pagehttps://github.com/winedarksea/AutoTS
SummaryAutomated Time Series Forecasting
upload_time2023-02-02 00:45:19
maintainer
docs_urlNone
authorColin Catlin
requires_python>=3.6
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # AutoTS

<img src="/img/autots_1280.png" width="400" height="184" title="AutoTS Logo">

AutoTS is a time series package for Python designed for rapidly deploying high-accuracy forecasts at scale. 

There are dozens of forecasting models usable in the `sklearn` style 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 the `sklearn` style 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 Contents
* [Installation](https://github.com/winedarksea/AutoTS#installation)
* [Basic Use](https://github.com/winedarksea/AutoTS#basic-use)
* [Tips for Speed and Large Data](https://github.com/winedarksea/AutoTS#tips-for-speed-and-large-data)
* Extended Tutorial [GitHub](https://github.com/winedarksea/AutoTS/blob/master/extended_tutorial.md) or [Docs](https://winedarksea.github.io/AutoTS/build/html/source/tutorial.html)
* [Production Example](https://github.com/winedarksea/AutoTS/blob/master/production_example.py)

## Installation
```
pip install autots
```
This includes dependencies for basic models, but [additonal packages](https://github.com/winedarksea/AutoTS/blob/master/extended_tutorial.md#installation-and-dependency-versioning) are required for some models and methods.

## Basic Use

Input data for AutoTS is expected to come in either a *long* or a *wide* format:

- The *wide* format is a `pandas.DataFrame` with a `pandas.DatetimeIndex` and each column a distinct series. 
- The *long* format has three columns: 
  - Date (ideally already in pandas-recognized `datetime` format)
  - Series ID. For a single time series, series_id can be `= None`.
  - Value
- For *long* data, the column name for each of these is passed to `.fit()` as `date_col`, `id_col`, and `value_col`. No parameters are needed for *wide* data.

Lower-level functions are only designed for `wide` style data.

```python
# also load: _hourly, _monthly, _weekly, _yearly, or _live_daily
from autots import AutoTS, load_daily

# sample datasets can be used in either of the long or wide import shapes
long = False
df = load_daily(long=long)

model = AutoTS(
    forecast_length=21,
    frequency='infer',
    prediction_interval=0.9,
    ensemble=None,
    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' if long else None,
    value_col='value' if long else None,
    id_col='series_id' if long else None,
)

prediction = model.predict()
# plot a sample
prediction.plot(model.df_wide_numeric,
                series=model.df_wide_numeric.columns[0],
                start_date="2019-01-01")
# Print the details of the best model
print(model)

# point forecasts dataframe
forecasts_df = prediction.forecast
# upper and lower forecasts
forecasts_up, forecasts_low = prediction.upper_forecast, prediction.lower_forecast

# accuracy of all tried model results
model_results = model.results()
# and aggregated from cross validation
validation_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 out [extended_tutorial.md](https://winedarksea.github.io/AutoTS/build/html/source/tutorial.html) for a more detailed guide to features.

Also take a look at the [production_example.py](https://github.com/winedarksea/AutoTS/blob/master/production_example.py)

## Tips for Speed and Large Data:
* Use appropriate model lists, especially the predefined lists:
	* `superfast` (simple naive models) and `fast` (more complex but still faster models, optimized for many series)
	* `fast_parallel` (a combination of `fast` and `parallel`) or `parallel`, given many CPU cores are available
		* `n_jobs` usually gets pretty close with `='auto'` but adjust as necessary for the environment
	* see a dict of predefined lists (some defined for internal use) with `from autots.models.model_list import model_lists`
* Use the `subset` parameter when there are many similar series, `subset=100` will often generalize well for tens of thousands of similar series.
	* if using `subset`, passing `weights` for 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.
* Set `model_interrupt=True` which passes over the current model when a `KeyboardInterrupt` ie `crtl+c` is pressed (although if the interrupt falls between generations it will stop the entire training).
* Use the `result_file` method of `.fit()` which will save progress after each generation - helpful to save progress if a long training is being done. Use `import_results` to recover.
* While Transformations are pretty fast, setting `transformer_max_depth` to a lower number (say, 2) will increase speed. Also utilize `transformer_list` == 'fast' or 'superfast'.
* Check out [this example](https://github.com/winedarksea/AutoTS/discussions/76) of 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'` with `model_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.
* Reducing `num_validations` and `models_to_validate` will 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 adjusting `frequency` and `aggfunc` but 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.
* Set `runtime_weighting` in `metric_weighting` to 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 confusing
* Use AutoTS and...
	* Report errors and request features by adding Issues on GitHub
	* Posting the top model templates for your data (to help improve the starting templates)
	* Feel free to recommend different search grid parameters for your favorite models
* And, of course, contributing to the codebase directly on GitHub.


*Also known as Project CATS (Catlin's Automated Time Series) hence the logo.*

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/winedarksea/AutoTS",
    "name": "AutoTS",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "",
    "author": "Colin Catlin",
    "author_email": "colin.catlin@syllepsis.live",
    "download_url": "https://files.pythonhosted.org/packages/e6/de/57865e8e8a90b3d0c40ee29b98cda896aab8fcd57bcc747b4b3e36a4a48a/AutoTS-0.5.4.tar.gz",
    "platform": null,
    "description": "# AutoTS\r\n\r\n<img src=\"/img/autots_1280.png\" width=\"400\" height=\"184\" title=\"AutoTS Logo\">\r\n\r\nAutoTS is a time series package for Python designed for rapidly deploying high-accuracy forecasts at scale. \r\n\r\nThere are dozens of forecasting models usable in the `sklearn` style of `.fit()` and `.predict()`. \r\nThese includes naive, statistical, machine learning, and deep learning models. \r\nAdditionally, there are over 30 time series specific transforms usable in the `sklearn` style of `.fit()`, `.transform()` and `.inverse_transform()`. \r\nAll of these function directly on Pandas Dataframes, without the need for conversion to proprietary objects. \r\n\r\nAll models support forecasting multivariate (multiple time series) outputs and also support probabilistic (upper/lower bound) forecasts. \r\nMost models can readily scale to tens and even hundreds of thousands of input series. \r\nMany models also support passing in user-defined exogenous regressors. \r\n\r\nThese 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. \r\n\r\nHorizontal and mosaic style ensembles are the flagship ensembling types, allowing each series to receive the most accurate possible models while still maintaining scalability.\r\n\r\nA 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. \r\n\r\n## Table of Contents\r\n* [Installation](https://github.com/winedarksea/AutoTS#installation)\r\n* [Basic Use](https://github.com/winedarksea/AutoTS#basic-use)\r\n* [Tips for Speed and Large Data](https://github.com/winedarksea/AutoTS#tips-for-speed-and-large-data)\r\n* Extended Tutorial [GitHub](https://github.com/winedarksea/AutoTS/blob/master/extended_tutorial.md) or [Docs](https://winedarksea.github.io/AutoTS/build/html/source/tutorial.html)\r\n* [Production Example](https://github.com/winedarksea/AutoTS/blob/master/production_example.py)\r\n\r\n## Installation\r\n```\r\npip install autots\r\n```\r\nThis includes dependencies for basic models, but [additonal packages](https://github.com/winedarksea/AutoTS/blob/master/extended_tutorial.md#installation-and-dependency-versioning) are required for some models and methods.\r\n\r\n## Basic Use\r\n\r\nInput data for AutoTS is expected to come in either a *long* or a *wide* format:\r\n\r\n- The *wide* format is a `pandas.DataFrame` with a `pandas.DatetimeIndex` and each column a distinct series. \r\n- The *long* format has three columns: \r\n  - Date (ideally already in pandas-recognized `datetime` format)\r\n  - Series ID. For a single time series, series_id can be `= None`.\r\n  - Value\r\n- For *long* data, the column name for each of these is passed to `.fit()` as `date_col`, `id_col`, and `value_col`. No parameters are needed for *wide* data.\r\n\r\nLower-level functions are only designed for `wide` style data.\r\n\r\n```python\r\n# also load: _hourly, _monthly, _weekly, _yearly, or _live_daily\r\nfrom autots import AutoTS, load_daily\r\n\r\n# sample datasets can be used in either of the long or wide import shapes\r\nlong = False\r\ndf = load_daily(long=long)\r\n\r\nmodel = AutoTS(\r\n    forecast_length=21,\r\n    frequency='infer',\r\n    prediction_interval=0.9,\r\n    ensemble=None,\r\n    model_list=\"fast\",  # \"superfast\", \"default\", \"fast_parallel\"\r\n    transformer_list=\"fast\",  # \"superfast\",\r\n    drop_most_recent=1,\r\n    max_generations=4,\r\n    num_validations=2,\r\n    validation_method=\"backwards\"\r\n)\r\nmodel = model.fit(\r\n    df,\r\n    date_col='datetime' if long else None,\r\n    value_col='value' if long else None,\r\n    id_col='series_id' if long else None,\r\n)\r\n\r\nprediction = model.predict()\r\n# plot a sample\r\nprediction.plot(model.df_wide_numeric,\r\n                series=model.df_wide_numeric.columns[0],\r\n                start_date=\"2019-01-01\")\r\n# Print the details of the best model\r\nprint(model)\r\n\r\n# point forecasts dataframe\r\nforecasts_df = prediction.forecast\r\n# upper and lower forecasts\r\nforecasts_up, forecasts_low = prediction.upper_forecast, prediction.lower_forecast\r\n\r\n# accuracy of all tried model results\r\nmodel_results = model.results()\r\n# and aggregated from cross validation\r\nvalidation_results = model.results(\"validation\")\r\n```\r\n\r\nThe 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.\r\n\r\nCheck out [extended_tutorial.md](https://winedarksea.github.io/AutoTS/build/html/source/tutorial.html) for a more detailed guide to features.\r\n\r\nAlso take a look at the [production_example.py](https://github.com/winedarksea/AutoTS/blob/master/production_example.py)\r\n\r\n## Tips for Speed and Large Data:\r\n* Use appropriate model lists, especially the predefined lists:\r\n\t* `superfast` (simple naive models) and `fast` (more complex but still faster models, optimized for many series)\r\n\t* `fast_parallel` (a combination of `fast` and `parallel`) or `parallel`, given many CPU cores are available\r\n\t\t* `n_jobs` usually gets pretty close with `='auto'` but adjust as necessary for the environment\r\n\t* see a dict of predefined lists (some defined for internal use) with `from autots.models.model_list import model_lists`\r\n* Use the `subset` parameter when there are many similar series, `subset=100` will often generalize well for tens of thousands of similar series.\r\n\t* if using `subset`, passing `weights` for series will weight subset selection towards higher priority series.\r\n\t* 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.\r\n* Set `model_interrupt=True` which passes over the current model when a `KeyboardInterrupt` ie `crtl+c` is pressed (although if the interrupt falls between generations it will stop the entire training).\r\n* Use the `result_file` method of `.fit()` which will save progress after each generation - helpful to save progress if a long training is being done. Use `import_results` to recover.\r\n* While Transformations are pretty fast, setting `transformer_max_depth` to a lower number (say, 2) will increase speed. Also utilize `transformer_list` == 'fast' or 'superfast'.\r\n* Check out [this example](https://github.com/winedarksea/AutoTS/discussions/76) of using AutoTS with pandas UDF.\r\n* Ensembles are obviously slower to predict because they run many models, 'distance' models 2x slower, and 'simple' models 3x-5x slower.\r\n\t* `ensemble='horizontal-max'` with `model_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.\r\n* Reducing `num_validations` and `models_to_validate` will decrease runtime but may lead to poorer model selections.\r\n* For datasets with many records, upsampling (for example, from daily to monthly frequency forecasts) can reduce training time if appropriate.\r\n\t* this can be done by adjusting `frequency` and `aggfunc` but is probably best done before passing data into AutoTS.\r\n* 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.\r\n* Set `runtime_weighting` in `metric_weighting` to a higher value. This will guide the search towards faster models, although it may come at the expense of accuracy. \r\n\r\n## How to Contribute:\r\n* Give feedback on where you find the documentation confusing\r\n* Use AutoTS and...\r\n\t* Report errors and request features by adding Issues on GitHub\r\n\t* Posting the top model templates for your data (to help improve the starting templates)\r\n\t* Feel free to recommend different search grid parameters for your favorite models\r\n* And, of course, contributing to the codebase directly on GitHub.\r\n\r\n\r\n*Also known as Project CATS (Catlin's Automated Time Series) hence the logo.*\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Automated Time Series Forecasting",
    "version": "0.5.4",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "70d00bb25acba36cfa276535224673caca6503df05c39614b53dd2c889bd014e",
                "md5": "e0a8f8aaab3e30fa2898a3b3e9bd0efb",
                "sha256": "2ef8c773b8b9e96151bf1412eea82e5ca0d1c44cb37ff14920a59c21be9cf188"
            },
            "downloads": -1,
            "filename": "AutoTS-0.5.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e0a8f8aaab3e30fa2898a3b3e9bd0efb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 686406,
            "upload_time": "2023-02-02T00:45:18",
            "upload_time_iso_8601": "2023-02-02T00:45:18.024122Z",
            "url": "https://files.pythonhosted.org/packages/70/d0/0bb25acba36cfa276535224673caca6503df05c39614b53dd2c889bd014e/AutoTS-0.5.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e6de57865e8e8a90b3d0c40ee29b98cda896aab8fcd57bcc747b4b3e36a4a48a",
                "md5": "75c65c57f136b54e6bcf374f1723359f",
                "sha256": "e9a6d7d3717a2483626b3452b1ba1fd43cf19342427c47a62ba3d560d14fceee"
            },
            "downloads": -1,
            "filename": "AutoTS-0.5.4.tar.gz",
            "has_sig": false,
            "md5_digest": "75c65c57f136b54e6bcf374f1723359f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 662427,
            "upload_time": "2023-02-02T00:45:19",
            "upload_time_iso_8601": "2023-02-02T00:45:19.297640Z",
            "url": "https://files.pythonhosted.org/packages/e6/de/57865e8e8a90b3d0c40ee29b98cda896aab8fcd57bcc747b4b3e36a4a48a/AutoTS-0.5.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-02-02 00:45:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "winedarksea",
    "github_project": "AutoTS",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "autots"
}
        
Elapsed time: 0.04100s