Minimize a function over a hyperparameter space. More realistically: *explore* a function over a hyperparameter space according to a given algorithm, allowing up to a certain number of function evaluations. As points are explored, they are accumulated in `trials` Parameters
(
fn,
space,
algo=None,
max_evals=None,
timeout=None,
loss_threshold=None,
trials=None,
rstate=None,
allow_trials_fmin=True,
pass_expr_memo_ctrl=None,
catch_eval_exceptions=False,
verbose=True,
return_argmin=True,
points_to_evaluate=None,
max_queue_len=1,
show_progressbar=True,
early_stop_fn=None,
trials_save_file="",
)
| 367 | |
| 368 | |
| 369 | def fmin( |
| 370 | fn, |
| 371 | space, |
| 372 | algo=None, |
| 373 | max_evals=None, |
| 374 | timeout=None, |
| 375 | loss_threshold=None, |
| 376 | trials=None, |
| 377 | rstate=None, |
| 378 | allow_trials_fmin=True, |
| 379 | pass_expr_memo_ctrl=None, |
| 380 | catch_eval_exceptions=False, |
| 381 | verbose=True, |
| 382 | return_argmin=True, |
| 383 | points_to_evaluate=None, |
| 384 | max_queue_len=1, |
| 385 | show_progressbar=True, |
| 386 | early_stop_fn=None, |
| 387 | trials_save_file="", |
| 388 | ): |
| 389 | """Minimize a function over a hyperparameter space. |
| 390 | |
| 391 | More realistically: *explore* a function over a hyperparameter space |
| 392 | according to a given algorithm, allowing up to a certain number of |
| 393 | function evaluations. As points are explored, they are accumulated in |
| 394 | `trials` |
| 395 | |
| 396 | |
| 397 | Parameters |
| 398 | ---------- |
| 399 | |
| 400 | fn : callable (trial point -> loss) |
| 401 | This function will be called with a value generated from `space` |
| 402 | as the first and possibly only argument. It can return either |
| 403 | a scalar-valued loss, or a dictionary. A returned dictionary must |
| 404 | contain a 'status' key with a value from `STATUS_STRINGS`, must |
| 405 | contain a 'loss' key if the status is `STATUS_OK`. Particular |
| 406 | optimization algorithms may look for other keys as well. An |
| 407 | optional sub-dictionary associated with an 'attachments' key will |
| 408 | be removed by fmin its contents will be available via |
| 409 | `trials.trial_attachments`. The rest (usually all) of the returned |
| 410 | dictionary will be stored and available later as some 'result' |
| 411 | sub-dictionary within `trials.trials`. |
| 412 | |
| 413 | space : hyperopt.pyll.Apply node or "annotated" |
| 414 | The set of possible arguments to `fn` is the set of objects |
| 415 | that could be created with non-zero probability by drawing randomly |
| 416 | from this stochastic program involving involving hp_<xxx> nodes |
| 417 | (see `hyperopt.hp` and `hyperopt.pyll_utils`). |
| 418 | If set to "annotated", will read space using type hint in fn. Ex: |
| 419 | (`def fn(x: hp.uniform("x", -1, 1)): return x`) |
| 420 | |
| 421 | algo : search algorithm |
| 422 | This object, such as `hyperopt.rand.suggest` and |
| 423 | `hyperopt.tpe.suggest` provides logic for sequential search of the |
| 424 | hyperparameter space. |
| 425 | |
| 426 | max_evals : int |