docstr: Compute the accuracy of the anomaly scores computed by the model.
  
  Predicts the `series` with the forecasting model, and applies the
  scorer(s) on the predicted time series and the given target time series. Returns the
  score(s) of an agnostic threshold metric, based on the anomaly score given by the scorer(s).
  
  Parameters
  ----------
  actual_anomalies
      The (sequence of) ground truth of the anomalies (1 if it is an anomaly and 0 if not)
  series
      The (sequence of) series to predict anomalies on.
  past_covariates
      An optional past-observed covariate series or sequence of series. This applies only
      if the model supports past covariates.
  future_covariates
      An optional future-known covariate series or sequence of series. This applies only
      if the model supports future covariates.
  forecast_horizon
      The forecast horizon for the predictions.
  start
      The first point of time at which a prediction is computed for a future time.
      This parameter supports 3 different data types: ``float``, ``int`` and ``pandas.Timestamp``.
      In the case of ``float``, the parameter will be treated as the proportion of the time series
      that should lie before the first prediction point.
      In the case of ``int``, the parameter will be treated as an integer index to the time index of
      `series` that will be used as first prediction time.
      In case of ``pandas.Timestamp``, this time stamp will be used to determine the first prediction time
      directly.
  num_samples
      Number of times a prediction is sampled from a probabilistic model. Should be left set to 1 for
      deterministic models.
  metric
      Optionally, Scoring function to use. Must be one of "AUC_ROC" and "AUC_PR".
      Default: "AUC_ROC"
  
  Returns
  -------
  Union[Dict[str, float], Dict[str, Sequence[float]], Sequence[Dict[str, float]],
  Sequence[Dict[str, Sequence[float]]]]
      Score for the time series.
      A (sequence of) dictionary with the keys being the name of the scorers, and the values being the
      metric results on the (sequence of) `series`. If the scorer treats every dimension independently
      (by nature of the scorer or if its component_wise is set to True), the values of the dictionary
      will be a Sequence containing the score for each dimension.
