adaptive.SKOptLearner#
- class adaptive.SKOptLearner(function, **kwargs)[source]#
Bases:
Optimizer
,BaseLearner
Learn a function minimum using
skopt.Optimizer
.This is an
Optimizer
fromscikit-optimize
, with the necessary methods added to make it conform to theadaptive
learner interface.- Parameters:
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:
https://hal.archives-ouvertes.fr/hal-00732512/document
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, thenlearner.function
’s default arguments are set (usingfunctools.partial
) from the values in thepandas.DataFrame
.
- loss(real=True)[source]#
Return the loss for the current state of the learner.
- Parameters:
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.
- 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.
- Parameters:
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_pending(x)[source]#
Tell the learner that ‘x’ has been requested such that it’s not suggested again.