adaptive.SequenceLearner

class adaptive.SequenceLearner(*args, **kwargs)[source]

Bases: adaptive.learner.base_learner.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
  • function (callable) – The function to learn. Must take a single element sequence.

  • sequence (sequence) – The sequence to learn.

data

The data as a mapping from “index of element in sequence” => value.

Type

dict

Notes

From primitive tests, the SequenceLearner appears to have a similar performance to ipyparallels load_balanced_view().map. With the added benefit of having results in the local kernel already.

ask(n, tell_pending=True)[source]

Choose the next ‘n’ points to evaluate.

Parameters
  • n (int) – The number of points to choose.

  • tell_pending (bool, default: True) – If True, add the chosen points to this learner’s pending_points. Set this to False if you do not want to modify the state of the learner.

data: dict
done()[source]
loss(real=True)[source]

Return the loss for the current state of the learner.

Parameters

real (bool, default: True) – If False, return the “expected” loss, i.e. the loss including the as-yet unevaluated points (possibly by interpolation).

property npoints
pending_points: set
remove_unfinished()[source]

Remove uncomputed data from the learner.

result()[source]

Get the function values in the same order as sequence.

tell(point, value)[source]

Tell the learner about a single value.

Parameters
  • x (A value from the function domain) –

  • y (A value from the function image) –

tell_pending(point)[source]

Tell the learner that ‘x’ has been requested such that it’s not suggested again.