docstr: Train the detector and detect anomalies from the time series used
  for training.
  
  Parameters
  ----------
  ts: pandas.Series or pandas.DataFrame
      Time series to be used for training and be detected for anomalies.
      If a DataFrame with k columns, it is treated as k independent
      univariate time series, and k univariate detectors will be trained
      and applied to each series independently.
  
  return_list: bool, optional
      Whether to return a list of anomalous events, or a binary series
      indicating normal/anomalous. Default: False.
  
  Returns
  -------
  pandas.Series, pandas.DataFrame, list, or dict
      Detected anomalies.
  
      - If input is a Series and return_list=False, return a Series;
      - If input is a DataFrame and return_list=False, return a
        DataFrame, where each column corresponds a column in input;
      - If input is a Series and return_list=True, return a list of
        events where an event is a pandas Timestamp if it is
        instantaneous or a 2-tuple of pandas Timestamps if it is a closed
        time interval.
      - If input is a DataFrame and return_list=True, return a dict of
        event lists, where each key-value pair corresponds a column in
        input.
docstr_tok: ["Train","the","detector","and","detect","anomalies","from","the","time","series","used","for","training",".","Parameters","--","--","--","--","--","ts",":","pandas.Series","or","pandas.DataFrame","Time","series","to","be","used","for","training","and","be","detected","for","anomalies",".","If","a","DataFrame","with","k","columns",",","it","is","treated","as","k","independent","univariate","time","series",",","and","k","univariate","detectors","will","be","trained","and","applied","to","each","series","independently",".","return_list",":","bool",",","optional","Whether","to","return","a","list","of","anomalous","events",",","or","a","binary","series","indicating","normal\/anomalous",".","Default",":","False",".","Returns","--","--","--","-","pandas.Series",",","pandas.DataFrame",",","list",",","or","dict","Detected","anomalies",".","-","If","input","is","a","Series","and","return_list=False",",","return","a","Series",";","-","If","input","is","a","DataFrame","and","return_list=False",",","return","a","DataFrame",",","where","each","column","corresponds","a","column","in","input",";","-","If","input","is","a","Series","and","return_list=True",",","return","a","list","of","events","where","an","event","is","a","pandas","Timestamp","if","it","is","instantaneous","or","a","2-tuple","of","pandas","Timestamps","if","it","is","a","closed","time","interval",".","-","If","input","is","a","DataFrame","and","return_list=True",",","return","a","dict","of","event","lists",",","where","each","key-value","pair","corresponds","a","column","in","input","."]
code: def fit_predict(
      self,
      ts: Union[pd.Series, pd.DataFrame],
      return_list: bool = False,
  ) -> Union[
      pd.Series,
      pd.DataFrame,
      List[Union[Tuple[pd.Timestamp, pd.Timestamp], pd.Timestamp]],
      Dict[
          str,
          List[Union[Tuple[pd.Timestamp, pd.Timestamp], pd.Timestamp]],
      ],
  ]:
      """Train the detector and detect anomalies from the time series used
      for training.
  
      Parameters
      ----------
      ts: pandas.Series or pandas.DataFrame
          Time series to be used for training and be detected for anomalies.
          If a DataFrame with k columns, it is treated as k independent
          univariate time series, and k univariate detectors will be trained
          and applied to each series independently.
  
      return_list: bool, optional
          Whether to return a list of anomalous events, or a binary series
          indicating normal/anomalous. Default: False.
  
      Returns
      -------
      pandas.Series, pandas.DataFrame, list, or dict
          Detected anomalies.
  
          - If input is a Series and return_list=False, return a Series;
          - If input is a DataFrame and return_list=False, return a
            DataFrame, where each column corresponds a column in input;
          - If input is a Series and return_list=True, return a list of
            events where an event is a pandas Timestamp if it is
            instantaneous or a 2-tuple of pandas Timestamps if it is a closed
            time interval.
          - If input is a DataFrame and return_list=True, return a dict of
            event lists, where each key-value pair corresponds a column in
            input.
  
      """
      self.fit(ts)
      return self.detect(ts, return_list=return_list)
  
imports: from typing import Any, Callable, Dict, List, Tuple, Union
  import pandas
  from ._base import _NonTrainableUnivariateModel, _TrainableMultivariateModel, _TrainableUnivariateModel
  from .data import to_events
  from .metrics import f1_score, iou, precision, recall
label_desc: Use image node_id 3 for calling the _TrainableUnivariateDetector obj's underlying member method code with example usage: obj.fit_predict(ts, return_list) and returns: self