Skip to main content
`Ctrl`+`K`

# `skopt.callbacks`.CheckpointSaver

class skopt.callbacks.CheckpointSaver(checkpoint_path, **dump_options)

  Save current state after each iteration with `skopt.dump`. Allows to re- use previously computed function evaluations.

  Parameters:
    checkpoint_path string

      location where checkpoint will be saved to;

    dump_options string

      options to pass on to `skopt.dump`, like `compress=9`

  Examples

      >>> import skopt
      >>> def obj_fun(x):
      ...     return x[0]**2
      >>> checkpoint_callback = skopt.callbacks.CheckpointSaver("./result.pkl")
      >>> skopt.gp_minimize(obj_fun, [(-2, 2)], n_calls=10,
      ...                   callback=[checkpoint_callback])
      >>> # when re-using stored results.
      >>> checkpoint_callback = skopt.callbacks.CheckpointSaver("./result.pkl")
      >>> skopt.gp_minimize(obj_fun, [(-2, 2)], n_calls=10,
      ...                   callback=[checkpoint_callback]
      ...                   **checkpoint_callback.load())

  Methods

  `__call__`(res) |
  `load`() | Loads from disk previously evaluated points.

  __init__(checkpoint_path, **dump_options)
  load()

    Loads from disk previously evaluated points.

    Returns:
      Dict with previous evaluations and their latest surrogate state.