lale.operators module¶
-
class
lale.operators.IndividualOp(name: str, impl, schemas)[source]¶ Bases:
lale.operators.MetaModelOperatorThis is a concrete class that can instantiate a new individual operator and provide access to its metadata.
-
accept(visitor, *args, **kwargs)¶
-
customize_schema(**kwargs: lale.schemas.Schema) → lale.operators.IndividualOp[source]¶ Return a new operator with a customized schema
- Parameters
schema (Schema) – A dictionary of json schemas for the operator. Override the entire schema and ignore other arguments
input (Schema) – (or input_*) override the input schema for method *. input_* must be an existing method (already defined in the schema for lale operators, exising method for external operators)
output (Schema) – (or output_*) override the output schema for method *. output_* must be an existing method (already defined in the schema for lale operators, exising method for external operators)
constraint (Schema) – Add a constraint in JSON schema format.
relevantToOptimizer (String list) – update the set parameters that will be optimized.
param (Schema) – Override the schema of the hyperparameter. param must be an existing parameter (already defined in the schema for lale operators, __init__ parameter for external operators)
tags (Dict) – Override the tags of the operator.
- Returns
Copy of the operator with a customized schema
- Return type
-
get_param_ranges() → Tuple[Dict[str, Any], Dict[str, Any]][source]¶ Returns two dictionaries, ranges and cat_idx, for hyperparameters.
The ranges dictionary has two kinds of entries. Entries for numeric and Boolean hyperparameters are tuples of the form (min, max, default). Entries for categorical hyperparameters are lists of their values.
The cat_idx dictionary has (min, max, default) entries of indices into the corresponding list of values.
-
get_schema(schema_kind: str) → Dict[str, Any][source]¶ Return a schema of the operator.
- Parameters
schema_kind (string, 'input_fit' or 'input_predict' or 'output' or 'hyperparams') – Type of the schema to be returned.
- Returns
The python object containing the json schema of the operator. For all the schemas currently present, this would be a dictionary.
- Return type
-
get_schema_maybe(schema_kind: str, default: Any = None) → Dict[str, Any][source]¶ Return a schema of the operator or a given default if the schema is unspecified
- Parameters
schema_kind (string, 'input_fit' or 'input_predict' or 'output' or 'hyperparams') – Type of the schema to be returned.
- Returns
The python object containing the json schema of the operator. For all the schemas currently present, this would be a dictionary.
- Return type
Return the tags of an operator.
- Returns
A list of tags describing the operator.
- Return type
-
has_same_impl(other: lale.operators.Operator) → bool[source]¶ Checks if the type of the operator implementations are compatible
-
has_tag(tag: str) → bool[source]¶ Check the presence of a tag for an operator.
- Parameters
tag (string) –
- Returns
Flag indicating the presence or absence of the given tag in this operator’s schemas.
- Return type
boolean
-
hyperparam_defaults()[source]¶ Returns the default values of hyperparameters for the operator.
- Returns
A dictionary with names of the hyperparamers as keys and their default values as values.
- Return type
-
hyperparam_schema(name: Optional[str] = None)[source]¶ Returns the hyperparameter schema for the operator.
- Parameters
name (string, optional) – Name of the hyperparameter.
- Returns
Full hyperparameter schema for this operator or part of the schema corresponding to the hyperparameter given by parameter name.
- Return type
-
input_schema_fit()[source]¶ Returns the schema for fit method’s input.
- Returns
Logical schema describing input required by this operator’s fit method.
- Return type
-
input_schema_predict()[source]¶ Returns the schema for predict method’s input.
- Returns
Logical schema describing input required by this operator’s predict method.
- Return type
-
input_schema_predict_proba()[source]¶ Returns the schema for predict proba method’s input.
- Returns
Logical schema describing input required by this operator’s predict proba method.
- Return type
-
input_schema_transform()[source]¶ Returns the schema for transform method’s input.
- Returns
Logical schema describing input required by this operator’s transform method.
- Return type
-
output_schema()[source]¶ Returns the schema for predict/transform method’s output.
- Returns
Logical schema describing output of this operator’s predict/transform method.
- Return type
-
-
class
lale.operators.MetaModel[source]¶ Bases:
abc.ABCAbstract base class for LALE operators states: MetaModel, Planned, Trainable, and Trained.
-
class
lale.operators.MetaModelOperator[source]¶ Bases:
lale.operators.Operator,lale.operators.MetaModel-
accept(visitor, *args, **kwargs)¶
-
-
class
lale.operators.Operator[source]¶ Bases:
objectAbstract base class for a LALE operator.
Pipelines and individual operators extend this.
-
accept(visitor, *args, **kwargs)¶
-
-
class
lale.operators.OperatorChoice(steps, name: str)[source]¶ Bases:
lale.operators.Operator-
accept(visitor, *args, **kwargs)¶
-
-
class
lale.operators.Pipeline(steps: List[OpType], edges: Optional[Iterable[Tuple[OpType, OpType]]], ordered: bool = False)[source]¶ Bases:
lale.operators.MetaModelOperatorThis is a concrete class that can instantiate a new pipeline operator and provide access to its meta data.
-
accept(visitor, *args, **kwargs)¶
-
-
class
lale.operators.Planned[source]¶ Bases:
lale.operators.MetaModelBase class to tag an operator’s state as Planned.
Warning: This class is not to be used directly by users/developers.
-
class
lale.operators.PlannedIndividualOp(_name: str, _impl, _schemas)[source]¶ Bases:
lale.operators.IndividualOp,lale.operators.PlannedOperatorThis is a concrete class that returns a trainable individual operator through its __call__ method. A configure method can use an optimizer and return the best hyperparameter combination.
-
accept(visitor, *args, **kwargs)¶
-
auto_configure(X, y=None, optimizer=None)[source]¶ Abstract method to use an hyper-param optimizer.
Automatically select hyper-parameter values using an optimizer. This will return an operator in a Trainable state.
- Parameters
TBD –
-
-
class
lale.operators.PlannedOperator[source]¶ Bases:
lale.operators.MetaModelOperator,lale.operators.Planned-
accept(visitor, *args, **kwargs)¶
-
-
class
lale.operators.PlannedPipeline(steps: List[PlannedOpType], edges: Optional[Iterable[Tuple[PlannedOpType, PlannedOpType]]], ordered: bool = False)[source]¶ Bases:
lale.operators.Pipeline,lale.operators.PlannedOperator-
accept(visitor, *args, **kwargs)¶
-
-
class
lale.operators.Trainable[source]¶ Bases:
lale.operators.PlannedBase class to tag an operator’s state as Trainable.
Warning: This class is not to be used directly by users/developers.
-
abstract
fit(X, y=None, **fit_params) → lale.operators.Trained[source]¶ Abstract fit method to be overriden by all trainable operators.
- Parameters
X – The type of X is as per input_fit schema of the operator.
y (optional) – The type of y is as per input_fit schema of the operator. Default is None.
fit_params (Dictionary, optional) – A dictionary of keyword parameters to be used during training.
-
abstract
-
class
lale.operators.TrainableIndividualOp(_name, _impl, _schemas)[source]¶ Bases:
lale.operators.PlannedIndividualOp,lale.operators.TrainableOperator-
accept(visitor, *args, **kwargs)¶
-
fit(X, y=None, **fit_params) → lale.operators.TrainedOperator[source]¶ Abstract fit method to be overriden by all trainable operators.
- Parameters
X – The type of X is as per input_fit schema of the operator.
y (optional) – The type of y is as per input_fit schema of the operator. Default is None.
fit_params (Dictionary, optional) – A dictionary of keyword parameters to be used during training.
-
get_params(deep: bool = True) → Dict[str, Any][source]¶ Get parameters for this operator.
This method follows scikit-learn’s convention that all operators have a constructor which takes a list of keyword arguments. This is not required for operator impls which do not desire scikit-compatibility.
- Parameters
deep (boolean, optional) – If True, will return the parameters for this operator state wrapper and its impl object
- Returns
params – Parameter names mapped to their values.
- Return type
mapping of string to any
-
is_supervised() → bool[source]¶ Checks if the this operator needs labeled data for learning (the `y’ parameter for fit)
-
predict(X)[source]¶ Deprecated since version 0.0.0: The predict method is deprecated on a trainable operator, because the learned coefficients could be accidentally overwritten by retraining. Call predict on the trained operator returned by fit instead.
-
predict_proba(X)[source]¶ Deprecated since version 0.0.0: The predict_proba method is deprecated on a trainable operator, because the learned coefficients could be accidentally overwritten by retraining. Call predict_proba on the trained operator returned by fit instead.
-
-
class
lale.operators.TrainableOperator[source]¶ Bases:
lale.operators.PlannedOperator,lale.operators.Trainable-
accept(visitor, *args, **kwargs)¶
-
abstract
fit(X, y=None, **fit_params) → lale.operators.TrainedOperator[source]¶ Abstract fit method to be overriden by all trainable operators.
- Parameters
X – The type of X is as per input_fit schema of the operator.
y (optional) – The type of y is as per input_fit schema of the operator. Default is None.
fit_params (Dictionary, optional) – A dictionary of keyword parameters to be used during training.
-
-
class
lale.operators.TrainablePipeline(steps: List[TrainableOpType], edges: Optional[Iterable[Tuple[TrainableOpType, TrainableOpType]]], ordered: bool = False)[source]¶ Bases:
lale.operators.PlannedPipeline,lale.operators.TrainableOperator-
accept(visitor, *args, **kwargs)¶
-
fit(X, y=None, **fit_params) → lale.operators.TrainedOperator[source]¶ Abstract fit method to be overriden by all trainable operators.
- Parameters
X – The type of X is as per input_fit schema of the operator.
y (optional) – The type of y is as per input_fit schema of the operator. Default is None.
fit_params (Dictionary, optional) – A dictionary of keyword parameters to be used during training.
-
is_supervised() → bool[source]¶ Checks if the this operator needs labeled data for learning (the `y’ parameter for fit)
-
predict(X)[source]¶ Deprecated since version 0.0.0: The predict method is deprecated on a trainable operator, because the learned coefficients could be accidentally overwritten by retraining. Call predict on the trained operator returned by fit instead.
-
-
class
lale.operators.Trained[source]¶ Bases:
lale.operators.TrainableBase class to tag an operator’s state as Trained.
Warning: This class is not to be used directly by users/developers.
-
abstract
predict(X)[source]¶ Abstract predict method to be overriden by trained operators as applicable.
- Parameters
X – The type of X is as per input_predict schema of the operator.
-
abstract
-
class
lale.operators.TrainedIndividualOp(_name, _impl, _schemas)[source]¶ Bases:
lale.operators.TrainableIndividualOp,lale.operators.TrainedOperator-
accept(visitor, *args, **kwargs)¶
-
fit(X, y=None, **fit_params) → lale.operators.TrainedOperator[source]¶ Abstract fit method to be overriden by all trainable operators.
- Parameters
X – The type of X is as per input_fit schema of the operator.
y (optional) – The type of y is as per input_fit schema of the operator. Default is None.
fit_params (Dictionary, optional) – A dictionary of keyword parameters to be used during training.
-
predict(X)[source]¶ Deprecated since version 0.0.0.
The predict method is deprecated on a trainable operator, because the learned coefficients could be accidentally overwritten by retraining. Call predict on the trained operator returned by fit instead.
-
-
class
lale.operators.TrainedOperator[source]¶ Bases:
lale.operators.TrainableOperator,lale.operators.Trained-
accept(visitor, *args, **kwargs)¶
-
-
class
lale.operators.TrainedPipeline(steps: List[TrainedOpType], edges: List[Tuple[TrainedOpType, TrainedOpType]], ordered: bool = False)[source]¶ Bases:
lale.operators.TrainablePipeline,lale.operators.TrainedOperator-
accept(visitor, *args, **kwargs)¶
-
predict(X, y=None)[source]¶ Deprecated since version 0.0.0.
The predict method is deprecated on a trainable operator, because the learned coefficients could be accidentally overwritten by retraining. Call predict on the trained operator returned by fit instead.
-
predict_proba(X)[source]¶ Deprecated since version 0.0.0.
The predict_proba method is deprecated on a trainable operator, because the learned coefficients could be accidentally overwritten by retraining. Call predict_proba on the trained operator returned by fit instead.
-
-
lale.operators.get_available_estimators(tags: AbstractSet[str] = None) → List[lale.operators.PlannedOperator][source]¶
-
lale.operators.get_available_operators(tag: str, more_tags: AbstractSet[str] = None) → List[lale.operators.PlannedOperator][source]¶
-
lale.operators.get_available_transformers(tags: AbstractSet[str] = None) → List[lale.operators.PlannedOperator][source]¶
-
lale.operators.get_pipeline_of_applicable_type(steps, edges, ordered=False) → lale.operators.PlannedPipeline[source]¶ Based on the state of the steps, it is important to decide an appropriate type for a new Pipeline. This method will decide the type, create a new Pipeline of that type and return it. #TODO: If multiple independently trained components are composed together in a pipeline, should it be of type TrainedPipeline? Currently, it will be TrainablePipeline, i.e. it will be forced to train it again.
-
lale.operators.make_choice(*orig_steps: Union[lale.operators.Operator, Any], name: Optional[str] = None) → lale.operators.OperatorChoice[source]¶
-
lale.operators.make_operator(impl, schemas=None, name=None) → lale.operators.PlannedOperator[source]¶
-
lale.operators.make_pipeline(*orig_steps: Union[lale.operators.Operator, Any]) → lale.operators.PlannedPipeline[source]¶