Flexible row of named data used for train/dev/test sets.
Examples are plain data with one important Imp convention: call
with_inputs/2 to mark which fields a program may see. The remaining fields
are labels for evaluation, bootstrapping, demonstrations, and optimizers.
A key keeps the type it was given: %{"question" => ...} is stored under the
string and %{question: ...} under the atom, and no string is turned into an
atom. Every function that takes a key compares keys by their text, so
get(example, :question) reads a field stored under "question".
Internal fields whose names start with imp_ are omitted from keys/1,
items/1, and values/1, but to_map/1 remains lossless for persistence and
debugging.
Example
iex> example =
...> Imp.Example.new(question: "2+2?", answer: "4", imp_trace: :kept)
...> |> Imp.Example.with_inputs(:question)
iex> Imp.Example.to_map(Imp.Example.inputs(example))
%{question: "2+2?"}
iex> Imp.Example.to_map(Imp.Example.labels(example))
%{answer: "4", imp_trace: :kept}
iex> Imp.Example.keys(example) |> Enum.sort()
[:answer, :question]
Summary
Functions
Returns a copy of the example with one field removed.
Reads a field or raises KeyError when it is missing.
Reads a field, returning default when it is missing.
Returns an example containing only the marked input fields.
Returns non-internal {key, value} field pairs.
Returns non-internal field keys.
Returns an example containing label fields, excluding marked inputs.
Builds an example from a map, field pair list, or existing example.
Returns a copy of the example with one field set.
Returns the full field map, including internal imp_ fields.
Returns non-internal field values.
Attaches demonstrations to an example.
Marks which fields are inputs for programs and optimizers.
Types
Functions
Returns a copy of the example with one field removed.
Reads a field or raises KeyError when it is missing.
Reads a field, returning default when it is missing.
Returns an example containing only the marked input fields.
Returns non-internal {key, value} field pairs.
Returns non-internal field keys.
Returns an example containing label fields, excluding marked inputs.
Builds an example from a map, field pair list, or existing example.
Returns a copy of the example with one field set.
Returns the full field map, including internal imp_ fields.
Returns non-internal field values.
Attaches demonstrations to an example.
Marks which fields are inputs for programs and optimizers.