lale.grammar module¶
- class lale.grammar.Grammar(variables: Optional[Dict[str, Operator]] = None)[source]¶
Bases:
Operator
Base class for Lale grammars.
- is_classifier() bool [source]¶
Checks if this operator is a clasifier.
- Returns
True if the classifier tag is set.
- Return type
- is_supervised()[source]¶
Checks if this operator needs labeled data for learning.
- Returns
True if the fit method requires a y argument.
- Return type
- 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
- 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
- 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.
- is_classifier() bool [source]¶
Checks if this operator is a clasifier.
- Returns
True if the classifier tag is set.
- Return type
- is_supervised()[source]¶
Checks if this operator needs labeled data for learning.
- Returns
True if the fit method requires a y argument.
- Return type
- 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.