Callbacks#
- class pyhopper.callbacks.Callback[source]#
- load_state_dict(state_dict)[source]#
Restores the internal state of the callback. :param state_dict: A dict created by the self.state_dict method
- on_duplicate_sampled(candidate, info)[source]#
Called if candidate was sampled twice
- Parameters
candidate (dict) – Parameter value of the sampled candidate
info (ParamInfo) –
- on_evaluate_end(candidate, f, info)[source]#
Called after candidate was successfully evaluated
- Parameters
candidate (dict) – Parameter value of the evaluated candidate
f (float) – Value of the objective function corresponding to the candidate
info (ParamInfo) –
- on_evaluate_nan(candidate, info)[source]#
Called if candidate is evaluated to NaN and the ignore_nans argument of run was set to True
- Parameters
candidate (dict) – Parameter value that evaluate to NaN
info (ParamInfo) –
- on_evaluate_pruned(candidate, info)[source]#
Called if candidate was pruned (by an
pyhopper.pruners.Pruner())- Parameters
candidate (dict) – Parameter value of the pruned candidate
info (ParamInfo) –
- on_evaluate_start(candidate, info)[source]#
Called after candidate was sampled and scheduled for evaluation
- Parameters
candidate (dict) – Parameter value of the candidate to be evaluated
info (ParamInfo) –
- on_new_best(new_best, f, info)[source]#
Called when a new best parameter is found
- Parameters
new_best (dict) – Value of the new best parameter
f (float) – Value of the objective function corresponding to the new best parameter
info (ParamInfo) –
- class pyhopper.ParamInfo(candidate_type, sampled_at)[source]#
Holds auxiliary information about a parameter candidate
- Attributes:
typeEnum specifying how the parameter was sampled (valid values are pyhopper.CandidateType.INIT, pyhopper.CandidateType.MANUALLY_ADDED, pyhopper.CandidateType.RANDOM_SEEDING, pyhopper.CandidateType.LOCAL_SAMPLING).sampled_atUNIX epoch timestamp when the parameter candidate was sampled.finished_atUNIX epoch timestamp when the evaluation of the candidate was finished.is_prunedBool indicating if the candidate was pruned.
- class pyhopper.callbacks.History(log_candidates=True)[source]#
Public API for the history of the search. Can be used by the user for plotting and analyzing the search space. Persistent over several consecutive calls of
`run`- load_state_dict(state_dict)[source]#
Restores the internal state of the callback. :param state_dict: A dict created by the self.state_dict method
- on_evaluate_end(candidate, f, info)[source]#
Called after candidate was successfully evaluated
- Parameters
candidate (dict) – Parameter value of the evaluated candidate
f (float) – Value of the objective function corresponding to the candidate
info (ParamInfo) –
- on_evaluate_nan(candidate, info)[source]#
Called if candidate is evaluated to NaN and the ignore_nans argument of run was set to True
- Parameters
candidate (dict) – Parameter value that evaluate to NaN
info (ParamInfo) –
- on_evaluate_pruned(candidate, info)[source]#
Called if candidate was pruned (by an
pyhopper.pruners.Pruner())- Parameters
candidate (dict) – Parameter value of the pruned candidate
info (ParamInfo) –
- on_new_best(new_best, f, info)[source]#
Called when a new best parameter is found
- Parameters
new_best (dict) – Value of the new best parameter
f (float) – Value of the objective function corresponding to the new best parameter
info (ParamInfo) –