docstr_tok: ["Compute","the","accuracy","of","the","anomaly","scores","computed","by","the","model",".","Predicts","the","`","series","`","with","the","forecasting","model",",","and","applies","the","scorer","(","s",")","on","the","predicted","time","series","and","the","given","target","time","series",".","Returns","the","score","(","s",")","of","an","agnostic","threshold","metric",",","based","on","the","anomaly","score","given","by","the","scorer","(","s",")",".","Parameters","--","--","--","--","--","actual_anomalies","The","(","sequence","of",")","ground","truth","of","the","anomalies","(","1","if","it","is","an","anomaly","and","0","if","not",")","series","The","(","sequence","of",")","series","to","predict","anomalies","on",".","past_covariates","An","optional","past-observed","covariate","series","or","sequence","of","series",".","This","applies","only","if","the","model","supports","past","covariates",".","future_covariates","An","optional","future-known","covariate","series","or","sequence","of","series",".","This","applies","only","if","the","model","supports","future","covariates",".","forecast_horizon","The","forecast","horizon","for","the","predictions",".","start","The","first","point","of","time","at","which","a","prediction","is","computed","for","a","future","time",".","This","parameter","supports","3","different","data","types",":","``","float","``",",","``","int","``","and","``","pandas.Timestamp","``",".","In","the","case","of","``","float","``",",","the","parameter","will","be","treated","as","the","proportion","of","the","time","series","that","should","lie","before","the","first","prediction","point",".","In","the","case","of","``","int","``",",","the","parameter","will","be","treated","as","an","integer","index","to","the","time","index","of","`","series","`","that","will","be","used","as","first","prediction","time",".","In","case","of","``","pandas.Timestamp","``",",","this","time","stamp","will","be","used","to","determine","the","first","prediction","time","directly",".","num_samples","Number","of","times","a","prediction","is","sampled","from","a","probabilistic","model",".","Should","be","left","set","to","1","for","deterministic","models",".","metric","Optionally",",","Scoring","function","to","use",".","Must","be","one","of","``","AUC_ROC","''","and","``","AUC_PR","''",".","Default",":","``","AUC_ROC","''","Returns","--","--","--","-","Union","[","Dict","[","str",",","float","]",",","Dict","[","str",",","Sequence","[","float","]","]",",","Sequence","[","Dict","[","str",",","float","]","]",",","Sequence","[","Dict","[","str",",","Sequence","[","float","]","]","]","]","Score","for","the","time","series",".","A","(","sequence","of",")","dictionary","with","the","keys","being","the","name","of","the","scorers",",","and","the","values","being","the","metric","results","on","the","(","sequence","of",")","`","series","`",".","If","the","scorer","treats","every","dimension","independently","(","by","nature","of","the","scorer","or","if","its","component_wise","is","set","to","True",")",",","the","values","of","the","dictionary","will","be","a","Sequence","containing","the","score","for","each","dimension","."]
code: def eval_accuracy(
      self,
      actual_anomalies: Union[TimeSeries, Sequence[TimeSeries]],
      series: Union[TimeSeries, Sequence[TimeSeries]],
      past_covariates: Optional[
          Union[TimeSeries, Sequence[TimeSeries]]
      ] = None,
      future_covariates: Optional[
          Union[TimeSeries, Sequence[TimeSeries]]
      ] = None,
      forecast_horizon: int = 1,
      start: Union[pd.Timestamp, float, int] = 0.5,
      num_samples: int = 1,
      metric: str = "AUC_ROC",
  ) -> Union[
      Dict[str, float],
      Dict[str, Sequence[float]],
      Sequence[Dict[str, float]],
      Sequence[Dict[str, Sequence[float]]],
  ]:
      """Compute the accuracy of the anomaly scores computed by the model.
  
      Predicts the `series` with the forecasting model, and applies the
      scorer(s) on the predicted time series and the given target time series. Returns the
      score(s) of an agnostic threshold metric, based on the anomaly score given by the scorer(s).
  
      Parameters
      ----------
      actual_anomalies
          The (sequence of) ground truth of the anomalies (1 if it is an anomaly and 0 if not)
      series
          The (sequence of) series to predict anomalies on.
      past_covariates
          An optional past-observed covariate series or sequence of series. This applies only
          if the model supports past covariates.
      future_covariates
          An optional future-known covariate series or sequence of series. This applies only
          if the model supports future covariates.
      forecast_horizon
          The forecast horizon for the predictions.
      start
          The first point of time at which a prediction is computed for a future time.
          This parameter supports 3 different data types: ``float``, ``int`` and ``pandas.Timestamp``.
          In the case of ``float``, the parameter will be treated as the proportion of the time series
          that should lie before the first prediction point.
          In the case of ``int``, the parameter will be treated as an integer index to the time index of
          `series` that will be used as first prediction time.
          In case of ``pandas.Timestamp``, this time stamp will be used to determine the first prediction time
          directly.
      num_samples
          Number of times a prediction is sampled from a probabilistic model. Should be left set to 1 for
          deterministic models.
      metric
          Optionally, Scoring function to use. Must be one of "AUC_ROC" and "AUC_PR".
          Default: "AUC_ROC"
  
      Returns
      -------
      Union[Dict[str, float], Dict[str, Sequence[float]], Sequence[Dict[str, float]],
      Sequence[Dict[str, Sequence[float]]]]
          Score for the time series.
          A (sequence of) dictionary with the keys being the name of the scorers, and the values being the
          metric results on the (sequence of) `series`. If the scorer treats every dimension independently
          (by nature of the scorer or if its component_wise is set to True), the values of the dictionary
          will be a Sequence containing the score for each dimension.
      """
  
      list_actual_anomalies = _to_list(actual_anomalies)
      list_series = _to_list(series)
  
      raise_if_not(
          all([isinstance(s, TimeSeries) for s in list_series]),
          "all input `series` must be of type Timeseries.",
      )
  
      raise_if_not(
          all(
              [isinstance(s, TimeSeries) for s in list_actual_anomalies]
          ),
          "all input `actual_anomalies` must be of type Timeseries.",
      )
  
      _assert_same_length(list_actual_anomalies, list_series)
      self._check_univariate(list_actual_anomalies)
  
      list_anomaly_scores = self.score(
          series=list_series,
          past_covariates=past_covariates,
          future_covariates=future_covariates,
          forecast_horizon=forecast_horizon,
          start=start,
          num_samples=num_samples,
      )
  
      acc_anomaly_scores = self._eval_accuracy_from_scores(
          list_actual_anomalies=list_actual_anomalies,
          list_anomaly_scores=list_anomaly_scores,
          metric=metric,
      )
  
      if len(acc_anomaly_scores) == 1 and not isinstance(
          series, Sequence
      ):
          return acc_anomaly_scores[0]
      else:
          return acc_anomaly_scores
  
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 8 for calling the ForecastingAnomalyModel obj's underlying member method code with example usage: obj.eval_accuracy(actual_anomalies, series, past_covariates, future_covariates, forecast_horizon, start, num_samples, metric) and returns: acc_anomaly_scores, acc_anomaly_scores