docstr: ####################################################################################
  ####                          Auto Time Series                                  ####
  ####         Developed by Ram Seshadri & Expanded by Nikhil Gupta               ####
  ####                        Python 3: copyright Ram Seshadri 2018-2021          ####
  ####################################################################################
  Initialize an auto_timeseries object
  :score_type: The metric used for scoring the models. Default = 'rmse'
  Currently only 2 are supported:
  (1) RMSE
  (2) Normalized RMSE (ratio of RMSE to the standard deviation of actual)
  :type str
  
  :param time_interval 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.
  We use the following codes from Pandas date-range frequency codes link:
  source: "https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#timeseries-offset-aliases">pandas date range frequency
  These are the same codes that Prophet uses to make the prediction dataframe.
  
  Hence, please note that these are the list of allowed aliases for time_interval
                        ['B','C','D','W','M','SM','BM','CBM',
                       'MS','SMS','BMS','CBMS','Q','BQ','QS','BQS',
                       'A,Y','BA,BY','AS,YS','BAS,BYS','BH',
                       'H','T,min','S','L,ms','U,us','N']
  
  For a start, you can test the following codes for your data and see how the results are:
  
  (1) 'MS', 'M', 'SM', 'BM', 'CBM', 'SMS', 'BMS' for monthly frequency data
  (2) 'D', 'B', 'C' for daily frequency data
  (3) 'W' for weekly frequency data
  (4) 'Q', 'BQ', 'QS', 'BQS' for quarterly frequency data
  (5) 'A,Y', 'BA,BY', 'AS,YS', 'BAS,YAS' for yearly frequency data
  (6) 'BH', 'H', 'h' for hourly frequency data
  (7) 'T,min' for minute frequency data
  (8) 'S', 'L,milliseconds', 'U,microseconds', 'N,nanoseconds' for second frequency data
  
  Or you can leave it as None and auto_timeseries will try and impute it.
  :type time_interval Optional[str]
  
  :param: non_seasonal_pdq Indicates the maximum value of p, d, q to be used in the search for "stats" based models.
  If None, then the following values are assumed max_p = 3, max_d = 1, max_q = 3
  :type non_seasonal_pdq Optional[Tuple]
  
  :param seasonality Used in the building of the SARIMAX model only at this time.
  :type seasonality bool
  
  :param seasonal_period: 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
  We assume the following as defaults but feel free to change them.
  (1) If frequency is Monthly, then seasonal_period is assumed to be 12
  (2) If frequency is Daily, then seasonal_period is assumed to be 30 (but it could be 7)
  (3) If frequency is Weekly, then seasonal_period is assumed to be 52
  (4) If frequency is Quarterly, then seasonal_period is assumed to be 4
  (5) If frequency is Yearly, then seasonal_period is assumed to be 1
  (6) If frequency is Hourly, then seasonal_period is assumed to be 24
  (7) If frequency is Minutes, then seasonal_period is assumed to be 60
  (8) If frequency is Seconds, then seasonal_period is assumed to be 60
  :type seasonal_period int
  
  :param conf_int: Confidence Interval for building the Prophet model. Default: 0.95
  :type conf_int float
  
  :param model_type 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', 'stats', 'SARIMAX', 'VAR', 'ML'.
  "prophet" will build a model using FB Prophet -> this means you must have FB Prophet installed
  "stats" will build statsmodels based 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 model_type: Union[str, List]
  
  :param verbose Indicates the verbosity of printing (Default = 0)
  :type verbose int
  
  :param dask_xgboost_flag: default is 0. But when you are fitting train data, you can
      ask it to load it into a dask dataframe with value set to 1.
  :type: dask_xgboost_flag Optional [int]
  
  :param lag Indicates the number of lags to include in ML models (Default = 2)
  :type verbose int
  
  #   ##################################################################################################
  #    AUTO_TIMESERIES IS A VERY COMPLEX MODEL BUILDING UTILITY FOR TIME SERIES DATA. SINCE IT AUTOMATES 
  #    MANY TASKS INVOLVED AT A FAST PACE, IT ASSUMES INTELLIGENT DEFAULTS. BUT YOU CAN CHANGE THEM.
  #    Auto_Timeseries will rapidly build predictive models based on Statsmodels, auto-ARIMA, Scikit-Learn
  #    and now dask_xgboost. It will automatically select the BEST model which gives best score specified.
  #    #####################################################################################################            
