code: def test_univariate_FilteringAnomalyModel(self):
      np.random.seed(40)
  
      np_series_train = np.array(range(0, 100, 1)) + np.random.normal(
          loc=0, scale=1, size=100
      )
      np_series_test = np.array(range(0, 100, 1)) + np.random.normal(
          loc=0, scale=1, size=100
      )
  
      np_series_test[30:35] = np_series_test[30:35] + np.random.normal(
          loc=0, scale=10, size=5
      )
      np_series_test[50:60] = np_series_test[50:60] + np.random.normal(
          loc=0, scale=4, size=10
      )
      np_series_test[75:80] = np_series_test[75:80] + np.random.normal(
          loc=0, scale=3, size=5
      )
  
      train_series_noise = TimeSeries.from_values(np_series_train)
      test_series_noise = TimeSeries.from_values(np_series_test)
  
      np_anomalies = np.zeros(100)
      np_anomalies[30:35] = 1
      np_anomalies[50:60] = 1
      np_anomalies[75:80] = 1
      ts_anomalies = TimeSeries.from_times_and_values(
          test_series_noise.time_index,
          np_anomalies,
          columns=["is_anomaly"],
      )
  
      anomaly_model = FilteringAnomalyModel(
          model=MovingAverageFilter(window=5),
          scorer=[
              NormScorer(),
              Difference(),
              WassersteinScorer(),
              KMeansScorer(),
              KMeansScorer(window=10),
              PyODScorer(model=KNN()),
              PyODScorer(model=KNN(), window=10),
              WassersteinScorer(window=15),
          ],
      )
      anomaly_model.fit(train_series_noise)
      score, model_output = anomaly_model.score(
          test_series_noise, return_model_prediction=True
      )
  
      # check that Difference is the difference of model_output and test_series_noise
      assert test_series_noise.slice_intersect(
          model_output
      ) - model_output == Difference().score_from_prediction(
          test_series_noise, model_output
      )
  
      # check that NormScorer is the abs difference of model_output and test_series_noise
      assert (
          test_series_noise.slice_intersect(model_output) - model_output
      ).__abs__() == NormScorer().score_from_prediction(
          test_series_noise, model_output
      )
  
      dict_auc_roc = anomaly_model.eval_accuracy(
          ts_anomalies, test_series_noise, metric="AUC_ROC"
      )
      dict_auc_pr = anomaly_model.eval_accuracy(
          ts_anomalies, test_series_noise, metric="AUC_PR"
      )
  
      auc_roc_from_scores = eval_accuracy_from_scores(
          actual_anomalies=[ts_anomalies] * 8,
          anomaly_score=score,
          window=[1, 1, 10, 1, 10, 1, 10, 15],
          metric="AUC_ROC",
      )
  
      auc_pr_from_scores = eval_accuracy_from_scores(
          actual_anomalies=[ts_anomalies] * 8,
          anomaly_score=score,
          window=[1, 1, 10, 1, 10, 1, 10, 15],
          metric="AUC_PR",
      )
  
      # function eval_accuracy_from_scores and eval_accuracy must return an input of same length
      assert len(auc_roc_from_scores) == len(dict_auc_roc)
      assert len(auc_pr_from_scores) == len(dict_auc_pr)
  
      # function eval_accuracy_from_scores and eval_accuracy must return the same values
      np.testing.assert_array_almost_equal(
          auc_roc_from_scores, list(dict_auc_roc.values()), decimal=1
      )
      np.testing.assert_array_almost_equal(
          auc_pr_from_scores, list(dict_auc_pr.values()), decimal=1
      )
  
      true_auc_roc = [
          0.875625,
          0.5850000000000001,
          0.952127659574468,
          0.814375,
          0.9598646034816247,
          0.88125,
          0.9666344294003868,
          0.9731182795698925,
      ]
  
      true_auc_pr = [
          0.7691407907338141,
          0.5566414178265074,
          0.9720504927710986,
          0.741298584352156,
          0.9744855592642071,
          0.7808056518442923,
          0.9800621192517156,
          0.9911842778990486,
      ]
  
      # check value of results
      np.testing.assert_array_almost_equal(
          auc_roc_from_scores, true_auc_roc, decimal=1
      )
      np.testing.assert_array_almost_equal(
          auc_pr_from_scores, true_auc_pr, decimal=1
      )
  
imports: from typing import Dict, Sequence, Tuple
  import numpy
  import pandas
  import pytest
  from pyod.models.knn import KNN
  from darts import TimeSeries
  from darts.ad import AndAggregator
  from darts.ad import EnsembleSklearnAggregator
  from darts.ad import OrAggregator
  from darts.ad import QuantileDetector
  from darts.ad import ThresholdDetector
  from darts.ad import CauchyNLLScorer
  from darts.ad import DifferenceScorer
  from darts.ad import ExponentialNLLScorer, FilteringAnomalyModel, ForecastingAnomalyModel, GammaNLLScorer, GaussianNLLScorer, KMeansScorer, LaplaceNLLScorer, NormScorer, PoissonNLLScorer, PyODScorer, WassersteinScorer
  from darts.ad.utils import eval_accuracy_from_scores, show_anomalies_from_scores
  from darts.models import MovingAverageFilter, NaiveSeasonal, RegressionModel
label_desc: Use image node_id 11 for calling the TestADAnomalyModel obj's underlying member method code with example usage: obj.test_univariate_FilteringAnomalyModel() without return types