code: def metrics_plot(
      target: np.ndarray,
      predicted: np.ndarray,
      df: pd.DataFrame = pd.DataFrame(),
      cross_cols: List[str] = [],
      categorical_cols: List[str] = [],
      bins: int = 6,
      plot: bool = True,
      exclude_metrics: List[str] = [],
      plot_threshold: float = 0.5,
  ) -> pd.DataFrame:
      """
      Creates a plot that displays statistical metrics including precision,
      recall, accuracy, auc, f1 and specificity for each of the groups created
      for the columns provided by cross_cols. For example, if the columns passed
      are "gender" and "age", the resulting plot will show the statistical metrics
      for Male and Female for each binned group.
  
      Example
      ---------
  
      .. code-block:: python
  
          target: np.ndarray
          predicted: np.ndarray
  
          df_metrics = xai.metrics_plot(
                          target,
                          predicted,
                          df=df_data,
                          cross_cols=["gender", "age"],
                          bins=3
  
      Args
      -------
  
      target:
          Numpy array containing the target labels for the datapoints
      predicted :
          Numpy array containing the predicted labels for the datapoints
      df :
          Pandas dataframe containing all the features for the datapoints.
          It can be empty if only looking to calculate global metrics, but
          if you would like to compute for categories across columns, the
          columns you are grouping by need to be provided
      cross_cols :
          Contains the columns that you would like to use to cross the values
      bins :
          [Default: 6] The number of bins in which you'd like
          numerical columns to be split
      plot :
          [Default: True] If True a plot will be drawn with the results
      exclude_metrics :
          These are the metrics that you can choose to exclude if you only
          want specific ones (for example, excluding "f1", "specificity", etc)
      plot_threshold:
          The percentage that will be used to draw the threshold line in the plot
          which would provide guidance on what is the ideal metrics to achieve.
  
      Returns
      ----------
  
      : pd.DataFrame
          Pandas Dataframe containing all the metrics for the groups provided
  
      """
  
      grouped = _group_metrics(
          target,
          predicted,
          df,
          cross_cols,
          categorical_cols,
          bins,
          target_threshold=plot_threshold,
      )
  
      prfs = []
      classes = []
      for group, group_df in grouped:
          group_valid = group_df["target"].values
          group_pred = group_df["predicted"].values
          metrics_dict = evaluation_metrics(group_valid, group_pred)
          # Remove metrics as specified by params
          [metrics_dict.pop(k, None) for k in exclude_metrics]
          prfs.append(list(metrics_dict.values()))
          classes.append(str(group))
  
      prfs_cols = metrics_dict.keys()
      prfs_df = pd.DataFrame(
          np.array(prfs).transpose(), columns=classes, index=prfs_cols
      )
  
      if plot:
          prfs_df.plot.bar(figsize=(20, 5))
          lp = plt.axhline(0.5, color="r")
          lp = plt.axhline(1, color="g")
  
      return prfs_df
  
imports: import pandas
  import matplotlib.pyplot
  import numpy
  from scipy.stats import spearmanr
  from scipy.cluster import hierarchy
  from typing import List, Any, Union, Tuple, Optional, Dict
  import random, math
  from sklearn.metrics import roc_curve, precision_recall_curve, roc_auc_score, confusion_matrix
  import itertools
  import logging
label_desc: Use image node_id 13 for calling a global function with example usage: metrics_plot(target, predicted, df, cross_cols, categorical_cols, bins, plot, exclude_metrics, plot_threshold) and returns: prfs_df