MCPcopy
hub / github.com/hyperopt/hyperopt / Trials

Class Trials

hyperopt/base.py:243–689  ·  view source on GitHub ↗

Database interface supporting data-driven model-based optimization. The model-based optimization algorithms used by hyperopt's fmin function work by analyzing samples of a response surface--a history of what points in the search space were tested, and what was discovered by those tests.

Source from the content-addressed store, hash-verified

241
242
243class Trials:
244 """Database interface supporting data-driven model-based optimization.
245
246 The model-based optimization algorithms used by hyperopt's fmin function
247 work by analyzing samples of a response surface--a history of what points
248 in the search space were tested, and what was discovered by those tests.
249 A Trials instance stores that history and makes it available to fmin and
250 to the various optimization algorithms.
251
252 This class (`base.Trials`) is a pure-Python implementation of the database
253 in terms of lists of dictionaries. Subclass `mongoexp.MongoTrials`
254 implements the same API in terms of a mongodb database running in another
255 process. Other subclasses may be implemented in future.
256
257 The elements of `self.trials` represent all of the completed, in-progress,
258 and scheduled evaluation points from an e.g. `fmin` call.
259
260 Each element of `self.trials` is a dictionary with *at least* the following
261 keys:
262
263 * **tid**: a unique trial identification object within this Trials instance
264 usually it is an integer, but it isn't obvious that other sortable,
265 hashable objects couldn't be used at some point.
266
267 * **result**: a sub-dictionary representing what was returned by the fmin
268 evaluation function. This sub-dictionary has a key 'status' with a value
269 from `STATUS_STRINGS` and the status is `STATUS_OK`, then there should be
270 a 'loss' key as well with a floating-point value. Other special keys in
271 this sub-dictionary may be used by optimization algorithms (see them
272 for details). Other keys in this sub-dictionary can be used by the
273 evaluation function to store miscellaneous diagnostics and debugging
274 information.
275
276 * **misc**: despite generic name, this is currently where the trial's
277 hyperparameter assignments are stored. This sub-dictionary has two
278 elements: `'idxs'` and `'vals'`. The `vals` dictionary is
279 a sub-sub-dictionary mapping each hyperparameter to either `[]` (if the
280 hyperparameter is inactive in this trial), or `[<val>]` (if the
281 hyperparameter is active). The `idxs` dictionary is technically
282 redundant -- it is the same as `vals` but it maps hyperparameter names
283 to either `[]` or `[<tid>]`.
284
285 """
286
287 asynchronous = False
288
289 def __init__(self, exp_key=None, refresh=True):
290 self._ids = set()
291 self._dynamic_trials = []
292 self._exp_key = exp_key
293 self.attachments = {}
294 if refresh:
295 self.refresh()
296
297 def view(self, exp_key=None, refresh=True):
298 rval = object.__new__(self.__class__)
299 rval._exp_key = exp_key
300 rval._ids = self._ids

Callers 15

idxs_vals_from_idsMethod · 0.90
setUpMethod · 0.90
test_quadratic1_randFunction · 0.90
test_quadratic1_tpeFunction · 0.90
test_quadratic1_annealFunction · 0.90
test_set_fmin_rstateFunction · 0.90
setUpMethod · 0.90
test_status_fail_tpeFunction · 0.90
test_loss_thresholdFunction · 0.90
test_early_stopFunction · 0.90

Calls

no outgoing calls

Tested by 15

idxs_vals_from_idsMethod · 0.72
setUpMethod · 0.72
test_quadratic1_randFunction · 0.72
test_quadratic1_tpeFunction · 0.72
test_quadratic1_annealFunction · 0.72
test_set_fmin_rstateFunction · 0.72
setUpMethod · 0.72
test_status_fail_tpeFunction · 0.72
test_loss_thresholdFunction · 0.72
test_early_stopFunction · 0.72