adaptive.BaseLearner#
- class adaptive.learner.BaseLearner[source]#
Bases:
ABC
Base class for algorithms for learning a function ‘f: X → Y’.
- function#
The function to learn. A subclass of BaseLearner might modify the user’s supplied function.
- Type:
callable: X → Y
- data#
function evaluated at certain points.
- Type:
dict: X → Y
Notes
Subclasses may define a
plot
method that takes no parameters and returns a holoviews plot.- copy_from(other)[source]#
Copy over the data from another learner.
- Parameters:
other (BaseLearner object) – The learner from which the data is copied.
- abstract load_dataframe(df: pandas.DataFrame, with_default_function_args: bool = True, function_prefix: str = 'function.', **kwargs: Any) None [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
.
- abstract 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).
- tell(x, y)[source]#
Tell the learner about a single value.
- Parameters:
x (A value from the function domain) –
y (A value from the function image) –
- tell_many(xs, ys)[source]#
Tell the learner about some values.
- Parameters:
xs (Iterable of values from the function domain) –
ys (Iterable of values from the function image) –
- abstract tell_pending(x)[source]#
Tell the learner that ‘x’ has been requested such that it’s not suggested again.
- abstract to_dataframe(with_default_function_args: bool = True, function_prefix: str = 'function.', **kwargs: Any) pandas.DataFrame [source]#
Return the data as a
pandas.DataFrame
.- Parameters:
with_default_function_args (bool, optional) – Include the
learner.function
’s default arguments as a column, by default Truefunction_prefix (str, optional) – Prefix to the
learner.function
’s default arguments’ names, by default “function.”x_name (str, optional) – Name of the input value, by default “x”
y_name (str, optional) – Name of the output value, by default “y”
- Return type:
pandas.DataFrame