class_docstr: Takes another algorithm and repeats every hyperparameter configuration a
  given number of times. The wrapped algorithm will be passed the mean
  objective values of the repeated experiments.
  
  Args:
      algorithm (sherpa.algorithms.Algorithm): the algorithm to produce
          hyperparameter configurations.
      num_times (int): the number of times to repeat each configuration.
      wait_for_completion (bool): only relevant when running in parallel with
          max_concurrent > 1. Means that the algorithm won't issue the next
          suggestion until all repetitions are completed. This can be useful
          when the repeats have impact on sequential decision making in the
          wrapped algorithm.
      agg (bool): whether to aggregate repetitions before passing them to the
          parameter generating algorithm.
class_docstr_tok: ["Takes","another","algorithm","and","repeats","every","hyperparameter","configuration","a","given","number","of","times",".","The","wrapped","algorithm","will","be","passed","the","mean","objective","values","of","the","repeated","experiments",".","Args",":","algorithm","(","sherpa.algorithms.Algorithm",")",":","the","algorithm","to","produce","hyperparameter","configurations",".","num_times","(","int",")",":","the","number","of","times","to","repeat","each","configuration",".","wait_for_completion","(","bool",")",":","only","relevant","when","running","in","parallel","with","max_concurrent",">","1",".","Means","that","the","algorithm","wo","n't","issue","the","next","suggestion","until","all","repetitions","are","completed",".","This","can","be","useful","when","the","repeats","have","impact","on","sequential","decision","making","in","the","wrapped","algorithm",".","agg","(","bool",")",":","whether","to","aggregate","repetitions","before","passing","them","to","the","parameter","generating","algorithm","."]
docstr: A helper function to aggregate results for repeated trials.
  
  Groups results by parameter values and computes mean and standard error of
  the mean. The returned dataframe's Objective column is the mean within
  groups. The standard error is denoted ObjectiveStdErr.
  
  # Arguments:
      results (pandas.Dataframe): the results dataframe.
      min_count (int): the minimum count within groups. Groups with fewer
          observations than min_count are excluded from the results.
  
  # Returns:
      pandas.Dataframe: the aggregated dataframe.
docstr_tok: ["A","helper","function","to","aggregate","results","for","repeated","trials",".","Groups","results","by","parameter","values","and","computes","mean","and","standard","error","of","the","mean",".","The","returned","dataframe","'s","Objective","column","is","the","mean","within","groups",".","The","standard","error","is","denoted","ObjectiveStdErr",".","#","Arguments",":","results","(","pandas.Dataframe",")",":","the","results","dataframe",".","min_count","(","int",")",":","the","minimum","count","within","groups",".","Groups","with","fewer","observations","than","min_count","are","excluded","from","the","results",".","#","Returns",":","pandas.Dataframe",":","the","aggregated","dataframe","."]
code: def aggregate_results(results, parameters, min_count=0):
      """
      A helper function to aggregate results for repeated trials.
  
      Groups results by parameter values and computes mean and standard error of
      the mean. The returned dataframe's Objective column is the mean within
      groups. The standard error is denoted ObjectiveStdErr.
  
      # Arguments:
          results (pandas.Dataframe): the results dataframe.
          min_count (int): the minimum count within groups. Groups with fewer
              observations than min_count are excluded from the results.
  
      # Returns:
          pandas.Dataframe: the aggregated dataframe.
      """
      intermediate = results.query("Status == 'INTERMEDIATE'")
      completed = results.query("Status != 'INTERMEDIATE'")
  
      # aggregate
      aggregate_completed = completed.groupby(
          [p.name for p in parameters] + ["Status"]
      ).agg({"Objective": ["mean", "var", "count"], "Iteration": "max"})
  
      # flatten hierarchical column names
      aggregate_completed.columns = [
          "".join(c.capitalize() for c in col).strip()
          for col in aggregate_completed.columns.values
      ]
  
      # add variance and finalize
      aggregate_completed = (
          aggregate_completed.reset_index()
          .assign(
              ObjectiveStdErr=lambda x: numpy.sqrt(
                  x["ObjectiveVar"] / (x["ObjectiveCount"] - 1)
              )
          )
          .rename({"IterationMax": "Iteration"}, axis=1)
          .query("ObjectiveCount >= {}".format(min_count))
      )
  
      aggregate_intermediate = intermediate.groupby(
          [p.name for p in parameters] + ["Status", "Iteration"]
      ).agg({"Objective": ["mean", "var", "count"]})
      aggregate_intermediate.columns = [
          "".join(c.capitalize() for c in col).strip()
          for col in aggregate_intermediate.columns.values
      ]
  
      aggregate_intermediate = (
          aggregate_intermediate.reset_index()
          .assign(
              ObjectiveStdErr=lambda x: numpy.sqrt(
                  x["ObjectiveVar"] / (x["ObjectiveCount"] - 1)
              )
          )
          .query("ObjectiveCount >= {}".format(min_count))
      )
  
      full_results = pandas.concat(
          [aggregate_intermediate, aggregate_completed], sort=False
      ).rename({"ObjectiveMean": "Objective"}, axis=1)
  
      return full_results
  
imports: import os
  import random
  import numpy
  import logging
  import sherpa
  import pandas
  import sklearn.gaussian_process
  from sherpa.core import Choice, Continuous, Discrete, Ordinal, AlgorithmState
  from sherpa.core import rng
  import sklearn.model_selection
  import collections
label_desc: Use image node_id 4 for calling the Repeat obj's underlying member method code with example usage: obj.aggregate_results(results, parameters, min_count) and returns: full_results