deephyper.hpo.RandomSearch#
- class deephyper.hpo.RandomSearch(problem, evaluator, random_state=None, log_dir='.', verbose=0, stopper=None)[source]#
Bases:
Search
Random search algorithm used as an example for the API to implement new search algorithms.
Single-Objective
Multi-Objectives
Failures
✅
✅
✅
- Parameters:
problem – object describing the search/optimization problem.
evaluator – object describing the evaluation process.
random_state (np.random.RandomState, optional) – Initial random state of the search. Defaults to
None
.log_dir (str, optional) – Path to the directoy where results of the search are stored. Defaults to
"."
.verbose (int, optional) – Use verbose mode. Defaults to
0
.stopper (Stopper, optional) – a stopper to leverage multi-fidelity when evaluating the function. Defaults to
None
which does not use any stopper.
Methods
Ask the search for new configurations to evaluate.
check_evaluator
Dumps the context in the log folder.
Extend the results DataFrame with a column
pareto_efficient
which isTrue
if the point is Pareto efficient.Execute the search algorithm.
Tell the search the results of the evaluations.
Returns a json version of the search object.
Attributes
The identifier of the search used by the evaluator.
- ask(n: int = 1) List[Dict] #
Ask the search for new configurations to evaluate.
- Parameters:
n (int, optional) – The number of configurations to ask. Defaults to 1.
- Returns:
a list of hyperparameter configurations to evaluate.
- Return type:
List[Dict]
- dump_context()#
Dumps the context in the log folder.
- extend_results_with_pareto_efficient(df_path: str)#
Extend the results DataFrame with a column
pareto_efficient
which isTrue
if the point is Pareto efficient.- Parameters:
df (pd.DataFrame) – the input results DataFrame.
- search(max_evals: int = -1, timeout: int = None, max_evals_strict: bool = False)#
Execute the search algorithm.
- Parameters:
max_evals (int, optional) – The maximum number of evaluations of the run function to perform before stopping the search. Defaults to
-1
, will run indefinitely.timeout (int, optional) – The time budget (in seconds) of the search before stopping. Defaults to
None
, will not impose a time budget.max_evals_strict (bool, optional) – If
True
the search will not spawn more thanmax_evals
jobs. Defaults toFalse
.
- Returns:
a pandas DataFrame containing the evaluations performed or
None
if the search could not evaluate any configuration.- Return type:
DataFrame
- property search_id#
The identifier of the search used by the evaluator.
- tell(results: List[HPOJob])#
Tell the search the results of the evaluations.
- Parameters:
results (List[HPOJob]) – a list of HPOJobs from which hyperparameters and objectives can be retrieved.
- to_json()#
Returns a json version of the search object.