code: def compare(ytest, test_pred):
      ytest = np.array(ytest)
      test_pred = np.array(test_pred)
      METRICS = [
          "mae",
          "rmse",
          "pearson",
          "spearman",
          "kendalltau",
          "kt_2dec",
          "kt_1dec",
          "precision_10",
          "precision_20",
          "full_ytest",
          "full_testpred",
      ]
      metrics_dict = {}
  
      try:
          metrics_dict["mae"] = np.mean(abs(test_pred - ytest))
          metrics_dict["rmse"] = metrics.mean_squared_error(
              ytest, test_pred, squared=False
          )
          metrics_dict["pearson"] = np.abs(
              np.corrcoef(ytest, test_pred)[1, 0]
          )
          metrics_dict["spearman"] = stats.spearmanr(ytest, test_pred)[
              0
          ]
          metrics_dict["kendalltau"] = stats.kendalltau(
              ytest, test_pred
          )[0]
          metrics_dict["kt_2dec"] = stats.kendalltau(
              ytest, np.round(test_pred, decimals=2)
          )[0]
          metrics_dict["kt_1dec"] = stats.kendalltau(
              ytest, np.round(test_pred, decimals=1)
          )[0]
          print("ytest = ", ytest)
          print("test_pred = ", test_pred)
          for k in [10, 20]:
              top_ytest = np.array(
                  [
                      y > sorted(ytest)[max(-len(ytest), -k - 1)]
                      for y in ytest
                  ]
              )
              top_test_pred = np.array(
                  [
                      y
                      > sorted(test_pred)[max(-len(test_pred), -k - 1)]
                      for y in test_pred
                  ]
              )
              metrics_dict["precision_{}".format(k)] = (
                  sum(top_ytest & top_test_pred) / k
              )
          metrics_dict["full_ytest"] = ytest.tolist()
          metrics_dict["full_testpred"] = test_pred.tolist()
  
      except:
          for metric in METRICS:
              metrics_dict[metric] = float("nan")
      if np.isnan(metrics_dict["pearson"]) or not np.isfinite(
          metrics_dict["pearson"]
      ):
          logger.info(
              "Error when computing metrics. ytest and test_pred are:"
          )
          logger.info(ytest)
          logger.info(test_pred)
  
      return metrics_dict
  
file_path: singa/examples/model_selection/TRAILS-Database-Native-Model-Selection/internal/ml/model_selection/src/tools/correlation.py
imports: from scipy import stats
  from src.common.constant import CommonVars
  import numpy
  from src.logger import logger
  from sklearn import metrics
label_desc: Use image node_id 2 for calling the CorCoefficient obj's underlying member method code with example usage: obj.compare(ytest, test_pred) and returns: metrics_dict