class_docstr: This class is responsible for analyzing the results and outputting various types of analysis to the results folder.
class_docstr_tok: ["This","class","is","responsible","for","analyzing","the","results","and","outputting","various","types","of","analysis","to","the","results","folder","."]
code: def exportLossMatrixToImage(
      self,
      fileName,
      results,
      parameter1,
      parameter2,
      valueKey="loss",
      title="Loss Matrix",
      cutoff=1.0,
      mode="global",
      reduction="min",
  ):
      (
          scores,
          parameter1Buckets,
          parameter2Buckets,
      ) = self.computeLossMatrix(
          results,
          parameter1,
          parameter2,
          valueKey,
          cutoff=cutoff,
          reduction=reduction,
      )
  
      minVal = float(numpy.min(scores))
      maxVal = float(numpy.max(scores))
      redVal = float(numpy.percentile(scores, q=90))
      yellowVal = float(numpy.percentile(scores, q=40))
      greenVal = float(numpy.percentile(scores, q=20))
      blueVal = float(numpy.percentile(scores, q=5))
  
      if mode == "global":
          if (maxVal - minVal) > 0:
              redVal = (redVal - minVal) / (maxVal - minVal)
              yellowVal = (yellowVal - minVal) / (maxVal - minVal)
              greenVal = (greenVal - minVal) / (maxVal - minVal)
              blueVal = (blueVal - minVal) / (maxVal - minVal)
          else:
              redVal = 0.9
              yellowVal = 0.6
              greenVal = 0.3
              blueVal = 0.1
      elif mode == "response":
          redVal = 0.9
          yellowVal = 0.6
          greenVal = 0.3
          blueVal = 0.1
  
      green = numpy.array([0, 1, 0])
      yellow = numpy.array([1, 1, 0])
      red = numpy.array([1, 0, 0])
      blue = numpy.array([0.3, 0.3, 1])
  
      colorGrid = []
      for row in scores:
          if mode == "global":
              colorRow = []
              for score in row:
                  colorRow.append(score)
              colorGrid.append(colorRow)
          else:
              rowMinVal = float(numpy.min(row))
              rowMaxVal = float(numpy.max(row))
  
              if rowMaxVal == rowMinVal:
                  colorRow = [0.5] * len(row)
                  colorGrid.append(colorRow)
              else:
                  sortedRow = sorted(row)
  
                  colorRow = []
                  for score in row:
                      colorRow.append(
                          float(sortedRow.index(score)) / len(row)
                      )
                  colorGrid.append(colorRow)
  
      if self.twoParameterLossFigure is None:
          fig, ax = plt.subplots()
          self.twoParameterLossFigure = fig
          self.twoParameterLossAxes = ax
      else:
          fig = self.twoParameterLossFigure
          ax = self.twoParameterLossAxes
          ax.clear()
  
      colorList = [
          (0, blue),
          (blueVal, blue),
          (greenVal, green),
          (yellowVal, yellow),
          (redVal, red),
          (1.0, red),
      ]
  
      im = ax.imshow(
          colorGrid,
          cmap=matplotlib.colors.LinearSegmentedColormap.from_list(
              "loss_matrix", colorList, N=50000
          ),
          interpolation="quadric",
      )
  
      # We want to show all ticks...
      ax.set_xticks(numpy.arange(len(parameter1Buckets)) - 0.5)
      ax.set_yticks(numpy.arange(len(parameter2Buckets)) - 0.5)
      #
      # if parameter1.root[5:] == 'layer_0.max_depth':
      #     print(parameter1Buckets)
      #     print(parameter2Buckets)
  
      # ... and label them with the respective list entries
      ax.set_xticklabels(
          [roundPrecision(bucket) for bucket in parameter1Buckets]
      )
      ax.set_yticklabels(
          [roundPrecision(bucket) for bucket in parameter2Buckets]
      )
  
      ax.set_xlabel(parameter1.root[5:])
      ax.set_ylabel(parameter2.root[5:])
  
      # Rotate the tick labels and set their alignment.
      # ax.setp(ax.get_xticklabels(), rotation=45, ha="right", rotation_mode="anchor")
  
      # Function which formats the text for display in each cell of heatmap
      def getText(i, j):
          cellText = str(roundPrecision(scores[i][j], 2))
          if cellText[:2] == "0.":
              cellText = cellText[1:]  # Eliminate the 0 from 0.xx
          return cellText
  
      # Determine the longest string we have to put into the heatmap
      longest = 0
      for j in range(len(parameter1Buckets[1:])):
          for i in range(len(parameter2Buckets[1:])):
              longest = max(len(getText(i, j)), longest)
  
      # Loop over data dimensions and create text annotations.
      fontSize = int(12 - max(0, 1.25 * (longest - 3)))
      for j in range(len(parameter1Buckets[1:])):
          for i in range(len(parameter2Buckets[1:])):
              ax.text(
                  j,
                  i,
                  getText(i, j),
                  ha="center",
                  va="center",
                  color="black",
                  fontsize=fontSize,
              )
  
      ax.set_title(
          title
          + " of "
          + parameter1.root[5:]
          + " vs "
          + parameter2.root[5:],
          fontdict={"fontsize": 10},
      )
      fig.set_tight_layout(True)
      fig.savefig(fileName, dpi=200)
      plt.close(fig)
  
imports: import jsonschema
  import os
  import os.path
  import math
  import csv
  from hypermax.hyperparameter import Hyperparameter
  import sklearn.covariance
  import numpy
  from hypermax.utils import roundPrecision
  import matplotlib
  import matplotlib.cm
  import matplotlib.style
  import matplotlib.pyplot
  from pprint import pprint
  import concurrent.futures
  import colors
  import traceback
  import functools
  import warnings
  import scipy.optimize
  import random
  import json
  import atexit
  import matplotlib.ticker
  import traceback
  import copy
label_desc: Use image node_id 11 for calling the ResultsAnalyzer obj's underlying member method code with example usage: obj.exportLossMatrixToImage(fileName, results, parameter1, parameter2, valueKey, title, cutoff, mode, reduction) and returns: cellText