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: :param time_series: the time series over whose timestamps we wish to make a forecast. Exactly one of
      ``time_series`` or ``time_stamps`` should be provided.
  :param time_stamps: Either a ``list`` of timestamps we wish to forecast for, or the number of steps (``int``)
      we wish to forecast for. Exactly one of ``time_series`` or ``time_stamps`` should be provided.
  :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 plot_forecast_uncertainty: whether to plot uncertainty estimates (the inter-quartile range) for forecast
      values. Not supported for all  models.
  :param plot_time_series_prev: whether to plot ``time_series_prev`` (and  the model's fit for it).
      Only used if ``time_series_prev`` is given.
  :return: a `Figure` of the model's forecast.
docstr_tok: [":","param","time_series",":","the","time","series","over","whose","timestamps","we","wish","to","make","a","forecast",".","Exactly","one","of","``","time_series","``","or","``","time_stamps","``","should","be","provided",".",":","param","time_stamps",":","Either","a","``","list","``","of","timestamps","we","wish","to","forecast","for",",","or","the","number","of","steps","(","``","int","``",")","we","wish","to","forecast","for",".","Exactly","one","of","``","time_series","``","or","``","time_stamps","``","should","be","provided",".",":","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","plot_forecast_uncertainty",":","whether","to","plot","uncertainty","estimates","(","the","inter-quartile","range",")","for","forecast","values",".","Not","supported","for","all","models",".",":","param","plot_time_series_prev",":","whether","to","plot","``","time_series_prev","``","(","and","the","model","'s","fit","for","it",")",".","Only","used","if","``","time_series_prev","``","is","given",".",":","return",":","a","`","Figure","`","of","the","model","'s","forecast","."]
code: def get_figure(
      self,
      *,
      time_series: TimeSeries = None,
      time_stamps: List[int] = None,
      time_series_prev: TimeSeries = None,
      exog_data: TimeSeries = None,
      plot_forecast_uncertainty=False,
      plot_time_series_prev=False,
  ) -> Figure:
      """
      :param time_series: the time series over whose timestamps we wish to make a forecast. Exactly one of
          ``time_series`` or ``time_stamps`` should be provided.
      :param time_stamps: Either a ``list`` of timestamps we wish to forecast for, or the number of steps (``int``)
          we wish to forecast for. Exactly one of ``time_series`` or ``time_stamps`` should be provided.
      :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 plot_forecast_uncertainty: whether to plot uncertainty estimates (the inter-quartile range) for forecast
          values. Not supported for all  models.
      :param plot_time_series_prev: whether to plot ``time_series_prev`` (and  the model's fit for it).
          Only used if ``time_series_prev`` is given.
      :return: a `Figure` of the model's forecast.
      """
      assert not (
          time_series is None and time_stamps is None
      ), "Must provide at least one of time_series or time_stamps"
      if time_stamps is None:
          if self.invert_transform:
              time_stamps = time_series.time_stamps
              y = time_series.univariates[
                  time_series.names[self.target_seq_index]
              ]
          else:
              transformed_ts = self.transform(time_series)
              time_stamps = transformed_ts.time_stamps
              y = transformed_ts.univariates[
                  transformed_ts.names[self.target_seq_index]
              ]
      else:
          y = None
  
      # Get forecast + bounds if plotting uncertainty
      if plot_forecast_uncertainty:
          yhat, lb, ub = self.forecast(
              time_stamps,
              time_series_prev,
              exog_data=exog_data,
              return_iqr=True,
              return_prev=plot_time_series_prev,
          )
          yhat, lb, ub = [
              None if x is None else x.univariates[x.names[0]]
              for x in [yhat, lb, ub]
          ]
  
      # Just get the forecast otherwise
      else:
          lb, ub = None, None
          yhat, err = self.forecast(
              time_stamps,
              time_series_prev,
              exog_data=exog_data,
              return_iqr=False,
              return_prev=plot_time_series_prev,
          )
          yhat = yhat.univariates[yhat.names[0]]
  
      # Set up all the parameters needed to make a figure
      if time_series_prev is not None and plot_time_series_prev:
          if not self.invert_transform:
              time_series_prev = self.transform(time_series_prev)
          time_series_prev = time_series_prev.univariates[
              time_series_prev.names[self.target_seq_index]
          ]
  
          n_prev = len(time_series_prev)
          yhat_prev, yhat = yhat[:n_prev], yhat[n_prev:]
          if lb is not None and ub is not None:
              lb_prev, lb = lb[:n_prev], lb[n_prev:]
              ub_prev, ub = ub[:n_prev], ub[n_prev:]
          else:
              lb_prev = ub_prev = None
      else:
          time_series_prev = None
          yhat_prev = lb_prev = ub_prev = None
  
      # Create the figure
      return Figure(
          y=y,
          yhat=yhat,
          yhat_lb=lb,
          yhat_ub=ub,
          y_prev=time_series_prev,
          yhat_prev=yhat_prev,
          yhat_prev_lb=lb_prev,
          yhat_prev_ub=ub_prev,
      )
  
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 19 for calling the ForecasterBase obj's underlying member method code with example usage: obj.get_figure() and returns: Figure