code: def test_OrAggregator(self):
      aggregator = OrAggregator()
  
      # simple case
      # aggregator must have an accuracy of 0 for input with 2 components
      # (only 1 and only 0) and ground truth is only 0
      assert (
          abs(
              aggregator.eval_accuracy(
                  self.onlyzero,
                  self.series_1_and_0,
                  metric="accuracy",
              )
              - 0
          )
          < 1e-05
      )
      # aggregator must have an accuracy of 1 for input with 2 components
      # (only 1 and only 0) and ground truth is only 1
      assert (
          abs(
              aggregator.eval_accuracy(
                  self.onlyones,
                  self.series_1_and_0,
                  metric="accuracy",
              )
              - 1
          )
          < 1e-05
      )
  
      # aggregator must have an accuracy of 1 for the input containing only 1
      assert (
          abs(
              aggregator.eval_accuracy(
                  self.onlyones,
                  self.mts_onlyones,
                  metric="accuracy",
              )
              - 1
          )
          < 1e-05
      )
      # aggregator must have an accuracy of 1 for the input containing only 1
      assert (
          abs(
              aggregator.eval_accuracy(
                  self.onlyones,
                  self.mts_onlyones,
                  metric="recall",
              )
              - 1
          )
          < 1e-05
      )
      # aggregator must have an accuracy of 1 for the input containing only 1
      assert (
          abs(
              aggregator.eval_accuracy(
                  self.onlyones,
                  self.mts_onlyones,
                  metric="precision",
              )
              - 1
          )
          < 1e-05
      )
  
      # single series case (random example)
      # aggregator must found 67 anomalies in the input mts_anomalies1
      assert (
          aggregator.predict(self.mts_anomalies1)
          .sum(axis=0)
          .all_values()
          .flatten()[0]
          == 67
      )
  
      # aggregator must have an accuracy of 0.56 for the input mts_anomalies1
      assert (
          abs(
              aggregator.eval_accuracy(
                  self.real_anomalies,
                  self.mts_anomalies1,
                  metric="accuracy",
              )
              - 0.56
          )
          < 1e-05
      )
      # aggregator must have an recall of 0.72549 for the input mts_anomalies1
      assert (
          abs(
              aggregator.eval_accuracy(
                  self.real_anomalies,
                  self.mts_anomalies1,
                  metric="recall",
              )
              - 0.72549
          )
          < 1e-05
      )
      # aggregator must have an f1 of 0.62711 for the input mts_anomalies1
      assert (
          abs(
              aggregator.eval_accuracy(
                  self.real_anomalies, self.mts_anomalies1, metric="f1"
              )
              - 0.62711
          )
          < 1e-05
      )
      # aggregator must have an precision of 0.55223 for the input mts_anomalies1
      assert (
          abs(
              aggregator.eval_accuracy(
                  self.real_anomalies,
                  self.mts_anomalies1,
                  metric="precision",
              )
              - 0.55223
          )
          < 1e-05
      )
  
      # multiple series case (random example)
      # aggregator must found [67,75] anomalies in the input [mts_anomalies1, mts_anomalies2]
      values = aggregator.predict(
          [self.mts_anomalies1, self.mts_anomalies2]
      )
      np.testing.assert_array_almost_equal(
          [v.sum(axis=0).all_values().flatten()[0] for v in values],
          [67, 75],
          decimal=1,
      )
  
      # aggregator must have an accuracy of [0.56,0.52] for the input [mts_anomalies1, mts_anomalies2]
      np.testing.assert_array_almost_equal(
          np.array(
              aggregator.eval_accuracy(
                  [self.real_anomalies, self.real_anomalies],
                  [self.mts_anomalies1, self.mts_anomalies2],
                  metric="accuracy",
              )
          ),
          np.array([0.56, 0.52]),
          decimal=1,
      )
      # aggregator must have an recall of [0.72549,0.764706] for the input [mts_anomalies1, mts_anomalies2]
      np.testing.assert_array_almost_equal(
          np.array(
              aggregator.eval_accuracy(
                  [self.real_anomalies, self.real_anomalies],
                  [self.mts_anomalies1, self.mts_anomalies2],
                  metric="recall",
              )
          ),
          np.array([0.72549, 0.764706]),
          decimal=1,
      )
      # aggregator must have an f1 of [0.627119,0.619048] for the input [mts_anomalies1, mts_anomalies2]
      np.testing.assert_array_almost_equal(
          np.array(
              aggregator.eval_accuracy(
                  [self.real_anomalies, self.real_anomalies],
                  [self.mts_anomalies1, self.mts_anomalies2],
                  metric="f1",
              )
          ),
          np.array([0.627119, 0.619048]),
          decimal=1,
      )
      # aggregator must have an precision of [0.552239,0.52] for the input [mts_anomalies1, mts_anomalies2]
      np.testing.assert_array_almost_equal(
          np.array(
              aggregator.eval_accuracy(
                  [self.real_anomalies, self.real_anomalies],
                  [self.mts_anomalies1, self.mts_anomalies2],
                  metric="precision",
              )
          ),
          np.array([0.552239, 0.52]),
          decimal=1,
      )
  
file_path: darts/darts/tests/ad/test_aggregators.py
imports: from typing import Sequence
  import numpy
  import pytest
  from sklearn.ensemble import GradientBoostingClassifier
  from darts import TimeSeries
  from darts.ad.aggregators.and_aggregator import AndAggregator
  from darts.ad.aggregators.ensemble_sklearn_aggregator import EnsembleSklearnAggregator
  from darts.ad.aggregators.or_aggregator import OrAggregator
  from darts.models import MovingAverageFilter
label_desc: Use image node_id 6 for calling the TestADAggregators obj's underlying member method code with example usage: obj.test_OrAggregator() without return types