class_docstr: Base class for an anomaly detection model.
class_docstr_tok: ["Base","class","for","an","anomaly","detection","model","."]
docstr: :param time_series: The `TimeSeries` we wish to plot & predict anomaly scores for.
  :param time_series_prev: a `TimeSeries` immediately preceding
      ``time_stamps``. If given, we use it to initialize the time series
      model. Otherwise, we assume that ``time_stamps`` immediately follows
      the training data.
  :param filter_scores: whether to filter the anomaly scores by the
      post-rule before plotting them.
  :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.
  :param fig: a `Figure` we might want to add anomaly scores onto.
  :return: a `Figure` of the model's anomaly score predictions.
docstr_tok: [":","param","time_series",":","The","`","TimeSeries","`","we","wish","to","plot","&","predict","anomaly","scores","for",".",":","param","time_series_prev",":","a","`","TimeSeries","`","immediately","preceding","``","time_stamps","``",".","If","given",",","we","use","it","to","initialize","the","time","series","model",".","Otherwise",",","we","assume","that","``","time_stamps","``","immediately","follows","the","training","data",".",":","param","filter_scores",":","whether","to","filter","the","anomaly","scores","by","the","post-rule","before","plotting","them",".",":","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",".",":","param","fig",":","a","`","Figure","`","we","might","want","to","add","anomaly","scores","onto",".",":","return",":","a","`","Figure","`","of","the","model","'s","anomaly","score","predictions","."]
code: def get_figure(
      self,
      time_series: TimeSeries,
      time_series_prev: TimeSeries = None,
      *,
      filter_scores=True,
      plot_time_series_prev=False,
      fig: Figure = None,
      **kwargs,
  ) -> Figure:
      """
      :param time_series: The `TimeSeries` we wish to plot & predict anomaly scores for.
      :param time_series_prev: a `TimeSeries` immediately preceding
          ``time_stamps``. If given, we use it to initialize the time series
          model. Otherwise, we assume that ``time_stamps`` immediately follows
          the training data.
      :param filter_scores: whether to filter the anomaly scores by the
          post-rule before plotting them.
      :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.
      :param fig: a `Figure` we might want to add anomaly scores onto.
      :return: a `Figure` of the model's anomaly score predictions.
      """
      f = (
          self.get_anomaly_label
          if filter_scores
          else self.get_anomaly_score
      )
      scores = f(
          time_series, time_series_prev=time_series_prev, **kwargs
      )
      scores = scores.univariates[scores.names[0]]
  
      # Get the severity level associated with each value & convert things to
      # numpy arrays as well
      assert time_series.dim == 1, (
          f"Plotting only supported for univariate time series, but got a"
          f"time series of dimension {time_series.dim}"
      )
      time_series = time_series.univariates[time_series.names[0]]
  
      if fig is None:
          if time_series_prev is not None and plot_time_series_prev:
              k = time_series_prev.names[0]
              time_series_prev = time_series_prev.univariates[k]
          elif not plot_time_series_prev:
              time_series_prev = None
          fig = Figure(
              y=time_series, y_prev=time_series_prev, anom=scores
          )
      else:
          if fig.y is None:
              fig.y = time_series
          fig.anom = scores
      return fig
  
imports: from abc import abstractmethod
  import copy
  import inspect
  import logging
  from typing import Any, Dict, List, Union
  import pandas
  from scipy.stats import norm
  from merlion.models.base import Config, ModelBase, MultipleTimeseriesModelMixin
  from merlion.plot import Figure, MTSFigure
  from merlion.post_process.calibrate import AnomScoreCalibrator
  from merlion.post_process.factory import PostRuleFactory
  from merlion.post_process.sequence import PostRuleSequence
  from merlion.post_process.threshold import AggregateAlarms, Threshold
  from merlion.utils import TimeSeries, UnivariateTimeSeries
  from merlion.utils.misc import call_with_accepted_kwargs
label_desc: Use image node_id 13 for calling the DetectorBase obj's underlying member method code with example usage: obj.get_figure(time_series, time_series_prev) and returns: fig