concepts.dsl.learning.function_domain_search.learn_expression_from_examples#

learn_expression_from_examples(domain, executor, input_output, criterion, candidate_expressions=None, max_depth=3, max_function_arguments=0, search_constants=True)[source]#

Learn a function from examples.

Parameters:
  • domain (FunctionDomain) – the function domain.

  • executor (FunctionDomainExecutor) – the executor of the function domain.

  • input_output (Sequence[Tuple[Sequence[Value], Value, Any]]) – a sequence of (input, output, grounding) pairs.

  • criterion (Callable[[Value, Value], bool]) – a function that takes two values and returns True if they are equal.

  • candidate_expressions (Iterable[FunctionDomainExpressionSearchResult] | None) – a sequence of candidate functions. If None, we will generate candidate functions automatically.

  • max_depth (int) – the maximum depth of the function. Only used when candidate_expressions is None.

  • max_function_arguments (int) – the maximum number of arguments of a function. Only used when candidate_expressions is None.

  • search_constants (bool) – whether to search for constants. Only used when candidate_expressions is None.

Returns:

A function.

Return type:

Function