docstr: converts the metrics saved in the object to a table that is ready to render in the report.
  
  Args:
      label_as_row (bool): True if each row of the output table is for a class,
                           False if each row of the output table is for a metric
  
  Returns:
      a set of table (title, header, values)
docstr_tok: ["converts","the","metrics","saved","in","the","object","to","a","table","that","is","ready","to","render","in","the","report",".","Args",":","label_as_row","(","bool",")",":","True","if","each","row","of","the","output","table","is","for","a","class",",","False","if","each","row","of","the","output","table","is","for","a","metric","Returns",":","a","set","of","table","(","title",",","header",",","values",")"]
code: def convert_metrics_to_table(self, label_as_row=True):
      """
      converts the metrics saved in the object to a table that is ready to render in the report.
  
      Args:
          label_as_row (bool): True if each row of the output table is for a class,
                               False if each row of the output table is for a metric
  
      Returns:
          a set of table (title, header, values)
      """
      if label_as_row:
          # set metric as columns, label as rows
          table_header = ["Label"]
          table_header.extend([metric for metric in self.metric_set])
  
          table_content = []
          for label in self.label_set:
              row = [label]
              row.extend(
                  [
                      "{:.4f}".format(self.resultdict[metric][label])
                      if type(self.resultdict[metric][label]) == float
                      else "nan"
                      for metric in self.metric_set
                  ]
              )
              table_content.append(row)
      else:
          # set label as columns, metric as rows
          table_header = ["Metric"]
          table_header.extend([label for label in self.label_set])
  
          table_content = []
          for metric in self.metric_set:
              row = [metric]
              row.extend(
                  [
                      "{:.4f}".format(self.resultdict[metric][label])
                      for label in self.label_set
                  ]
              )
              table_content.append(row)
  
      # add in average result if any[
      if table_header[0] == "Label":
          row = ["Average"]
          row.extend(
              [
                  "{:.4f}".format(self.average_result_dict[metric])
                  if type(self.average_result_dict[metric]) != str
                  else self.average_result_dict[metric]
                  for metric in self.metric_set
              ]
          )
          table_content.append(row)
      elif table_header[0] == "Metric":
          table_header.append("Average")
          for row in table_content:
              metric = row[0]
              if type(self.average_result_dict[metric]) != str:
                  row.append(
                      "{:.4f}".format(self.average_result_dict[metric])
                  )
              else:
                  row.append(self.average_result_dict[metric])
      layout = get_table_layout(table_header)
      table = ("Metric Result", table_header, table_content, layout)
  
      return table
  
file_path: contextual-ai/xai/model/evaluation/multi_classification_result.py
imports: from collections import defaultdict
  from xai import constants
  from xai.model.evaluation.basic_result import ClassificationResult
  from xai.model.evaluation.confusion_matrix import ConfusionMatrix
  from xai.util import get_table_layout
label_desc: Use image node_id 3 for calling the MultiClassificationResult obj's underlying member method code with example usage: obj.convert_metrics_to_table(label_as_row) and returns: table