cave.utils.helpers module¶
-
exception
cave.utils.helpers.
MissingInstancesError
[source]¶ Bases:
Exception
Exception indicating that instances are missing.
-
args
¶
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
cave.utils.helpers.
combine_runhistories
(rhs, logger=None)[source]¶ Combine list of given runhistories. interleaving to best approximate execution order
-
cave.utils.helpers.
combine_trajectories
(trajs, logger=None)[source]¶ Combine trajectories. Trajectories are expected as an iterable of sorted lists, which are increasing in time. A trajectory entry is expected as: TrajEntry = collections.namedtuple(
- ‘TrajEntry’, [‘train_perf’, ‘incumbent_id’, ‘incumbent’,
‘ta_runs’, ‘ta_time_used’, ‘wallclock_time’])
- Parameters
trajs (List[List[TrajEntry]]) – trajectories to be combined
- Returns
combined_traj – combined trajectory
- Return type
List[TrajEntry]
-
cave.utils.helpers.
escape_parameter_name
(p)[source]¶ Necessary because: 1. parameters called ‘size’ or ‘origin’ might exist in cs 2. ‘-‘ not allowed in bokeh’s CDS
-
cave.utils.helpers.
get_config_origin
(c)[source]¶ Return appropriate configuration origin
- Parameters
c (Configuration) – configuration to be examined
- Returns
origin – origin of configuration (e.g. “Local”, “Random”, etc.)
- Return type
str
-
cave.utils.helpers.
get_cost_dict_for_config
(rh: smac.runhistory.runhistory.RunHistory, conf: ConfigSpace.configuration_space.Configuration, par: int = 1, cutoff: Optional[float] = None)[source]¶ Aggregates loss for configuration on evaluated instances over seeds.
- Parameters
rh (RunHistory) – runhistory with data
conf (Configuration) – configuration to evaluate
par (int) – par-factor with which to multiply timeouts
cutoff (float) – cutoff of scenario - used to penalize costs if par != 1
- Returns
cost – cost per instance (aggregated or as list per seed)
- Return type
dict(instance->cost)
-
cave.utils.helpers.
get_folder_basenames
(folders)[source]¶ Shorten folder-strings as much as possible (always keeping the basename). [“foo/bar/run_1”, “foo/bar/run_2/”] will be [“run_1”, “run_2”] [“foo/run_1/bar/”, “foo/run_2/bar”] will be [“run_1/bar”, “run_2/bar”]
-
cave.utils.helpers.
get_timeout
(rh, conf, cutoff)[source]¶ Check for timeouts. If multiple runs for an inst/config-pair are available, using the median (not the mean: no fractional timeouts)
- Parameters
rh (RunHistory) – runhistory to take runs from
conf (Configuration) – config to use
cutoff (int) – to determine timeouts
- Returns
timeouts – mapping instances to [True, False], where True indicates a timeout
- Return type
Dict(str: bool)