adaptive.AverageLearner¶
AverageLearner
¶
AverageLearner(function: Callable[[int], Real], atol: float | None = None, rtol: float | None = None, min_npoints: int = 2)
Bases: BaseLearner
A naive implementation of adaptive computing of averages.
The learned function must depend on an integer input variable that represents the source of randomness.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
atol
|
float
|
Desired absolute tolerance. |
None
|
rtol
|
float
|
Desired relative tolerance. |
None
|
min_npoints
|
int
|
Minimum number of points to sample. |
2
|
Attributes:
| Name | Type | Description |
|---|---|---|
data |
dict
|
Sampled points and values. |
pending_points |
set
|
Points that still have to be evaluated. |
npoints |
int
|
Number of evaluated points. |
Source code in adaptive/learner/average_learner.py
to_numpy
¶
to_dataframe
¶
to_dataframe(with_default_function_args: bool = True, function_prefix: str = 'function.', seed_name: str = 'seed', y_name: str = 'y') -> 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.'
|
seed_name
|
str
|
Name of the |
'seed'
|
y_name
|
str
|
Name of the output value, by default "y" |
'y'
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
|
Raises:
| Type | Description |
|---|---|
ImportError
|
If |
Source code in adaptive/learner/average_learner.py
load_dataframe
¶
load_dataframe(df: DataFrame, with_default_function_args: bool = True, function_prefix: str = 'function.', seed_name: str = 'seed', y_name: str = 'y')
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.'
|
seed_name
|
str
|
The |
'seed'
|
y_name
|
str
|
The |
'y'
|
Source code in adaptive/learner/average_learner.py
ask
¶
Source code in adaptive/learner/average_learner.py
tell
¶
Source code in adaptive/learner/average_learner.py
loss
¶
loss(real: bool = True, *, n=None) -> Float
Source code in adaptive/learner/average_learner.py
remove_unfinished
¶
plot
¶
Returns a histogram of the evaluated data.
Returns:
| Type | Description |
|---|---|
Histogram
|
A histogram of the evaluated data. |