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 computeBucketsForParameter(
      self, results, parameter, numBuckets=10
  ):
      values = [result[parameter.root[5:]] for result in results]
  
      bottom = numpy.min(values)
      top = numpy.max(values)
      if (top - bottom) < 1e-5:
          top += 1e-5
  
      # Determine the number of possible discrete values for this parameter (in the entire hyperparameter space).
      # If there are less possible discrete values then number of buckets, just return each of them as our buckets.
      if parameter.config.get("rounding", None) is not None:
          paramMin = parameter.config["min"]
          paramMax = parameter.config["max"]
          possibleValues = (
              math.ceil(
                  (paramMax - paramMin) / parameter.config["rounding"]
              )
              + 1
          )
          if possibleValues <= numBuckets:
              discrete = list(
                  numpy.arange(
                      paramMin, paramMax, parameter.config["rounding"]
                  )
              ) + [paramMax]
  
              # Add in one additional bucket on the low end.
              buckets = sorted(list(discrete))
              diff = buckets[1] - buckets[0]
              bottom = bottom - diff
              buckets.insert(0, bottom)
              return buckets
  
      # Count the number of discrete values for this parameter in our results.
      # If there are less discrete values then the number of buckets,
      # then modify the bottom so we consider the lowest discrete value
      # as its own bucket
      discrete = set(values)
      if len(discrete) <= numBuckets:
          # Add in one additional bucket on the low end.
          buckets = sorted(list(discrete))
          if len(buckets) > 1:
              diff = buckets[1] - buckets[0]
              bottom = bottom - diff
          else:
              bottom = buckets[0] - 1.0
  
      buckets = []
      if parameter.config.get("scaling", "linear") == "linear":
          domain = top - bottom
          buckets = [bottom]
          while len(buckets) <= (numBuckets):
              buckets = buckets + [buckets[-1] + (domain / numBuckets)]
      elif parameter.config.get("scaling", "linear") == "logarithmic":
          logMax = math.log(top)
          if bottom > 0:
              logMin = math.log(bottom)
          else:
              logMin = math.log(1e-7)
          domain = logMax - logMin
  
          logBuckets = [logMin]
          while len(logBuckets) <= numBuckets:
              logBuckets = logBuckets + [
                  logBuckets[-1] + (domain / numBuckets)
              ]
          buckets = [math.exp(n) for n in logBuckets]
  
      buckets = [value for value in buckets]
  
      return buckets
  
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 16 for calling the ResultsAnalyzer obj's underlying member method code with example usage: obj.computeBucketsForParameter(results, parameter, numBuckets) and returns: buckets, buckets