code: def test_fit_score(self):
      look_back = 4
  
      # generate dataframe
      data = self.gen_data(feature_num=6, sample_num=100)
      # split train and test dataframes
      train_df, test_df = self.train_test_split(
          data, test_num=20, look_back=look_back
      )
  
      # roll data to generate model input
      x_train, y_train = self.roll_data(
          dataset=train_df, look_back=look_back, target_col_indexes=[0]
      )
      x_test, y_test = self.roll_data(
          dataset=test_df, look_back=look_back, target_col_indexes=[0]
      )
  
      # create model, train on train data and predict on test
      y_train = np.expand_dims(y_train, 1)
      forecaster = LSTMForecaster(
          past_seq_len=look_back,
          input_feature_num=x_train.shape[-1],
          output_feature_num=1,
          hidden_dim=32,
          layer_num=2,
      )
      forecaster.fit(
          data=(x_train, y_train), batch_size=1024, epochs=50
      )
      y_predict = forecaster.predict(x_test)
      y_predict = np.squeeze(y_predict, axis=1)
  
      # find anomaly using a manual set threshold
      td = ThresholdDetector()
      td.set_params(threshold=10)
      td.fit(y_test, y_predict)
      anomaly_scores = td.score()
      assert len(list(np.where(anomaly_scores > 0)[0])) == 0
      anomaly_indexes = td.anomaly_indexes()
      assert len(anomaly_indexes) == 0
  
      # if threshold is not provided, ThresholdDetector can fit to the data
      ratio = 0.1
      td = ThresholdDetector()
      td.set_params(ratio=ratio)
      td.fit(y_test, y_predict)
      fitted_anomaly_indexes = td.anomaly_indexes()
      assert len(fitted_anomaly_indexes) == int(ratio * y_test.shape[0])
  
file_path: analytics-zoo/pyzoo/test/zoo/chronos/detector/anomaly/test_th_detector.py
imports: import pytest
  import numpy
  import pandas
  from test.zoo.pipeline.utils.test_utils import ZooTestCase
  from zoo.chronos.forecaster.lstm_forecaster import LSTMForecaster
  from zoo.chronos.detector.anomaly import ThresholdDetector
label_desc: Use image node_id 6 for calling the TestThresholdDetector obj's underlying member method code with example usage: obj.test_fit_score() without return types