code: def precision(
      y_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]
              ],
          ],
      ],
      y_pred: 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]
              ],
          ],
      ],
      thresh: float = 0.5,
  ) -> Union[float, Dict[str, float]]:
      """Precision score of prediction.
  
      Precision, a.k.a. positive predictive value (PPV), is the percentage of
      predicted anomalies that are true anomalies.
  
      When the input is anomaly labels, metric calculation treats every time
      point with positive label as an independent event. An anomalous time point
      that are detected as anomalous is considered as a successful detection.
  
      When the input is lists of anomalous time windows, metric calculation
      treats every anomalous time window as an independent event. A detected
      event is considered as a successfully detection if the percentage of this
      time window covered by the true anomaly list is greater or equal to
      `thresh`. Note that input time windows will be merged first if overlapped
      time windows exists in the list.
  
      Parameters
      ----------
      y_true: pandas Series or DataFrame, list, or dict
          Labels or lists of true anomalies.
  
          - If pandas Series, it is treated as binary labels along time index.
          - 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.
  
      y_pred: pandas Series or DataFrame, list, or dict
          Labels or lists of predicted anomalies.
  
          - If pandas Series, it is treated as binary labels along time index.
          - 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.
  
      thresh: float, optional
          Threshold of a hit. Only used if input is list or dict. Default: 0.5.
  
      Returns
      -------
      float or dict
          Score(s) for each type of anomaly.
  
      """
      return recall(y_pred, y_true, thresh=thresh)
  
imports: from typing import Dict, List, Tuple, Union, overload
  import pandas
  from ..aggregator import AndAggregator, OrAggregator
  from ..data import validate_events
label_desc: Use image node_id 10 for calling a global function with example usage: precision(y_true, y_pred, thresh) and returns: recall