code: def test_threshold_single(self):
      sample_num = 10
      feature_dim = 5
      num_anomaly = 5
      # predicted value
      y_pred = np.full((sample_num, feature_dim), 0)
      # actual value
      y_test = np.full(sample_num * feature_dim, 0.2)
  
      gen_rand_indexes = [0, 7, 16, 33, 45]
      y_test[gen_rand_indexes] = 10
      y_test = y_test.reshape((sample_num, feature_dim))
  
      td = ThresholdDetector()
      td.set_params(pattern_threshold=3)
      td.fit(y_test, y_pred)
      anomaly_scores = td.score()["anomaly score"]
      assert len(set(np.where(anomaly_scores > 0)[0])) == num_anomaly
      anomaly_indexes = td.anomaly_indexes()["anomaly index"]
      assert len(anomaly_indexes) == num_anomaly
  
file_path: BigDL/python/chronos/test/bigdl/chronos/detector/anomaly/test_th_detector.py
imports: import pytest
  import numpy
  import pandas
  from unittest import TestCase
  from bigdl.chronos.utils import LazyImport
  from bigdl.chronos.detector.anomaly import ThresholdDetector
  from ...None import op_torch
label_desc: Use image node_id 5 for calling the TestThresholdDetector obj's underlying member method code with example usage: obj.test_threshold_single() without return types