class_docstr: The surrogate analyzer evaluates the performance of a surrogate model with
  respect to ranking and regression metrics.
  
  The analysis is run in parallel and should, thus, not be used in a Jupyter
  notebook. Instead, consider using the `tsbench` CLI.
code: def _score(
      self, y_pred: List[Performance], y_true: List[Performance]
  ) -> pd.DataFrame:
      df_pred = Performance.to_dataframe(y_pred)
      df_true = Performance.to_dataframe(y_true)
  
      if self.metrics is not None:
          df_pred = df_pred[self.metrics]
          df_true = df_true[self.metrics]
  
      # We extract the NumPy arrays so that indexing is easier. Each metric is computed such that
      # it results in an array of shape [D] where D is the number of metrics.
      columns = df_pred.columns
      y_pred_min = df_pred.to_numpy()  # type: ignore
      y_true_min = df_true.to_numpy()  # type: ignore
  
      # Return all results
      metrics = {
          "nrmse": nrmse(y_pred_min, y_true_min),
          "smape": smape(y_pred_min, y_true_min),
          "mrr": mrr(y_pred_min, y_true_min),
          **{
              f"precision_{k}": precision_k(k, y_pred_min, y_true_min)
              for k in (5, 10, 20)
          },
          "ndcg": ndcg(y_pred_min, y_true_min),
      }
      column_index = pd.MultiIndex.from_tuples(
          [(c, m) for m in sorted(metrics) for c in columns]
      )
      values = np.concatenate([metrics[m] for m in sorted(metrics)])
      return pd.DataFrame(
          np.reshape(values, (1, -1)), columns=column_index
      )
  
file_path: gluonts/src/gluonts/nursery/tsbench/src/tsbench/analysis/surrogate/analyzer.py
imports: from typing import List, Optional, Tuple
  import numpy
  import pandas
  from tqdm.auto import tqdm
  from tsbench.analysis.utils import loocv_split, num_fitting_processes, run_parallel
  from tsbench.config import Config, ModelConfig
  from tsbench.evaluations.metrics import Performance
  from tsbench.evaluations.tracking import ModelTracker
  from tsbench.surrogate import AutoGluonSurrogate, Surrogate
  from .metrics import mrr, ndcg, nrmse, precision_k, smape
label_desc: Use image node_id 4 for calling the SurrogateAnalyzer obj's underlying member method code with example usage: obj._score(y_pred, y_true) and returns: pd