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.fit(y_test, y_pred)
      >>> anomaly_scores = td.score()
      >>> anomaly_indexes = td.anomaly_indexes()
docstr: Fit the model
  
  :param y: the values to detect. shape could be 1-D (num_samples,)
      or 2-D array (num_samples, features)
  :param y_pred: the predicted values, a tensor with same shape as y,
      default to be None.
docstr_tok: ["Fit","the","model",":","param","y",":","the","values","to","detect",".","shape","could","be","1-D","(","num_samples",",",")","or","2-D","array","(","num_samples",",","features",")",":","param","y_pred",":","the","predicted","values",",","a","tensor","with","same","shape","as","y",",","default","to","be","None","."]
code: def fit(self, y, y_pred=None):
      """
      Fit the model
  
      :param y: the values to detect. shape could be 1-D (num_samples,)
          or 2-D array (num_samples, features)
      :param y_pred: the predicted values, a tensor with same shape as y,
          default to be None.
      """
      if (
          not isinstance(self.trend_th[0], np.ndarray)
          and self.trend_th[0] == -math.inf
          and not isinstance(self.trend_th[1], np.ndarray)
          and self.trend_th[1] == math.inf
      ):
          self.trend_th = estimate_trend_th(
              y, mode=self.mode, ratio=self.ratio
          )
      if y_pred is not None and self.pattern_th == math.inf:
          self.pattern_th = estimate_pattern_th(
              y,
              y_pred,
              mode=self.mode,
              ratio=self.ratio,
              dist_measure=self.dist_measure,
          )
      # calculate anomalies in advance in case score does not specify input
      anomalies = detect_anomaly(
          y, y_pred, self.pattern_th, self.trend_th, self.dist_measure
      )
      self.anomaly_indexes_ = anomalies[0]
      self.anomaly_scores_ = anomalies[1]
  
imports: import math
  import numpy
  from bigdl.chronos.detector.anomaly.abstract import AnomalyDetector
  from bigdl.nano.utils.common import invalidInputError
  from abc import ABC, abstractmethod
label_desc: Use image node_id 3 for calling the ThresholdDetector obj's underlying member method code with example usage: obj.fit(y, y_pred) without return types