autots 0.0.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Colin Catlin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,176 @@
1
+ Metadata-Version: 2.1
2
+ Name: AutoTS
3
+ Version: 0.0.2
4
+ Summary: Automated Time Series Forecasting
5
+ Home-page: https://github.com/winedarksea/AutoTS
6
+ Author: Colin Catlin
7
+ Author-email: colin.catlin@syllepsis.live
8
+ License: MIT
9
+ Platform: UNKNOWN
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Requires-Python: >=3.6
14
+ Description-Content-Type: text/markdown
15
+ Requires-Dist: numpy
16
+ Requires-Dist: pandas
17
+ Requires-Dist: statsmodels
18
+ Requires-Dist: scikit-learn
19
+ Requires-Dist: holidays
20
+ Provides-Extra: additional_models
21
+ Requires-Dist: fbprophet ; extra == 'additional_models'
22
+ Requires-Dist: fredapi ; extra == 'additional_models'
23
+
24
+ # AutoTS
25
+ Unstable prototype: version 0.0.2
26
+ ### Project CATS (Catlin Automated Time Series)
27
+ (or maybe eventually: Clustered Automated Time Series)
28
+ #### Model Selection for Multiple Time Series
29
+
30
+ Simple package for comparing and predicting with open-source time series implementations.
31
+ For other time series needs, check out the package list here: https://github.com/MaxBenChrist/awesome_time_series_in_python
32
+
33
+ `pip install autots`
34
+ #### Requirements:
35
+ Python >= 3.5 (typing) >= 3.6 (GluonTS)
36
+ pandas
37
+ sklearn >= 0.20.0 (ColumnTransformer)
38
+ statsmodels
39
+ holidays
40
+
41
+ `pip install autots['additional models']`
42
+ #### Requirements
43
+ fbprophet
44
+ fredapi (example datasets)
45
+
46
+ ## Basic Use
47
+ Input data is expected to come in a 'long' format with three columns: Date (ideally already in pd.DateTime format), Value, and Series ID. the column name for each of these is passed to .fit(). For a single time series, series_id can be = None.
48
+
49
+ ```
50
+ from autots.datasets import load_toy_daily
51
+ df_long = load_toy_daily()
52
+
53
+ from autots import AutoTS
54
+ model = AutoTS(forecast_length = 14, frequency = 'infer',
55
+ prediction_interval = 0.9, ensemble = True, weighted = False,
56
+ max_generations = 5, num_validations = 2, validation_method = 'even')
57
+ model = model.fit(df_long, date_col = 'date', value_col = 'value', id_col = 'series_id' )
58
+
59
+ # Print the name of the best mode
60
+ print(model.best_model['Model'].iloc[0])
61
+
62
+ prediction = model.predict()
63
+ # point forecasts dataframe
64
+ forecasts_df = prediction.forecast
65
+ # accuracy of all tried model results (not including cross validation)
66
+ model_results = model.main_results.model_results
67
+ ```
68
+
69
+ ## Underlying Process
70
+ AutoTS works in the following way at present:
71
+ * It begins by taking long data and converting it to a wide dataframe with DateTimeIndex
72
+ * An initial train/test split is generated where the test is the most recent data, of forecast_length
73
+ * A random template of models is generated and tested on the initial train/test
74
+ * Models consist of a pre-transformation step (fill na options, outlier removal options, etc), and algorithm (ie ETS) and model paramters (trend, damped, etc)
75
+ * The top models (selected by a combination of SMAPE, MAE, RMSE) are recombined with random mutations for n_generations
76
+ * A handful of the best models from this process go to cross validation, where they are re-assessed on new train/test splits.
77
+ * The best model in validation is selected as best_model and used in the .predict() method to generate forecasts.
78
+
79
+ ## Caveats and Advice
80
+
81
+ #### Short Training History
82
+ How much data is 'too little' depends on the seasonality and volatility of the data.
83
+ But less than half a year of daily data or less than two years of monthly data are both going to be tight.
84
+ Minimal training data most greatly impacts the ability to do proper cross validation. Set num_validations = 0 in such cases.
85
+ Since ensembles are based on the test dataset, it would also be wise to set ensemble = False if num_validations = 0.
86
+
87
+ #### Too much training data.
88
+ Too much data is already handled to some extent by 'context_slicer' in the transformations, which tests using less training data.
89
+ That said, large datasets will be slower and more memory intensive, for high frequency data (say hourly) it can often be advisable to roll that up to a higher level (daily, hourly, etc.).
90
+ Rollup can be accomplished by specifying the frequency = your rollup frequency, and then setting the agg_func = 'sum' or 'mean' or other appropriate statistic.
91
+
92
+ #### Lots of NaN in data
93
+ Various NaN filling techniques are tested in the transformation. Rolling up data to a lower frequency may also help deal with NaNs.
94
+
95
+ #### More than one preord regressor
96
+ 'Preord' regressor stands for 'Preordained' regressor, to make it clear this is data that will be know with high certainy about the future.
97
+ Such data about the future is rare, one example might be number of stores that will be (planned to be) open each given day in the future when forecast sales.
98
+ Since many algorithms do not handle more than one regressor, only one is handled here. If you would like to use more than one,
99
+ manually select the best variable or use dimensionality reduction to reduce the features to one dimension.
100
+ However, the model can handle quite a lot of parallel time series. Additional regressors can be passed through as additional time series to forecast.
101
+ The regression models here can utilize the information they provide to help improve forecast quality.
102
+ To prevent forecast accuracy for considering these additional series too heavily, input series weights that lower or remove their forecast accuracy from consideration.
103
+
104
+ #### Categorical Data
105
+ Categorical data is handled, but it is handled poorly. For example, optimization metrics do not currently include any categorical accuracy metrics.
106
+ For categorical data that has a meaningful order (ie 'low', 'medium', 'high') it is best for the user to encode that data before passing it in,
107
+ thus properly capturing the relative sequence (ie 'low' = 1, 'medium' = 2, 'high' = 3).
108
+
109
+ #### Custom Metrics
110
+ Implementing new metrics is rather difficult. However the internal 'Score' that compares models can easily be adjusted by passing through custom metric weights.
111
+ Higher weighting increases the importance of that metric.
112
+ `metric_weighting = {'smape_weighting' : 9, 'mae_weighting' : 1, 'rmse_weighting' : 5, 'containment_weighting' : 1, 'runtime_weighting' : 0.5}`
113
+ sMAPE is generally the most versatile across multiple series, but doesn't handle forecasts with lots of zeroes well.
114
+ Contaiment measures the percent of test data that falls between the upper and lower forecasts.
115
+
116
+ ## To-Do
117
+ * Smaller
118
+ * Recombine best two of each model, if two or more present
119
+ * Duplicates still seem to be occurring in the genetic template runs
120
+ * Inf appearing in MAE and RMSE (possibly all NaN in test)
121
+ * Na Tolerance for test in simple_train_test_split
122
+ * Relative/Absolute Imports and reduce package reloading
123
+ * User regressor to sklearn model regression_type
124
+ * Import/export template
125
+ * ARIMA + Detrend fails
126
+ * Things needing testing:
127
+ * Confirm per_series weighting works properly
128
+ * Passing in Start Dates - (Test)
129
+ * Different frequencies
130
+ * Various verbose inputs
131
+ * Test holidays on non-daily data
132
+ * Handle categorical forecasts where forecast leaves known values
133
+ * Speed improvements, Profiling, Parallelization, and Distributed options for general greater speed
134
+ * Generate list of functional frequences, and improve usability on rarer frequenices
135
+ * Warning/handling if lots of NaN in most recent (test) part of data
136
+ * Figures: Add option to output figures of train/test + forecast, other performance figures
137
+ * Input and Output saved templates as .csv and .json
138
+ * 'Check Package' to check if optional model packages are installed
139
+ * Pre-clustering on many time series
140
+ * If all input are Int, convert floats back to int
141
+ * Trim whitespace on string inputs
142
+ * Hierachial correction (bottom-up to start with)
143
+ * Improved verbosity controls and options. Replace most 'print' with logging.
144
+ * Export as simpler code (as TPOT)
145
+ * AIC metric, other accuracy metrics
146
+ * Analyze and return inaccuracy patterns (most inaccurate periods out, days of week, most inaccurate series)
147
+ * Used saved results to resume a search partway through
148
+ * Generally improved probabilistic forecasting
149
+ * Option to drop series which haven't had a value in last N days
150
+ * Option to change which metric is being used for model selections
151
+ * Use quantile of training data to provide upper/lower forecast for Last Value Naive (so upper forecast might be 95th percentile largest number)
152
+ * More thorough use of setting random seed
153
+ * For monthly data account for number of days in month
154
+ * Option to run generations until generations no longer see improvement of at least X % over n generations
155
+
156
+ #### New Ensembles:
157
+ best 3 (unique algorithms not just variations)
158
+ forecast distance 30/30/30
159
+ best per series ensemble
160
+ best point with best probalistic containment
161
+ #### New models:
162
+ Seasonal Naive
163
+ Last Value + Drift Naive
164
+ Simple Decomposition forecasting
165
+ GluonTS Models
166
+ Simulations
167
+ Sklearn + TSFresh
168
+ Sklearn + polynomial features
169
+ Sktime
170
+ Ta-lib
171
+ tslearn
172
+ pydlm
173
+ Isotonic regression
174
+ TPOT if it adds multioutput functionality
175
+
176
+
@@ -0,0 +1,26 @@
1
+ autots/__init__.py,sha256=YGDDQCYlYZZUc8V3BTB9TFrCKLdPcHrtwIbfNIPksvA,396
2
+ autots/datasets/__init__.py,sha256=mu6O826oBODAPYN-fjAVdWQLPqxcwF4LHvyKyJZZno8,123
3
+ autots/datasets/_base.py,sha256=uIriLBZh8HLxOK55243e1uvcXoQVngNv8UJpTduvHIU,483
4
+ autots/datasets/fred.py,sha256=vtp2MdbybZ8kH5jXApKbmG7N1OnAMBuYvFd-5Eaz3x0,2322
5
+ autots/datasets/data/toy_daily.csv,sha256=WHR6jq7vE35fW6gNyKMDtphMiSBNDfSn0sD3-hu6nkg,13090
6
+ autots/evaluator/__init__.py,sha256=W52tlP7cKjwNBkvV9F9m8pNYk6QmVMvfUz9rOzb7c_w,30
7
+ autots/evaluator/auto_model.py,sha256=uApYbzRLpoQ-74C1Y1X8GRivkeEbwWUmjVvoVGjXdpc,36466
8
+ autots/evaluator/auto_ts.py,sha256=gm1p2_a1Kor9kd1iEVbOzmHLQjakdbqsrLYdfEUUMVQ,31813
9
+ autots/evaluator/metrics.py,sha256=at1eeey9Cik8LvTiv1Mg3bsc3FKH0Sb8S2SwNvJJPq0,6039
10
+ autots/models/basics.py,sha256=3wPcdNHKwSFqjFXKndl8r_8WIjAFDIjk8nIaxt2yL6g,10072
11
+ autots/models/ensemble.py,sha256=DqirKJru0UGDu2XwKM2xeNVelihaGl-Y6HirZmITyN0,9207
12
+ autots/models/prophet.py,sha256=gFUz4I4YA4l19NjFhQGFfeouyabMaJKgCUO8-eFvtCo,6926
13
+ autots/models/sklearn.py,sha256=mzoLn1P9UGY6edHwIAeSJAE53GNOvXQ3gkDvjxbKlTs,8420
14
+ autots/models/statsmodels.py,sha256=vBvzESJf8WUnC_JiP8W4Z3qFLQ9RgrKTj72kVwGTZDA,16585
15
+ autots/tools/__init__.py,sha256=d7csIB5IR_Bty-B5evzIbB3KRtPWMoSY4SPp7SdFerA,27
16
+ autots/tools/holiday.py,sha256=66iSw3MFZSsDiWFxu3pq_-y_TnwY96C2HKWqvQW3wOE,1892
17
+ autots/tools/impute.py,sha256=UNMkw9m9nW5umLXQJgAbwXRyicALNWzqWNt8f_6iabs,3301
18
+ autots/tools/probabilistic.py,sha256=YV_bHSIwoELs6Mqu_WA6E_jAbTuvFfWQPKWuPrImKiY,4490
19
+ autots/tools/profile.py,sha256=WfszidiNKSggk6J7vKKu7Atvfxa7ioi-RN-YWbpA3Do,935
20
+ autots/tools/shaping.py,sha256=5DAmr-D5pCk3Kx0OqOvDglGyxToQYQqPH1Ku4H6dOwU,11660
21
+ autots/tools/transform.py,sha256=qCapdKCVQpAPMvSWj5nyY-aO_D1Ej99WOPb_ywpg7tc,16659
22
+ AutoTS-0.0.2.dist-info/LICENSE,sha256=8UOx7AhGiXXInHrdKEY1IDVHiG3t8Sg817EVjn9MXks,1090
23
+ AutoTS-0.0.2.dist-info/METADATA,sha256=UKiBBQqmFIv1n6nJucFIdMtZ6m4tOoh-rP5-0wZJqoU,8977
24
+ AutoTS-0.0.2.dist-info/WHEEL,sha256=v8slff5hmCpvciQ3G55d2d1CnOBupjDFJHDE2dUb1Ao,97
25
+ AutoTS-0.0.2.dist-info/top_level.txt,sha256=bhy_5vpZM1lRYmoAfSD1mnUSNOyfnKBoihQmH6pEzAI,7
26
+ AutoTS-0.0.2.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: bdist_wheel (0.33.6)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ autots
autots/__init__.py ADDED
@@ -0,0 +1,16 @@
1
+ """
2
+ Automated Time Series Model Selection for Python
3
+
4
+ https://github.com/winedarksea/AutoTS
5
+ """
6
+ from autots.datasets import load_toy_daily
7
+ from autots.evaluator.auto_ts import AutoTS
8
+
9
+ __version__ = '0.0.2'
10
+
11
+ __all__ = ['load_toy_daily', 'AutoTS']
12
+
13
+ # import logging
14
+ # logger = logging.getLogger(__name__)
15
+ # logger.addHandler(logging.StreamHandler())
16
+ # logger.setLevel(logging.INFO)
@@ -0,0 +1,6 @@
1
+ """
2
+ Tools for Importing Sample Data
3
+ """
4
+ from autots.datasets._base import load_toy_daily
5
+
6
+ __all__ = ['load_toy_daily']
@@ -0,0 +1,16 @@
1
+ from os.path import dirname, join
2
+ import numpy as np
3
+ import pandas as pd
4
+
5
+ def load_toy_daily():
6
+ """
7
+ 4 series of sample daily data from late 2019
8
+ Testing some basic missing and categorical features.
9
+ """
10
+ module_path = dirname(__file__)
11
+ data_file_name = join(module_path, 'data', 'toy_daily.csv')
12
+
13
+ df_long = pd.read_csv(data_file_name)
14
+ df_long['date'] = pd.to_datetime(df_long['date'], infer_datetime_format = True)
15
+
16
+ return df_long