docstr: Detect anomalies and score the results against true anomalies.
  
  Parameters
  ----------
  ts: pandas Series or pandas.DataFrame
      Time series to detect anomalies from.
      If a DataFrame with k columns, it is treated as k independent
      univariate time series, and the detector will be applied to each
      series independently.
  
  anomaly_true: pandas.Series, pandas.DataFrame, list, or dict
      True anomalies.
  
      - If pandas Series, it is treated as a series of binary labels.
      - If pandas DataFrame, each column is a binary series and is
        treated as an independent type of anomaly.
      - If list, 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 dict, each key-value pair is a list of events and is treated
        as an independent type of anomaly.
  
  scoring: str, optional
      Scoring function to use. Must be one of "recall", "precision",
      "f1", and "iou". See module `metrics` for more information.
      Default: "recall"
  
  **kwargs
      Optional parameters for scoring function. See module `metrics` for
      more information.
  
  Returns
  -------
  float or dict
      Score(s) for each type of anomaly.
docstr_tok: ["Detect","anomalies","and","score","the","results","against","true","anomalies",".","Parameters","--","--","--","--","--","ts",":","pandas","Series","or","pandas.DataFrame","Time","series","to","detect","anomalies","from",".","If","a","DataFrame","with","k","columns",",","it","is","treated","as","k","independent","univariate","time","series",",","and","the","detector","will","be","applied","to","each","series","independently",".","anomaly_true",":","pandas.Series",",","pandas.DataFrame",",","list",",","or","dict","True","anomalies",".","-","If","pandas","Series",",","it","is","treated","as","a","series","of","binary","labels",".","-","If","pandas","DataFrame",",","each","column","is","a","binary","series","and","is","treated","as","an","independent","type","of","anomaly",".","-","If","list",",","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","dict",",","each","key-value","pair","is","a","list","of","events","and","is","treated","as","an","independent","type","of","anomaly",".","scoring",":","str",",","optional","Scoring","function","to","use",".","Must","be","one","of","``","recall","''",",","``","precision","''",",","``","f1","''",",","and","``","iou","''",".","See","module","`","metrics","`","for","more","information",".","Default",":","``","recall","''","*","*","kwargs","Optional","parameters","for","scoring","function",".","See","module","`","metrics","`","for","more","information",".","Returns","--","--","--","-","float","or","dict","Score","(","s",")","for","each","type","of","anomaly","."]
code: def score(
      self,
      ts: Union[pd.Series, pd.DataFrame],
      anomaly_true: 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]
              ],
          ],
      ],
      scoring: str = "recall",
      **kwargs: Any,
  ) -> Union[float, Dict[str, float]]:
      """Detect anomalies and score the results against true anomalies.
  
      Parameters
      ----------
      ts: pandas Series or pandas.DataFrame
          Time series to detect anomalies from.
          If a DataFrame with k columns, it is treated as k independent
          univariate time series, and the detector will be applied to each
          series independently.
  
      anomaly_true: pandas.Series, pandas.DataFrame, list, or dict
          True anomalies.
  
          - If pandas Series, it is treated as a series of binary labels.
          - If pandas DataFrame, each column is a binary series and is
            treated as an independent type of anomaly.
          - If list, 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 dict, each key-value pair is a list of events and is treated
            as an independent type of anomaly.
  
      scoring: str, optional
          Scoring function to use. Must be one of "recall", "precision",
          "f1", and "iou". See module `metrics` for more information.
          Default: "recall"
  
      **kwargs
          Optional parameters for scoring function. See module `metrics` for
          more information.
  
      Returns
      -------
      float or dict
          Score(s) for each type of anomaly.
  
      """
      if scoring == "recall":
          scoring_func = recall  # type: Callable
      elif scoring == "precision":
          scoring_func = precision
      elif scoring == "f1":
          scoring_func = f1_score
      elif scoring == "iou":
          scoring_func = iou
      else:
          raise ValueError(
              "Argument `scoring` must be one of 'recall', 'precision', "
              "'f1' and 'iou'."
          )
      if isinstance(anomaly_true, (pd.Series, pd.DataFrame)):
          return scoring_func(
              y_true=anomaly_true,
              y_pred=self.detect(ts, return_list=False),
              **kwargs,
          )
      else:
          return scoring_func(
              y_true=anomaly_true,
              y_pred=self.detect(ts, return_list=True),
              **kwargs,
          )
  
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 2 for calling the _NonTrainableUnivariateDetector obj's underlying member method code with example usage: obj.score(ts, anomaly_true, scoring) and returns: scoring_func, scoring_func