docstr: Forecasting-based Anomaly Detection Model
  
  The forecasting model may or may not be already fitted. The underlying assumption is that `model`
  should be able to accurately forecast the series in the absence of anomalies. For this reason,
  it is recommended to either provide a model that has already been fitted and evaluated to work
  appropriately on a series without anomalies, or to ensure that a simple call to the :func:`fit()`
  method of the model will be sufficient to train it to satisfactory performance on a series without anomalies.
  
  Calling :func:`fit()` on the anomaly model will fit the underlying forecasting model only
  if ``allow_model_training`` is set to ``True`` upon calling ``fit()``.
  In addition, calling :func:`fit()` will also fit the fittable scorers, if any.
  
  Parameters
  ----------
  model
      An instance of a Darts forecasting model.
  scorer
      One or multiple scorer(s) that will be used to compare the actual and predicted time series in order
      to obtain an anomaly score ``TimeSeries``.
      If a list of `N` scorers is given, the anomaly model will call each
      one of the scorers and output a list of `N` anomaly scores ``TimeSeries``.
docstr_tok: ["Forecasting-based","Anomaly","Detection","Model","The","forecasting","model","may","or","may","not","be","already","fitted",".","The","underlying","assumption","is","that","`","model","`","should","be","able","to","accurately","forecast","the","series","in","the","absence","of","anomalies",".","For","this","reason",",","it","is","recommended","to","either","provide","a","model","that","has","already","been","fitted","and","evaluated","to","work","appropriately","on","a","series","without","anomalies",",","or","to","ensure","that","a","simple","call","to","the",":","func",":","`","fit","(",")","`","method","of","the","model","will","be","sufficient","to","train","it","to","satisfactory","performance","on","a","series","without","anomalies",".","Calling",":","func",":","`","fit","(",")","`","on","the","anomaly","model","will","fit","the","underlying","forecasting","model","only","if","``","allow_model_training","``","is","set","to","``","True","``","upon","calling","``","fit","(",")","``",".","In","addition",",","calling",":","func",":","`","fit","(",")","`","will","also","fit","the","fittable","scorers",",","if","any",".","Parameters","--","--","--","--","--","model","An","instance","of","a","Darts","forecasting","model",".","scorer","One","or","multiple","scorer","(","s",")","that","will","be","used","to","compare","the","actual","and","predicted","time","series","in","order","to","obtain","an","anomaly","score","``","TimeSeries","``",".","If","a","list","of","`","N","`","scorers","is","given",",","the","anomaly","model","will","call","each","one","of","the","scorers","and","output","a","list","of","`","N","`","anomaly","scores","``","TimeSeries","``","."]
code: def __init__(
      self,
      model: ForecastingModel,
      scorer: Union[AnomalyScorer, Sequence[AnomalyScorer]],
  ):
      """Forecasting-based Anomaly Detection Model
  
      The forecasting model may or may not be already fitted. The underlying assumption is that `model`
      should be able to accurately forecast the series in the absence of anomalies. For this reason,
      it is recommended to either provide a model that has already been fitted and evaluated to work
      appropriately on a series without anomalies, or to ensure that a simple call to the :func:`fit()`
      method of the model will be sufficient to train it to satisfactory performance on a series without anomalies.
  
      Calling :func:`fit()` on the anomaly model will fit the underlying forecasting model only
      if ``allow_model_training`` is set to ``True`` upon calling ``fit()``.
      In addition, calling :func:`fit()` will also fit the fittable scorers, if any.
  
      Parameters
      ----------
      model
          An instance of a Darts forecasting model.
      scorer
          One or multiple scorer(s) that will be used to compare the actual and predicted time series in order
          to obtain an anomaly score ``TimeSeries``.
          If a list of `N` scorers is given, the anomaly model will call each
          one of the scorers and output a list of `N` anomaly scores ``TimeSeries``.
      """
  
      raise_if_not(
          isinstance(model, ForecastingModel),
          f"Model must be a darts ForecastingModel not a {type(model)}.",
      )
      self.model = model
  
      super().__init__(model=model, scorer=scorer)
  
file_path: darts/darts/ad/anomaly_model/forecasting_am.py
imports: import inspect
  from typing import Dict, Optional, Sequence, Union
  import pandas
  from darts.ad.anomaly_model.anomaly_model import AnomalyModel
  from darts.ad.scorers.scorers import AnomalyScorer
  from darts.ad.utils import _assert_same_length, _assert_timeseries, _to_list
  from darts.logging import get_logger, raise_if_not
  from darts.models.forecasting.forecasting_model import ForecastingModel
  from darts.timeseries import TimeSeries
label_desc: Use image node_id 1 to create a new ForecastingAnomalyModel object from inherited base classes: AnomalyModel with example: obj = ForecastingAnomalyModel(model, scorer)