class_docstr: Asynchronous Successive Halving as described in:
  
      @article{li2018massively,
      title={Massively parallel hyperparameter tuning},
      author={Li, Liam and Jamieson, Kevin and Rostamizadeh, Afshin and Gonina, Ekaterina and Hardt, Moritz and Recht, Benjamin and Talwalkar, Ameet},
      journal={arXiv preprint arXiv:1810.05934},
      year={2018}
      }
  
  Asynchronous successive halving operates based on the multi-armed bandit
  algorithm Successive Halving (SHA) and performs principled early stopping for
  random search.
  
  Args:
      r (int): minimum resource that each configuration will be trained for.
      R (int): maximum resource.
      eta (int): elimination rate.
      s (int): minimum early-stopping rate.
      max_finished_configs (int): stop once max_finished_configs models have
          been trained to completion.
class_docstr_tok: ["Asynchronous","Successive","Halving","as","described","in",":","@","article","{","li2018massively",",","title=","{","Massively","parallel","hyperparameter","tuning","}",",","author=","{","Li",",","Liam","and","Jamieson",",","Kevin","and","Rostamizadeh",",","Afshin","and","Gonina",",","Ekaterina","and","Hardt",",","Moritz","and","Recht",",","Benjamin","and","Talwalkar",",","Ameet","}",",","journal=","{","arXiv","preprint","arXiv:1810.05934","}",",","year=","{","2018","}","}","Asynchronous","successive","halving","operates","based","on","the","multi-armed","bandit","algorithm","Successive","Halving","(","SHA",")","and","performs","principled","early","stopping","for","random","search",".","Args",":","r","(","int",")",":","minimum","resource","that","each","configuration","will","be","trained","for",".","R","(","int",")",":","maximum","resource",".","eta","(","int",")",":","elimination","rate",".","s","(","int",")",":","minimum","early-stopping","rate",".","max_finished_configs","(","int",")",":","stop","once","max_finished_configs","models","have","been","trained","to","completion","."]
docstr: If there are >=m*eta configs in rung k, return the m best ones,
  otherwise return []
docstr_tok: ["If","there","are",">","=m","*","eta","configs","in","rung","k",",","return","the","m","best","ones",",","otherwise","return","[","]"]
code: def top_n(parameters, results, lower_is_better, rung, eta):
      """
      If there are >=m*eta configs in rung k, return the m best ones,
      otherwise return []
      """
      if len(results) == 0:
          return pandas.DataFrame({"save_to": []})
      columns = [p.name for p in parameters] + ["save_to"]
  
      rung_results = SuccessiveHalving._get_completed_results(
          results, rung
      )
  
      n = len(rung_results) // eta
      top_n = (
          rung_results.sort_values(
              by="Objective", ascending=lower_is_better
          )
          .iloc[0:n, :]
          .loc[:, columns]
      )
      return top_n
  
file_path: sherpa/sherpa/algorithms/successive_halving.py
imports: from sherpa.algorithms import Algorithm, RandomSearch
  import numpy
  import pandas
  from sherpa.core import TrialStatus, AlgorithmState
label_desc: Use image node_id 5 for calling the SuccessiveHalving obj's underlying member method code with example usage: obj.top_n(parameters, results, lower_is_better, rung, eta) and returns: top_n, pandas