adaptive.SequenceLearner¶
SequenceLearner
¶
Bases: BaseLearner
A learner that will learn a sequence. It simply returns the points in the provided sequence when asked.
This is useful when your problem cannot be formulated in terms of another adaptive learner, but you still want to use Adaptive's routines to run, save, and plot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
function
|
callable
|
The function to learn. Must take a single element |
required |
sequence
|
sequence
|
The sequence to learn. |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
data |
dict
|
The data as a mapping from "index of element in sequence" => value. |
Notes
From primitive tests, the SequenceLearner appears to have a
similar performance to ipyparallel\s load_balanced_view().map. With
the added benefit of having results in the local kernel already.
Source code in adaptive/learner/sequence_learner.py
ask
¶
Source code in adaptive/learner/sequence_learner.py
loss
¶
Source code in adaptive/learner/sequence_learner.py
remove_unfinished
¶
tell_pending
¶
result
¶
Get the function values in the same order as sequence.
to_dataframe
¶
to_dataframe(with_default_function_args: bool = True, function_prefix: str = 'function.', index_name: str = 'i', x_name: str = 'x', y_name: str = 'y', *, full_sequence: bool = False) -> DataFrame
Return the data as a pandas.DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
with_default_function_args
|
bool
|
Include the |
True
|
function_prefix
|
str
|
Prefix to the |
'function.'
|
index_name
|
str
|
Name of the index parameter, by default "i" |
'i'
|
x_name
|
str
|
Name of the input value, by default "x" |
'x'
|
y_name
|
str
|
Name of the output value, by default "y" |
'y'
|
full_sequence
|
bool
|
If True, the returned dataframe will have the full sequence where the y_name values are pd.NA if not evaluated yet. |
False
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
|
Raises:
| Type | Description |
|---|---|
ImportError
|
If |
Source code in adaptive/learner/sequence_learner.py
load_dataframe
¶
load_dataframe(df: DataFrame, with_default_function_args: bool = True, function_prefix: str = 'function.', index_name: str = 'i', x_name: str = 'x', y_name: str = 'y', *, full_sequence: bool = False)
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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
The data to load. |
required |
with_default_function_args
|
bool
|
The |
True
|
function_prefix
|
str
|
The |
'function.'
|
index_name
|
str
|
The |
'i'
|
x_name
|
str
|
The |
'x'
|
y_name
|
str
|
The |
'y'
|
full_sequence
|
bool
|
The |
False
|