lale.grammar module

class lale.grammar.Grammar(variables: Optional[Dict[str, Operator]] = None)[source]

Bases: Operator

Base class for Lale grammars.

get_params(deep: bool = True) Dict[str, Any][source]

For scikit-learn compatibility

input_schema_fit()[source]

Input schema for the fit method.

is_classifier() bool[source]

Checks if this operator is a clasifier.

Returns

True if the classifier tag is set.

Return type

bool

is_supervised()[source]

Checks if this operator needs labeled data for learning.

Returns

True if the fit method requires a y argument.

Return type

bool

sample(n: int) PlannedOperator[source]

Sample the grammar g starting from g.start, that is, choose one element at random for each possible choices.

Parameters

n (int) – number of derivations

Return type

PlannedOperator

transform_schema(s_X)[source]

Return the output schema given the input schema.

Parameters

s_X – Input dataset or schema.

Returns

Schema of the output data given the input data schema.

Return type

JSON schema

unfold(n: int) PlannedOperator[source]

Explore this grammar self.start and generate all possible choices after n derivations.

Parameters

n (int) – number of derivations

Return type

PlannedOperator

validate_schema(X, y=None)[source]

Validate that X and y are valid with respect to the input schema of this operator.

Parameters
  • X – Features.

  • y – Target class labels or None for unsupervised operators.

Raises

ValueError – If X or y are invalid as inputs.

class lale.grammar.NonTerminal(name)[source]

Bases: Operator

Abstract operator for non-terminal grammar rules.

get_params(deep: bool = True) Dict[str, Any][source]

For scikit-learn compatibility

input_schema_fit()[source]

Input schema for the fit method.

is_classifier() bool[source]

Checks if this operator is a clasifier.

Returns

True if the classifier tag is set.

Return type

bool

is_supervised()[source]

Checks if this operator needs labeled data for learning.

Returns

True if the fit method requires a y argument.

Return type

bool

transform_schema(s_X)[source]

Return the output schema given the input schema.

Parameters

s_X – Input dataset or schema.

Returns

Schema of the output data given the input data schema.

Return type

JSON schema

validate_schema(X, y=None)[source]

Validate that X and y are valid with respect to the input schema of this operator.

Parameters
  • X – Features.

  • y – Target class labels or None for unsupervised operators.

Raises

ValueError – If X or y are invalid as inputs.