adaptive.AverageLearner1D¶
AverageLearner1D
¶
AverageLearner1D(function: Callable[[tuple[int, Real]], Real], bounds: tuple[Real, Real], loss_per_interval: None | Callable[[Sequence[Real], Sequence[Real]], float] = None, delta: float = 0.2, alpha: float = 0.005, neighbor_sampling: float = 0.3, min_samples: int = 50, max_samples: int = maxsize, min_error: float = 0)
Bases: Learner1D
Learns and predicts a noisy function 'f:ℝ → ℝ'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
function
|
callable
|
The function to learn. Must take a tuple of |
required |
bounds
|
pair of reals
|
The bounds of the interval on which to learn 'function'. |
required |
loss_per_interval
|
None | Callable[[Sequence[Real], Sequence[Real]], float]
|
A function that returns the loss for a single interval of the domain.
If not provided, then a default is used, which uses the scaled distance
in the x-y plane as the loss. See the notes for more details
of |
None
|
delta
|
float
|
This parameter controls the resampling condition. A point is resampled
if its uncertainty is larger than delta times the smallest neighboring
interval.
We strongly recommend |
0.2
|
alpha
|
float(0 < alpha < 1)
|
The true value of the function at x is within the confidence interval
|
0.005
|
neighbor_sampling
|
float(0 < neighbor_sampling <= 1)
|
Each new point is initially sampled at least a (neighbor_sampling*100)% of the average number of samples of its neighbors. |
0.3
|
min_samples
|
int(min_samples > 0)
|
Minimum number of samples at each point x. Each new point is initially sampled at least min_samples times. |
50
|
max_samples
|
int(min_samples < max_samples)
|
Maximum number of samples at each point x. |
np.inf
|
min_error
|
float(min_error >= 0)
|
Minimum size of the confidence intervals. The true value of the function at x is within the confidence interval [self.data[x] - self.error[x], self.data[x] + self.error[x]] with probability 1-2*alpha. If self.error[x] < min_error, then x will not be resampled anymore, i.e., the smallest confidence interval at x is [self.data[x] - min_error, self.data[x] + min_error]. |
0
|
Source code in adaptive/learner/average_learner1D.py
new
¶
new() -> AverageLearner1D
Create a copy of AverageLearner1D without the data.
Source code in adaptive/learner/average_learner1D.py
to_numpy
¶
to_numpy(mean: bool = False) -> ndarray
Source code in adaptive/learner/average_learner1D.py
to_dataframe
¶
to_dataframe(mean: bool = False, with_default_function_args: bool = True, function_prefix: str = 'function.', seed_name: str = 'seed', x_name: str = 'x', 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'
|
x_name
|
str
|
Name of the |
'x'
|
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_learner1D.py
load_dataframe
¶
load_dataframe(df: DataFrame, with_default_function_args: bool = True, function_prefix: str = 'function.', seed_name: str = 'seed', x_name: str = 'x', 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'
|
x_name
|
str
|
The |
'x'
|
y_name
|
str
|
The |
'y'
|
Source code in adaptive/learner/average_learner1D.py
ask
¶
Return 'n' points that are expected to maximally reduce the loss.
Source code in adaptive/learner/average_learner1D.py
tell_pending
¶
Source code in adaptive/learner/average_learner1D.py
tell
¶
Source code in adaptive/learner/average_learner1D.py
tell_many
¶
tell_many(xs: Points | ndarray, ys: Sequence[Real] | ndarray) -> None
Source code in adaptive/learner/average_learner1D.py
tell_many_at_point
¶
Tell the learner about many samples at a certain location x.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
Value from the function domain. |
required |
seed_y_mapping
|
Dict[int, Real]
|
Dictionary of |
required |
Source code in adaptive/learner/average_learner1D.py
plot
¶
Returns a plot of the evaluated data with error bars.
This is only implemented for scalar functions, i.e., it requires vdim=1.
Returns:
| Name | Type | Description |
|---|---|---|
plot |
`holoviews.element.Scatter * holoviews.element.ErrorBars *
|
Plot of the evaluated data. |