class adaptive.SKOptLearner(function, **kwargs)[source]#

Bases: Optimizer, BaseLearner

Learn a function minimum using skopt.Optimizer.

This is an Optimizer from scikit-optimize, with the necessary methods added to make it conform to the adaptive learner interface.

  • function (callable) – The function to learn.

  • **kwargs – Arguments to pass to skopt.Optimizer.

ask(n, tell_pending=True)[source]#

Query point or multiple points at which objective should be evaluated.

n_pointsint or None, default: None

Number of points returned by the ask method. If the value is None, a single point to evaluate is returned. Otherwise a list of points to evaluate is returned of size n_points. This is useful if you can evaluate your objective in parallel, and thus obtain more objective function evaluations per unit of time.

strategystring, default: “cl_min”

Method to use to sample multiple points (see also n_points description). This parameter is ignored if n_points = None. Supported options are “cl_min”, “cl_mean” or “cl_max”.

  • If set to “cl_min”, then constant liar strategy is used

    with lie objective value being minimum of observed objective values. “cl_mean” and “cl_max” means mean and max of values respectively. For details on this strategy see:

    With this strategy a copy of optimizer is created, which is then asked for a point, and the point is told to the copy of optimizer with some fake objective (lie), the next point is asked from copy, it is also told to the copy with fake objective and so on. The type of lie defines different flavours of cl_x strategies.

load_dataframe(df: pandas.DataFrame, with_default_function_args: bool = True, function_prefix: str = 'function.', seed_name: str = 'seed', y_name: str = 'y')[source]#

Load data from a pandas.DataFrame.

If with_default_function_args is True, then learner.function’s default arguments are set (using functools.partial) from the values in the pandas.DataFrame.

  • df (pandas.DataFrame) – The data to load.

  • with_default_function_args (bool, optional) – The with_default_function_args used in to_dataframe(), by default True

  • function_prefix (str, optional) – The function_prefix used in to_dataframe, by default “function.”

  • TODO


Return the loss for the current state of the learner.


real (bool, default: True) – If False, return the “expected” loss, i.e. the loss including the as-yet unevaluated points (possibly by interpolation).

new() SKOptLearner[source]#

Return a new SKOptLearner without the data.

property npoints#

Number of evaluated points.


Remove uncomputed data from the learner.

tell(x, y, fit=True)[source]#

Record an observation (or several) of the objective function.

Provide values of the objective function at points suggested by ask() or other points. By default a new model will be fit to all observations. The new model is used to suggest the next point at which to evaluate the objective. This point can be retrieved by calling ask().

To add observations without fitting a new model set fit to False.

To add multiple observations in a batch pass a list-of-lists for x and a list of scalars for y.

  • x (list or list-of-lists) – Point at which objective was evaluated.

  • y (scalar or list) – Value of objective at x.

  • fit (bool, default: True) – Fit a model to observed evaluations of the objective. A model will only be fitted after n_initial_points points have been told to the optimizer irrespective of the value of fit.


Tell the learner that ‘x’ has been requested such that it’s not suggested again.

to_dataframe(with_default_function_args: bool = True, function_prefix: str = 'function.', seed_name: str = 'seed', y_name: str = 'y') pandas.DataFrame[source]#

Return the data as a pandas.DataFrame.

  • with_default_function_args (bool, optional) – Include the learner.function’s default arguments as a column, by default True

  • function_prefix (str, optional) – Prefix to the learner.function’s default arguments’ names, by default “function.”

  • TODO

Return type:



ImportError – If pandas is not installed.