class_docstr: Example:
      >>> #The dataset is split into x_train, x_test, y_train, y_test
      >>> forecaster = Forecaster(...)
      >>> forecaster.fit(x=x_train, y=y_train, ...)
      >>> y_pred = forecaster.predict(x_test)
      >>> td = ThresholdDetector()
      >>> td.set_params(threshold=10)
      >>> td.fit(y_test, y_pred)
      >>> anomaly_scores = td.score()
      >>> anomaly_indexes = td.anomaly_indexes()
docstr: Gets the anomaly scores for each sample. Each anomaly score is either 0 or 1,
  where 1 indicates an anomaly.
  
  :param y: new time series to detect anomaly. if y is None, returns anomalies
      in the fit input, y_pred is ignored in this case
  :param y_pred: forecasts corresponding to y
  
  :return: anomaly score for each sample, in an array format with the same size as input
docstr_tok: ["Gets","the","anomaly","scores","for","each","sample",".","Each","anomaly","score","is","either","0","or","1",",","where","1","indicates","an","anomaly",".",":","param","y",":","new","time","series","to","detect","anomaly",".","if","y","is","None",",","returns","anomalies","in","the","fit","input",",","y_pred","is","ignored","in","this","case",":","param","y_pred",":","forecasts","corresponding","to","y",":","return",":","anomaly","score","for","each","sample",",","in","an","array","format","with","the","same","size","as","input"]
code: def score(self, y=None, y_pred=None):
      """
      Gets the anomaly scores for each sample. Each anomaly score is either 0 or 1,
      where 1 indicates an anomaly.
  
      :param y: new time series to detect anomaly. if y is None, returns anomalies
          in the fit input, y_pred is ignored in this case
      :param y_pred: forecasts corresponding to y
  
      :return: anomaly score for each sample, in an array format with the same size as input
      """
      if y is None:
          if self.anomaly_scores_ is None:
              raise RuntimeError("please call fit before calling score")
          return self.anomaly_scores_
      else:
          return detect_anomaly(y, y_pred, self.th, self.dist_measure)[
              1
          ]
  
imports: import math
  import numpy
  from zoo.chronos.detector.anomaly.abstract import AnomalyDetector
  from abc import ABC, abstractmethod
label_desc: Use image node_id 4 for calling the ThresholdDetector obj's underlying member method code with example usage: obj.score(y, y_pred) and returns: self, detect_anomaly