adaptive.AverageLearner1D
- class adaptive.AverageLearner1D(*args, **kwargs)[source]
Bases:
adaptive.learner.learner1D.Learner1D
Learns and predicts a noisy function ‘f:ℝ → ℝ’.
- Parameters
function (callable) – The function to learn. Must take a tuple of
(seed, x)
and return a real number.bounds (pair of reals) – The bounds of the interval on which to learn ‘function’.
loss_per_interval (callable, optional) – 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
adaptive.Learner1D
for more details.delta (float, optional, default 0.2) – 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 < delta <= 1
.alpha (float (0 < alpha < 1), default 0.005) – 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 probability1-2*alpha
. We recommend to keepalpha=0.005
.neighbor_sampling (float (0 < neighbor_sampling <= 1), default 0.3) – Each new point is initially sampled at least a (neighbor_sampling*100)% of the average number of samples of its neighbors.
min_samples (int (min_samples > 0), default 50) – Minimum number of samples at each point x. Each new point is initially sampled at least min_samples times.
max_samples (int (min_samples < max_samples), default np.inf) – Maximum number of samples at each point x.
min_error (float (min_error >= 0), default 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].
- ask(n: int, tell_pending: bool = True) tuple[typing.List[typing.Tuple[int, typing.Union[float, numpy.float64, int, numpy.int64]]], list[float]] [source]
Return ‘n’ points that are expected to maximally reduce the loss.
- plot()[source]
- Returns a plot of the evaluated data with error bars (not implemented
for vector functions, i.e., it requires vdim=1).
- Returns
plot – holoviews.element.Path` Plot of the evaluated data.
- Return type
`holoviews.element.Scatter * holoviews.element.ErrorBars *
- tell(seed_x: Tuple[int, Union[float, numpy.float64, int, numpy.int64]], y: Union[float, numpy.float64, int, numpy.int64]) None [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: List[Tuple[int, Union[float, numpy.float64, int, numpy.int64]]], ys: Sequence[Union[float, numpy.float64, int, numpy.int64]]) None [source]
Tell the learner about some values.
- Parameters
xs (Iterable of values from the function domain) –
ys (Iterable of values from the function image) –