cave.utils.hpbandster_helpers module

Here are helper functions needed to provide a certain behaviour of HpBandSter, such as special trajectories.

cave.utils.hpbandster_helpers._compute_trajectory_racing(all_runs, budgets)[source]

Computes the trajectory in racing mode. If there is at time T a current incumbent I on budget B, a configuration C can become a incumbent on a higher budget only if I is also evaluated on C. This means a configuration C can only be incumbent if the current incumbent is evaluated on the same budget.

If the current incumbent is not available for a higher budget, the incumbent candidate for this higher budget is chosen as incumbent.

If a configuration ‘waits’ for the incumbent to be evaluated on the same budget, its finishing time is set to the time the old incumbent is evaluated on the higher budget.

Parameters
  • all_runs – list(hpbandster.core.Run) list of all hpbandster runs sorted ascending by its finishing time

  • budgets – list(float) list of all budgets in ascending order

ReturnsGenerator

Generator representing the incumbents in order of appearance

cave.utils.hpbandster_helpers._get_incumbent_trajectory_hpbandster(result, budgets, bigger_is_better=True, non_decreasing_budget=True)[source]

Returns the best configurations over time

!! Copied from hpbandster and modified to enable getting trajectories for individual budgets !!

Parameters
  • result – result

  • budgets (List[budgets] or 'all' or 'only_largest') – budgets to be considered

  • bigger_is_better (bool) – flag whether an evaluation on a larger budget is always considered better. If True, the incumbent might increase for the first evaluations on a bigger budget

  • non_decreasing_budget (bool) – flag whether the budget of a new incumbent should be at least as big as the one for the current incumbent.

Returns

dictionary with all the config IDs, the times the runs finished, their respective budgets, and corresponding losses

Return type

dict

cave.utils.hpbandster_helpers.format_budgets(budgets, allow_whitespace=False)[source]

Format budget-strings so that they are as short as possible while still distinguishable

Parameters
  • budgets (List[str]) – list with budgets

  • allow_whitespace (bool) – if set to True, will return “budget 10.5” else “budget_10.5

Returns

formatted_budgets – list with formatted budgets

Return type

Dict[float] -> str

cave.utils.hpbandster_helpers.get_incumbent_trajectory(result, budgets=None, mode='racing')[source]
Parameters
  • result (hpbandster.core.result.Result) – result object

  • budgets (List[str|int|float] or 'all') – if a list of budgets, only consider those budgets (to enable trajectories for only a single budget)

  • mode (str) – from [‘racing’, ‘minimum’, ‘prefer_higher_budget’]

Returns

trajectory – dictionary with all the config IDs, the times the runs finished, their respective budgets, and corresponding losses

Return type

dict