Auto_TS: Auto_TimeSeries

Auto_timeseries is a complex model building utility for time series data. Since it automates many Tasks involved in a complex endeavor, it assumes many intelligent defaults. But you can change them. Auto_Timeseries will rapidly build predictive models based on Statsmodels ARIMA, Seasonal ARIMA and Scikit-Learn ML. It will automatically select the best model which gives best score specified.

New version 0.0.25 onwards changes the syntax of Auto_TimeSeries to be more like scikit-learn (fit and predict syntax). You will have to initialize an object and then call fit with your data and then predict again with data. Hope this makes it easier to remember and use.

Introduction

Auto_TimeSeries enables you to build and select multiple time series models using techniques such as ARIMA, SARIMAX, VAR, decomposable (trend+seasonality+holidays) models, and ensemble machine learning models.

Auto_TimeSeries is an Automated ML library for time series data. Auto_TimeSeries was initially conceived and developed by Ram Seshadri and was significantly expanded in functionality and scope and upgraded to its present status by Nikhil Gupta.

auto-ts.Auto_TimeSeries() is the main function that you will call with your train data. You can then choose what kind of models you want: stats, ml or FB prophet based model. You can also tell it to automatically select the best model based on the scoring parameter you want it to be based on. It will return the best model and a dictionary containing predictions for the number of forecast_periods you mentioned (default=2).

INSTALLATION INSTRUCTIONS

  1. Use “pip install auto-ts”
  2. Use “pip3 install auto-ts” if the above doesn’t work
  3. pip install git+git://github.com/AutoViML/Auto_TS

RUN

First you need to import auto_timeseries from auto_ts library:
from auto_ts import auto_timeseries

Second, Initialize an auto_timeseries model object which will hold all your parameters:

model = auto_timeseries( score_type='rmse', time_interval='Month', non_seasonal_pdq=None, seasonality=False, seasonal_period=12, model_type=['Prophet'], verbose=2)

Here are how the input parameters defined:
  1. score_type (default='rmse'): The metric used for scoring the models. Type is string. Currently only the following two types are supported: (1) "rmse": Root Mean Squared Error (RMSE) (2) "normalized_rmse": Ratio of RMSE to the standard deviation of actuals
  2. time_interval (default=None): Used to indicate the frequency at which the data is collected This is used for two purposes (1) in building the Prophet model and (2) used to impute the seasonal period for SARIMAX in case it is not provided by the user (None). Type is String. Allowed values are: (1) 'months', 'month', 'm' for monthly frequency data (2) 'days', 'daily', 'd' for daily freuency data (3) 'weeks', 'weekly', 'w' for weekly frequency data (4) 'qtr', 'quarter', 'q' for quarterly frequency data (5) 'years', 'year', 'annual', 'y', 'a' for yearly frequency data (6) 'hours', 'hourly', 'h' for hourly frequency data (7) 'minutes', 'minute', 'min', 'n' for minute frequency data (8) 'seconds', 'second', 'sec', 's' for second frequency data You can leave it blank and auto_timeseries will impute it.
  3. non_seasonal_pdq (default = (3,1,3)): Indicates the maximum value of (p, d, q) to be used in the search for statistical ARIMA models. If None, then the following values are assumed max_p = 3, max_d = 1, max_q = 3. Type is Tuple.
  4. seasonality (default=False): Used in the building of the SARIMAX model only at this time. True or False. Type is bool.
  5. seasonal_period (default is None): Indicates the seasonality period in the data. Used in the building of the SARIMAX model only at this time. There is no impact of this argument if seasonality is set to False If None, the program will try to infer this from the time_interval (frequency) of the data (1) If frequency = Monthly, then seasonal_period = 12 (1) If frequency = Daily, then seasonal_period = 30 (1) If frequency = Weekly, then seasonal_period = 52 (1) If frequency = Quarterly, then seasonal_period = 4 (1) If frequency = Yearly, then seasonal_period = 1 (1) If frequency = Hourly, then seasonal_period = 24 (1) If frequency = Minutes, then seasonal_period = 60 (1) If frequency = Seconds, then seasonal_period = 60 Type is integer
  6. conf_int (default=0.95): Confidence Interval for building the Prophet model. Default: 0.95. Type is float.
  7. model_type (default: 'stats': The type(s) of model to build. Default to building only statistical models Can be a string or a list of models. Allowed values are: 'best', 'prophet', 'pyflux', 'stats', 'ARIMA', 'SARIMAX', 'VAR', 'ML'. "prophet" will build a model using FB Prophet -> this means you must have FB Prophet installed "stats" will build statsmodels based ARIMA, SARIMAX and VAR models "ML" will build a machine learning model using Random Forests provided explanatory vars are given 'best' will try to build all models and pick the best one If a list is provided, then only those models will be built WARNING: "best" might take some time for large data sets. We recommend that you choose a small sample from your data set bedfore attempting to run entire data. Type can be either: [string, list]
  8. verbose (default=0): Indicates the verbosity of printing (Default = 0). Type is integer.
The next step after defining the model object is to fit it with some real data:

model.fit( traindata=train_data, ts_column=ts_column, target=target, cv=5, sep="," )


Here are how the parameters defined:
  • traindata (required): It can be either a dataframe or a file. You must give the name of the file along with its data path in case if a file. It also accepts a pandas dataframe in case you already have a dataframe loaded in your notebook.
  • ts_column (required): name of the datetime column in your dataset (it could be a name of column or index number in the columns index)
  • target (required): name of the column you are trying to predict. Target could also be the only column in your dataset
  • cv (default=5): You can enter any integer for the number of folds you want in your cross validation data set.
  • sep (default=","): Sep is the separator in your traindata file. If your separator is ",", "\t", ";", make sure you enter it here. If not, it is ignored.
The next step after training the model object is to make some predictions with test data:

predictions = model.predict( testdata = can be either test_data or forecast_period, )


Here are how the parameters are defined. You can choose to send either testdata in the form of a dataframe or send in an integer to decide how many periods you want to forecast. You need only
  • testdata (required): It can be either a dataframe or an empty string to indicate no test data frame is available. Instead you can use the forecast_period (next).
  • forecast_period (optional, default = 5): The number of time intervals ahead that you want to forecast. Type is integer.

Requirements

scikit-learn

FB Prophet

statsmodels

pmdarima

GitHub