code: def computePartialResultStatistics(
      self, hyperparameterSpace, results
  ):
      losses = numpy.array(
          sorted(
              [
                  result["loss"]
                  for result in results
                  if result["loss"] is not None
              ]
          )
      )
  
      bestLoss = 0
      percentile5Loss = 0
      percentile25Loss = 0
      percentile50Loss = 0
      percentile75Loss = 0
      statistics = {}
  
      numpy.warnings.filterwarnings("ignore")
  
      if len(set(losses)) > 1:
          bestLoss = numpy.percentile(losses, 0)
          percentile5Loss = numpy.percentile(losses, 5)
          percentile25Loss = numpy.percentile(losses, 25)
          percentile50Loss = numpy.percentile(losses, 50)
          percentile75Loss = numpy.percentile(losses, 75)
  
          statistics["loss_skew"] = scipy.stats.skew(losses)
          statistics["loss_kurtosis"] = scipy.stats.kurtosis(losses)
      else:
          statistics["loss_skew"] = 0
          statistics["loss_kurtosis"] = 0
  
      if percentile50Loss == 0:
          statistics["loss_stddev_median_ratio"] = 0
          statistics["loss_best_percentile50_ratio"] = 0
      else:
          statistics["loss_stddev_median_ratio"] = (
              numpy.std(losses) / percentile50Loss
          )
          statistics["loss_best_percentile50_ratio"] = (
              bestLoss / percentile50Loss
          )
  
      if bestLoss == 0:
          statistics["loss_stddev_best_ratio"] = 0
      else:
          statistics["loss_stddev_best_ratio"] = (
              numpy.std(losses) / bestLoss
          )
  
      if percentile25Loss == 0:
          statistics["loss_best_percentile25_ratio"] = 0
          statistics["loss_percentile5_percentile25_ratio"] = 0
      else:
          statistics["loss_best_percentile25_ratio"] = (
              bestLoss / percentile25Loss
          )
          statistics["loss_percentile5_percentile25_ratio"] = (
              percentile5Loss / percentile25Loss
          )
  
      if percentile75Loss == 0:
          statistics["loss_best_percentile75_ratio"] = 0
      else:
          statistics["loss_best_percentile75_ratio"] = (
              bestLoss / percentile75Loss
          )
  
      def getValue(result, parameter):
          return result[parameter.name]
  
      # Now we compute correlations between each parameter and the loss
      parameters = Hyperparameter(
          hyperparameterSpace
      ).getFlatParameters()
      correlations = []
      for parameter in parameters:
          if parameter.config["type"] == "number":
              if (
                  len(
                      set(
                          getValue(result, parameter)
                          for result in results
                          if (
                              getValue(result, parameter) is not None
                              and result["loss"] is not None
                          )
                      )
                  )
                  < 2
              ):
                  correlations.append(0)
              else:
                  values = []
                  valueLosses = []
                  for result in results:
                      if result["loss"] is not None and (
                          isinstance(getValue(result, parameter), float)
                          or isinstance(
                              getValue(result, parameter), int
                          )
                      ):
                          values.append(getValue(result, parameter))
                          valueLosses.append(result["loss"])
  
                  correlation = abs(
                      scipy.stats.spearmanr(values, valueLosses)[0]
                  )
                  if math.isnan(correlation) or math.isinf(correlation):
                      correlations.append(0)
                  else:
                      correlations.append(correlation)
  
      correlations = numpy.array(correlations)
  
      if len(set(correlations)) == 1:
          statistics["correlation_skew"] = 0
          statistics["correlation_kurtosis"] = 0
          statistics["correlation_stddev_median_ratio"] = 0
          statistics["correlation_stddev_best_ratio"] = 0
  
          statistics["correlation_best_percentile25_ratio"] = 0
          statistics["correlation_best_percentile50_ratio"] = 0
          statistics["correlation_best_percentile75_ratio"] = 0
          statistics["correlation_percentile5_percentile25_ratio"] = 0
      else:
          bestCorrelation = numpy.percentile(
              correlations, 100
          )  # Correlations are in the opposite order of losses, higher correlation is considered "best"
          percentile5Correlation = numpy.percentile(correlations, 95)
          percentile25Correlation = numpy.percentile(correlations, 75)
          percentile50Correlation = numpy.percentile(correlations, 50)
          percentile75Correlation = numpy.percentile(correlations, 25)
  
          statistics["correlation_skew"] = scipy.stats.skew(
              correlations
          )
          statistics["correlation_kurtosis"] = scipy.stats.kurtosis(
              correlations
          )
  
          if percentile50Correlation == 0:
              statistics["correlation_stddev_median_ratio"] = 0
              statistics["correlation_best_percentile50_ratio"] = 0
          else:
              statistics["correlation_stddev_median_ratio"] = (
                  numpy.std(correlations) / percentile50Correlation
              )
              statistics["correlation_best_percentile50_ratio"] = (
                  bestCorrelation / percentile50Correlation
              )
  
          if bestCorrelation == 0:
              statistics["correlation_stddev_best_ratio"] = 0
          else:
              statistics["correlation_stddev_best_ratio"] = (
                  numpy.std(correlations) / bestCorrelation
              )
  
          if percentile25Correlation == 0:
              statistics["correlation_best_percentile25_ratio"] = 0
              statistics[
                  "correlation_percentile5_percentile25_ratio"
              ] = 0
          else:
              statistics["correlation_best_percentile25_ratio"] = (
                  bestCorrelation / percentile25Correlation
              )
              statistics[
                  "correlation_percentile5_percentile25_ratio"
              ] = (percentile5Correlation / percentile25Correlation)
  
          if percentile75Correlation == 0:
              statistics["correlation_best_percentile75_ratio"] = 0
          else:
              statistics["correlation_best_percentile75_ratio"] = (
                  bestCorrelation / percentile75Correlation
              )
  
      return statistics
  
imports: from .optimization_algorithm_base import OptimizationAlgorithmBase
  import hyperopt
  import functools
  import random
  import numpy
  import numpy.random
  import json
  import pkg_resources
  from hypermax.hyperparameter import Hyperparameter
  import sklearn
  import lightgbm
  import scipy.stats
  import math
  from pprint import pprint
  import copy
  import hypermax.file_utils
label_desc: Use image node_id 4 for calling the ATPEOptimizer obj's underlying member method code with example usage: obj.computePartialResultStatistics(hyperparameterSpace, results) and returns: statistics, result