docstr_tok: ["#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","Auto","Time","Series","#","#","#","#","#","#","#","#","Developed","by","Ram","Seshadri","&","Expanded","by","Nikhil","Gupta","#","#","#","#","#","#","#","#","Python","3",":","copyright","Ram","Seshadri","2018-2021","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","Initialize","an","auto_timeseries","object",":","score_type",":","The","metric","used","for","scoring","the","models",".","Default","=","'rmse'","Currently","only","2","are","supported",":","(","1",")","RMSE","(","2",")","Normalized","RMSE","(","ratio","of","RMSE","to","the","standard","deviation","of","actual",")",":","type","str",":","param","time_interval","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",".","We","use","the","following","codes","from","Pandas","date-range","frequency","codes","link",":","source",":","``","https",":","\/\/pandas.pydata.org\/pandas-docs\/stable\/user_guide\/timeseries.html","#","timeseries-offset-aliases","''",">","pandas","date","range","frequency","These","are","the","same","codes","that","Prophet","uses","to","make","the","prediction","dataframe",".","Hence",",","please","note","that","these","are","the","list","of","allowed","aliases","for","time_interval","[","'","B","'",",","'","C","'",",","'D","'",",","'","W","'",",","'M","'",",","'SM","'",",","'BM","'",",","'CBM","'",",","'MS","'",",","'SMS","'",",","'BMS","'",",","'CBMS","'",",","'","Q","'",",","'BQ","'",",","'QS","'",",","'BQS","'",",","'","A",",","Y","'",",","'BA",",","BY","'",",","'AS",",","YS","'",",","'BAS",",","BYS","'",",","'BH","'",",","'","H","'",",","'T",",","min","'",",","'S","'",",","'","L",",","ms","'",",","'","U",",","us","'",",","'N","'","]","For","a","start",",","you","can","test","the","following","codes","for","your","data","and","see","how","the","results","are",":","(","1",")","'MS","'",",","'M","'",",","'SM","'",",","'BM","'",",","'CBM","'",",","'SMS","'",",","'BMS","'","for","monthly","frequency","data","(","2",")","'D","'",",","'","B","'",",","'","C","'","for","daily","frequency","data","(","3",")","'","W","'","for","weekly","frequency","data","(","4",")","'","Q","'",",","'BQ","'",",","'QS","'",",","'BQS","'","for","quarterly","frequency","data","(","5",")","'","A",",","Y","'",",","'BA",",","BY","'",",","'AS",",","YS","'",",","'BAS",",","YAS","'","for","yearly","frequency","data","(","6",")","'BH","'",",","'","H","'",",","'","h","'","for","hourly","frequency","data","(","7",")","'T",",","min","'","for","minute","frequency","data","(","8",")","'S","'",",","'","L",",","milliseconds","'",",","'","U",",","microseconds","'",",","'N",",","nanoseconds","'","for","second","frequency","data","Or","you","can","leave","it","as","None","and","auto_timeseries","will","try","and","impute","it",".",":","type","time_interval","Optional","[","str","]",":","param",":","non_seasonal_pdq","Indicates","the","maximum","value","of","p",",","d",",","q","to","be","used","in","the","search","for","``","stats","''","based","models",".","If","None",",","then","the","following","values","are","assumed","max_p","=","3",",","max_d","=","1",",","max_q","=","3",":","type","non_seasonal_pdq","Optional","[","Tuple","]",":","param","seasonality","Used","in","the","building","of","the","SARIMAX","model","only","at","this","time",".",":","type","seasonality","bool",":","param","seasonal_period",":","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","We","assume","the","following","as","defaults","but","feel","free","to","change","them",".","(","1",")","If","frequency","is","Monthly",",","then","seasonal_period","is","assumed","to","be","12","(","2",")","If","frequency","is","Daily",",","then","seasonal_period","is","assumed","to","be","30","(","but","it","could","be","7",")","(","3",")","If","frequency","is","Weekly",",","then","seasonal_period","is","assumed","to","be","52","(","4",")","If","frequency","is","Quarterly",",","then","seasonal_period","is","assumed","to","be","4","(","5",")","If","frequency","is","Yearly",",","then","seasonal_period","is","assumed","to","be","1","(","6",")","If","frequency","is","Hourly",",","then","seasonal_period","is","assumed","to","be","24","(","7",")","If","frequency","is","Minutes",",","then","seasonal_period","is","assumed","to","be","60","(","8",")","If","frequency","is","Seconds",",","then","seasonal_period","is","assumed","to","be","60",":","type","seasonal_period","int",":","param","conf_int",":","Confidence","Interval","for","building","the","Prophet","model",".","Default",":","0.95",":","type","conf_int","float",":","param","model_type","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","'",",","'stats","'",",","'SARIMAX","'",",","'VAR","'",",","'ML","'",".","``","prophet","''","will","build","a","model","using","FB","Prophet","-",">","this","means","you","must","have","FB","Prophet","installed","''","stats","''","will","build","statsmodels","based","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","model_type",":","Union","[","str",",","List","]",":","param","verbose","Indicates","the","verbosity","of","printing","(","Default","=","0",")",":","type","verbose","int",":","param","dask_xgboost_flag",":","default","is","0",".","But","when","you","are","fitting","train","data",",","you","can","ask","it","to","load","it","into","a","dask","dataframe","with","value","set","to","1.",":","type",":","dask_xgboost_flag","Optional","[","int","]",":","param","lag","Indicates","the","number","of","lags","to","include","in","ML","models","(","Default","=","2",")",":","type","verbose","int","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","AUTO_TIMESERIES","IS","A","VERY","COMPLEX","MODEL","BUILDING","UTILITY","FOR","TIME","SERIES","DATA",".","SINCE","IT","AUTOMATES","#","MANY","TASKS","INVOLVED","AT","A","FAST","PACE",",","IT","ASSUMES","INTELLIGENT","DEFAULTS",".","BUT","YOU","CAN","CHANGE","THEM",".","#","Auto_Timeseries","will","rapidly","build","predictive","models","based","on","Statsmodels",",","auto-ARIMA",",","Scikit-Learn","#","and","now","dask_xgboost",".","It","will","automatically","select","the","BEST","model","which","gives","best","score","specified",".","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#","#"]
code: def __init__(
      self,
      forecast_period: int = 5,
      score_type: str = "rmse",
      time_interval: Optional[str] = None,
      non_seasonal_pdq: Optional[Tuple] = None,
      seasonality: bool = False,
      seasonal_period: int = 12,
      conf_int: float = 0.95,
      model_type: Union[str, List] = "stats",
      verbose: int = 0,
      dask_xgboost_flag: int = 0,
      lag: int = 3,
      strf_time_format="",
      num_boost_rounds=250,
      *args,
      **kwargs,
  ):
      """
      ####################################################################################
      ####                          Auto Time Series                                  ####
      ####         Developed by Ram Seshadri & Expanded by Nikhil Gupta               ####
      ####                        Python 3: copyright Ram Seshadri 2018-2021          ####
      ####################################################################################
      Initialize an auto_timeseries object
      :score_type: The metric used for scoring the models. Default = 'rmse'
      Currently only 2 are supported:
      (1) RMSE
      (2) Normalized RMSE (ratio of RMSE to the standard deviation of actual)
      :type str
  
      :param time_interval 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.
      We use the following codes from Pandas date-range frequency codes link:
      source: "https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#timeseries-offset-aliases">pandas date range frequency
      These are the same codes that Prophet uses to make the prediction dataframe.
  
      Hence, please note that these are the list of allowed aliases for time_interval
                            ['B','C','D','W','M','SM','BM','CBM',
                           'MS','SMS','BMS','CBMS','Q','BQ','QS','BQS',
                           'A,Y','BA,BY','AS,YS','BAS,BYS','BH',
                           'H','T,min','S','L,ms','U,us','N']
  
      For a start, you can test the following codes for your data and see how the results are:
  
      (1) 'MS', 'M', 'SM', 'BM', 'CBM', 'SMS', 'BMS' for monthly frequency data
      (2) 'D', 'B', 'C' for daily frequency data
      (3) 'W' for weekly frequency data
      (4) 'Q', 'BQ', 'QS', 'BQS' for quarterly frequency data
      (5) 'A,Y', 'BA,BY', 'AS,YS', 'BAS,YAS' for yearly frequency data
      (6) 'BH', 'H', 'h' for hourly frequency data
      (7) 'T,min' for minute frequency data
      (8) 'S', 'L,milliseconds', 'U,microseconds', 'N,nanoseconds' for second frequency data
  
      Or you can leave it as None and auto_timeseries will try and impute it.
      :type time_interval Optional[str]
  
      :param: non_seasonal_pdq Indicates the maximum value of p, d, q to be used in the search for "stats" based models.
      If None, then the following values are assumed max_p = 3, max_d = 1, max_q = 3
      :type non_seasonal_pdq Optional[Tuple]
  
      :param seasonality Used in the building of the SARIMAX model only at this time.
      :type seasonality bool
  
      :param seasonal_period: 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
      We assume the following as defaults but feel free to change them.
      (1) If frequency is Monthly, then seasonal_period is assumed to be 12
      (2) If frequency is Daily, then seasonal_period is assumed to be 30 (but it could be 7)
      (3) If frequency is Weekly, then seasonal_period is assumed to be 52
      (4) If frequency is Quarterly, then seasonal_period is assumed to be 4
      (5) If frequency is Yearly, then seasonal_period is assumed to be 1
      (6) If frequency is Hourly, then seasonal_period is assumed to be 24
      (7) If frequency is Minutes, then seasonal_period is assumed to be 60
      (8) If frequency is Seconds, then seasonal_period is assumed to be 60
      :type seasonal_period int
  
      :param conf_int: Confidence Interval for building the Prophet model. Default: 0.95
      :type conf_int float
  
      :param model_type 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', 'stats', 'SARIMAX', 'VAR', 'ML'.
      "prophet" will build a model using FB Prophet -> this means you must have FB Prophet installed
      "stats" will build statsmodels based 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 model_type: Union[str, List]
  
      :param verbose Indicates the verbosity of printing (Default = 0)
      :type verbose int
  
      :param dask_xgboost_flag: default is 0. But when you are fitting train data, you can
          ask it to load it into a dask dataframe with value set to 1.
      :type: dask_xgboost_flag Optional [int]
  
      :param lag Indicates the number of lags to include in ML models (Default = 2)
      :type verbose int
  
      #   ##################################################################################################
      #    AUTO_TIMESERIES IS A VERY COMPLEX MODEL BUILDING UTILITY FOR TIME SERIES DATA. SINCE IT AUTOMATES
      #    MANY TASKS INVOLVED AT A FAST PACE, IT ASSUMES INTELLIGENT DEFAULTS. BUT YOU CAN CHANGE THEM.
      #    Auto_Timeseries will rapidly build predictive models based on Statsmodels, auto-ARIMA, Scikit-Learn
      #    and now dask_xgboost. It will automatically select the BEST model which gives best score specified.
      #    #####################################################################################################
      """
      self.ml_dict: Dict = {}
      self.score_type: str = score_type
      self.forecast_period = forecast_period
      self.time_interval = time_interval
      self.non_seasonal_pdq = non_seasonal_pdq
      self.seasonality = seasonality
      self.seasonal_period = seasonal_period
      self.conf_int = conf_int
      if isinstance(model_type, str):
          model_type = [model_type]
      self.model_type = model_type
      self.verbose = verbose
      self.holidays = None
      self.growth = "linear"
      self.allowed_models = [
          "best",
          "prophet",
          "stats",
          "ml",
          "arima",
          "ARIMA",
          "Prophet",
          "SARIMAX",
          "VAR",
          "ML",
      ]
      self.dask_xgboost_flag = dask_xgboost_flag
      self.sep = ","
      self.strf_time_format = strf_time_format
      self.num_boost_rounds = num_boost_rounds
      self.lag = lag
      if self.dask_xgboost_flag:
          print(
              "### Be careful setting 'dask_xgboost_flag' to True since dask is unstable and doesn't work well ###"
          )
  
      # new function.
      if args:
          for each_arg in args:
              print(each_arg)
  
      if kwargs:
          self.kwargs = kwargs
          for key, value in zip(kwargs.keys(), kwargs.values()):
              if key == "seasonal_PDQ":
                  print(
                      "seasonal_PDQ argument is deprecated. Please remove the argument in future."
                  )
              if key == "holidays":
                  print(
                      "holidays argument for FB Prophet given. It must be dictionary or DataFrame."
                  )
                  self.holidays = value
              if key == "growth":
                  print(
                      'growth argument of FB Prophet given. It must be "linear" or "logistic"'
                  )
                  self.growth = value
      else:
          self.kwargs = {}
  
imports: import warnings
  from typing import List, Dict, Optional, Tuple, Union
  from datetime import datetime
  import copy
  from collections import defaultdict
  import operator
  from time import time
  import pdb
  import pandas
  import numpy
  import dask
  import dask.dataframe
  from sklearn.exceptions import DataConversionWarning
  import seaborn
  import seaborn
  import matplotlib.pyplot
  from .models import BuildBase, BuildArima, BuildAutoSarimax, BuildVAR, BuildML
  from .models.build_prophet import BuildProphet
  from .utils import colorful, load_ts_data, convert_timeseries_dataframe_to_supervised, time_series_plot, print_static_rmse, print_dynamic_rmse, quick_ts_plot, test_stationarity, print_ts_model_stats
  from .__version__ import __version__
label_desc: Use image node_id 1 to create a new auto_timeseries object  with example: obj = auto_timeseries(forecast_period, score_type, time_interval, non_seasonal_pdq, seasonality, seasonal_period, conf_int, model_type, verbose, dask_xgboost_flag, lag, strf_time_format, num_boost_rounds)