code: def aggregate(cls, df):
      thresholds = np.linspace(1, 0, 10)
      df_out = pd.DataFrame(
          index=range(len(thresholds)),
          columns=(
              "thresholds",
              "tp",
              "fp",
              "tn",
              "fn",
              "acc",
              "sens",
              "spec",
          ),
      )
      df_out.thresholds = thresholds
      for it in range(len(thresholds)):
          df_out.loc[it, "tp"] = (
              df[df.roc_auc_l == 1].roc_auc_i > thresholds[it]
          ).sum()
          df_out.loc[it, "fp"] = (
              df[df.roc_auc_l == 0].roc_auc_i > thresholds[it]
          ).sum()
          df_out.loc[it, "tn"] = (
              df[df.roc_auc_l == 0].roc_auc_i <= thresholds[it]
          ).sum()
          df_out.loc[it, "fn"] = (
              df[df.roc_auc_l == 1].roc_auc_i <= thresholds[it]
          ).sum()
      df_out.acc = (df_out.tp + df_out.tn) / (
          df_out.tp + df_out.tn + df_out.fp + df_out.fn
      )
      denom = df_out.tp + df_out.fn
      df_out.loc[denom > 0, "sens"] = (
          df_out.loc[denom > 0, "tp"] / denom[denom > 0]
      )
      denom = df_out.tn + df_out.fp
      df_out.loc[denom > 0, "spec"] = (
          df_out.loc[denom > 0, "tn"] / denom[denom > 0]
      )
      by_threshold = df_out.set_index("thresholds")
  
      tpr = np.array(list(by_threshold.sens))
      fpr = np.array(1 - by_threshold.spec)
      roc_auc = np.sum((tpr[:-1] + tpr[1:]) * (fpr[1:] - fpr[:-1]) / 2)
      return [pd.DataFrame.from_records([{"roc_auc": roc_auc}])]
  
file_path: NiftyNet/niftynet/contrib/evaluation/classification_evaluations.py
imports: from __future__ import absolute_import, division, print_function
  import numpy
  import pandas
  from niftynet.evaluation.base_evaluations import BaseEvaluation
  from niftynet.evaluation.base_evaluator import ScalarAggregator, DataFrameAggregator
label_desc: Use image node_id 2 for calling the roc_auc obj's underlying member method code with example usage: obj.aggregate(cls, df) and returns: list