Tutorial SequenceLearner¶
Run this page yourself
Download this page as a Jupyter notebook: tutorial.SequenceLearner.ipynb.
Note
Because this documentation consists of static html, the live_plot and live_info widget is not live.
Download the notebook in order to see the real behaviour.
Show code
This learner 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, (periodically) save, and plot.
from adaptive import SequenceLearner
def f(x):
return int(x) ** 2
seq = np.linspace(-15, 15, 1000)
learner = SequenceLearner(f, seq)
runner = adaptive.Runner(learner)
# not providing a goal is same as `lambda learner: learner.done()`
def plotter(learner):
data = learner.data if learner.data else []
return hv.Scatter(data)
runner.live_plot(plotter=plotter)
learner.data contains a dictionary that maps the index of the point of learner.sequence to the value at that point.
To get the values in the same order as the input sequence (learner.sequence) use