class_docstr: Base class for a forecaster model.
  
  .. note::
  
      If your model depends on an evenly spaced time series, make sure to
  
      1. Call `ForecasterBase.train_pre_process` in `ForecasterBase.train`
      2. Call `ForecasterBase.resample_time_stamps` at the start of
         `ForecasterBase.forecast` to get a set of resampled time stamps, and
         call ``time_series.align(reference=time_stamps)`` to align the forecast
         with the original time stamps.
class_docstr_tok: ["Base","class","for","a","forecaster","model",".","..","note",":",":","If","your","model","depends","on","an","evenly","spaced","time","series",",","make","sure","to","1",".","Call","`","ForecasterBase.train_pre_process","`","in","`","ForecasterBase.train","`","2",".","Call","`","ForecasterBase.resample_time_stamps","`","at","the","start","of","`","ForecasterBase.forecast","`","to","get","a","set","of","resampled","time","stamps",",","and","call","``","time_series.align","(","reference=time_stamps",")","``","to","align","the","forecast","with","the","original","time","stamps","."]
docstr: Returns the model's forecast on the timestamps given. If ``self.transform`` is specified in the config, the
  forecast is a forecast of transformed values by default. To invert the transform and forecast the actual
  values of the time series, specify ``invert_transform = True`` when specifying the config.
  
  :param time_stamps: Either a ``list`` of timestamps we wish to forecast for, or the number of steps (``int``)
      we wish to forecast for.
  :param time_series_prev: a time series immediately preceding ``time_series``. If given, we use it to initialize
      the forecaster's state. Otherwise, we assume that ``time_series`` immediately follows the training data.
  :param exog_data: A time series of exogenous variables. Exogenous variables are known a priori, and they are
      independent of the variable being forecasted. ``exog_data`` must include data for all of ``time_stamps``;
      if ``time_series_prev`` is given, it must include data for all of ``time_series_prev.time_stamps`` as well.
      Optional. Only supported for models which inherit from `ForecasterExogBase`.
  :param return_iqr: whether to return the inter-quartile range for the forecast.
      Only supported for models which return error bars.
  :param return_prev: whether to return the forecast for ``time_series_prev`` (and its stderr or IQR if relevant),
      in addition to the forecast for ``time_stamps``. Only used if ``time_series_prev`` is provided.
  :return: ``(forecast, stderr)`` if ``return_iqr`` is false, ``(forecast, lb, ub)`` otherwise.
  
      - ``forecast``: the forecast for the timestamps given
      - ``stderr``: the standard error of each forecast value. May be ``None``.
      - ``lb``: 25th percentile of forecast values for each timestamp
      - ``ub``: 75th percentile of forecast values for each timestamp
docstr_tok: ["Returns","the","model","'s","forecast","on","the","timestamps","given",".","If","``","self.transform","``","is","specified","in","the","config",",","the","forecast","is","a","forecast","of","transformed","values","by","default",".","To","invert","the","transform","and","forecast","the","actual","values","of","the","time","series",",","specify","``","invert_transform","=","True","``","when","specifying","the","config",".",":","param","time_stamps",":","Either","a","``","list","``","of","timestamps","we","wish","to","forecast","for",",","or","the","number","of","steps","(","``","int","``",")","we","wish","to","forecast","for",".",":","param","time_series_prev",":","a","time","series","immediately","preceding","``","time_series","``",".","If","given",",","we","use","it","to","initialize","the","forecaster","'s","state",".","Otherwise",",","we","assume","that","``","time_series","``","immediately","follows","the","training","data",".",":","param","exog_data",":","A","time","series","of","exogenous","variables",".","Exogenous","variables","are","known","a","priori",",","and","they","are","independent","of","the","variable","being","forecasted",".","``","exog_data","``","must","include","data","for","all","of","``","time_stamps","``",";","if","``","time_series_prev","``","is","given",",","it","must","include","data","for","all","of","``","time_series_prev.time_stamps","``","as","well",".","Optional",".","Only","supported","for","models","which","inherit","from","`","ForecasterExogBase","`",".",":","param","return_iqr",":","whether","to","return","the","inter-quartile","range","for","the","forecast",".","Only","supported","for","models","which","return","error","bars",".",":","param","return_prev",":","whether","to","return","the","forecast","for","``","time_series_prev","``","(","and","its","stderr","or","IQR","if","relevant",")",",","in","addition","to","the","forecast","for","``","time_stamps","``",".","Only","used","if","``","time_series_prev","``","is","provided",".",":","return",":","``","(","forecast",",","stderr",")","``","if","``","return_iqr","``","is","false",",","``","(","forecast",",","lb",",","ub",")","``","otherwise",".","-","``","forecast","``",":","the","forecast","for","the","timestamps","given","-","``","stderr","``",":","the","standard","error","of","each","forecast","value",".","May","be","``","None","``",".","-","``","lb","``",":","25th","percentile","of","forecast","values","for","each","timestamp","-","``","ub","``",":","75th","percentile","of","forecast","values","for","each","timestamp"]
code: def forecast(
      self,
      time_stamps: Union[int, List[int]],
      time_series_prev: TimeSeries = None,
      exog_data: TimeSeries = None,
      return_iqr: bool = False,
      return_prev: bool = False,
  ) -> Union[
      Tuple[TimeSeries, Optional[TimeSeries]],
      Tuple[TimeSeries, TimeSeries, TimeSeries],
  ]:
      """
      Returns the model's forecast on the timestamps given. If ``self.transform`` is specified in the config, the
      forecast is a forecast of transformed values by default. To invert the transform and forecast the actual
      values of the time series, specify ``invert_transform = True`` when specifying the config.
  
      :param time_stamps: Either a ``list`` of timestamps we wish to forecast for, or the number of steps (``int``)
          we wish to forecast for.
      :param time_series_prev: a time series immediately preceding ``time_series``. If given, we use it to initialize
          the forecaster's state. Otherwise, we assume that ``time_series`` immediately follows the training data.
      :param exog_data: A time series of exogenous variables. Exogenous variables are known a priori, and they are
          independent of the variable being forecasted. ``exog_data`` must include data for all of ``time_stamps``;
          if ``time_series_prev`` is given, it must include data for all of ``time_series_prev.time_stamps`` as well.
          Optional. Only supported for models which inherit from `ForecasterExogBase`.
      :param return_iqr: whether to return the inter-quartile range for the forecast.
          Only supported for models which return error bars.
      :param return_prev: whether to return the forecast for ``time_series_prev`` (and its stderr or IQR if relevant),
          in addition to the forecast for ``time_stamps``. Only used if ``time_series_prev`` is provided.
      :return: ``(forecast, stderr)`` if ``return_iqr`` is false, ``(forecast, lb, ub)`` otherwise.
  
          - ``forecast``: the forecast for the timestamps given
          - ``stderr``: the standard error of each forecast value. May be ``None``.
          - ``lb``: 25th percentile of forecast values for each timestamp
          - ``ub``: 75th percentile of forecast values for each timestamp
      """
      # Determine the time stamps to forecast for, and resample them if needed
      orig_t = (
          None if isinstance(time_stamps, (int, float)) else time_stamps
      )
      time_stamps = self.resample_time_stamps(
          time_stamps, time_series_prev
      )
      if return_prev and time_series_prev is not None:
          if orig_t is None:
              orig_t = time_series_prev.time_stamps + time_stamps
          else:
              orig_t = (
                  time_series_prev.time_stamps
                  + to_timestamp(orig_t).tolist()
              )
  
      # Transform time_series_prev if it is given
      old_inversion_state = self.transform.inversion_state
      if time_series_prev is None:
          time_series_prev_df = None
      else:
          time_series_prev = self.transform(time_series_prev)
          assert time_series_prev.dim == self.dim, (
              f"time_series_prev has dimension of {time_series_prev.dim} that is different from "
              f"training data dimension of {self.dim} for the model"
          )
          time_series_prev_df = time_series_prev.to_pd()
  
      # Make the prediction
      exog_data, exog_data_prev = self.transform_exog_data(
          exog_data,
          time_stamps=time_stamps,
          time_series_prev=time_series_prev,
      )
      if exog_data is None:
          forecast, err = self._forecast(
              time_stamps=time_stamps,
              time_series_prev=time_series_prev_df,
              return_prev=return_prev,
          )
      else:
          forecast, err = self._forecast_with_exog(
              time_stamps=time_stamps,
              time_series_prev=time_series_prev_df,
              return_prev=return_prev,
              exog_data=exog_data.to_pd(),
              exog_data_prev=None
              if exog_data_prev is None
              else exog_data_prev.to_pd(),
          )
  
      # Format the return values and reset the transform's inversion state
      if self.invert_transform and time_series_prev is None:
          time_series_prev = self.transform(self.train_data)
      if (
          time_series_prev is not None
          and self.target_seq_index is not None
      ):
          time_series_prev = pd.DataFrame(
              time_series_prev.univariates[
                  time_series_prev.names[self.target_seq_index]
              ]
          )
      ret = self._process_forecast(
          forecast,
          err,
          time_series_prev,
          return_prev=return_prev,
          return_iqr=return_iqr,
      )
      self.transform.inversion_state = old_inversion_state
      return tuple(
          None if x is None else x.align(reference=orig_t) for x in ret
      )
  
imports: from abc import abstractmethod
  import copy
  import logging
  from typing import List, Optional, Tuple, Union
  import numpy
  import pandas
  from scipy.stats import norm
  from merlion.models.base import Config, ModelBase
  from merlion.plot import Figure
  from merlion.transform.base import TransformBase
  from merlion.transform.factory import TransformFactory
  from merlion.transform.normalize import MeanVarNormalize
  from merlion.utils.time_series import to_pd_datetime, to_timestamp, TimeSeries, AggregationPolicy, MissingValuePolicy
label_desc: Use image node_id 14 for calling the ForecasterBase obj's underlying member method code with example usage: obj.forecast(time_stamps, time_series_prev, exog_data, return_iqr, return_prev) and returns: tuple