lale.operators module

class lale.operators.IndividualOp(name: str, impl, schemas)[source]

Bases: lale.operators.MetaModelOperator

This is a concrete class that can instantiate a new individual operator and provide access to its metadata.

accept(visitor, *args, **kwargs)
arrange(*args, **kwargs)[source]

Given composable operators, create a plan. TBD.

auto_arrange(planner)[source]

Auto arrange the operators to make a new plan.

Parameters

TBD

class_name() → str[source]
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

IndividualOp

documentation_url()[source]
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

dict

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

dict

get_tags() → Dict[str, List[str]][source]

Return the tags of an operator.

Returns

A list of tags describing the operator.

Return type

list

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

dict

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

dict

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

dict

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

dict

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

dict

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

dict

name() → str[source]

[summary]

Returns

[description]

Return type

[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

dict

output_schema_predict_proba()[source]

Returns the schema for predict proba method’s output.

Returns

Logical schema describing output of this operator’s predict proba method.

Return type

dict

transform_schema(s_X)[source]
validate_schema(X, y=None)[source]
class lale.operators.MetaModel[source]

Bases: abc.ABC

Abstract base class for LALE operators states: MetaModel, Planned, Trainable, and Trained.

abstract arrange(*args, **kwargs)[source]

Given composable operators, create a plan. TBD.

abstract auto_arrange(planner)[source]

Auto arrange the operators to make a new plan.

Parameters

TBD

class lale.operators.MetaModelOperator[source]

Bases: lale.operators.Operator, lale.operators.MetaModel

accept(visitor, *args, **kwargs)
class lale.operators.Operator[source]

Bases: object

Abstract base class for a LALE operator.

Pipelines and individual operators extend this.

accept(visitor, *args, **kwargs)
abstract has_same_impl(other: lale.operators.Operator) → bool[source]

Checks if the type of the operator imnplementations are compatible

abstract name() → str[source]

Returns the name of the operator.

to_json()[source]

Returns the json representation of the operator.

class lale.operators.OperatorChoice(steps, name: str)[source]

Bases: lale.operators.Operator

accept(visitor, *args, **kwargs)
arrange(*args, **kwargs)[source]
auto_arrange()[source]
auto_configure(X, y=None, optimizer=None)[source]
class_name() → str[source]
configure(*args, **kwargs)[source]
has_same_impl(other: lale.operators.Operator) → bool[source]

Checks if the type of the operator imnplementations are compatible

name() → str[source]

Returns the name of the operator.

steps() → List[OperatorChoiceType][source]
class lale.operators.Pipeline(steps: List[OpType], edges: Optional[Iterable[Tuple[OpType, OpType]]], ordered: bool = False)[source]

Bases: lale.operators.MetaModelOperator

This is a concrete class that can instantiate a new pipeline operator and provide access to its meta data.

accept(visitor, *args, **kwargs)
arrange(*args, **kwargs)[source]

Given composable operators, create a plan. TBD.

auto_arrange(planner)[source]

Auto arrange the operators to make a new plan.

Parameters

TBD

class_name() → str[source]
constructor_for_cloning(steps: List[OpType])[source]
edges() → List[Tuple[OpType, OpType]][source]
find_sink_nodes()[source]
get_leaves() → List[OpType][source]
get_roots() → List[OpType][source]
has_same_impl(other: lale.operators.Operator) → bool[source]

Checks if the type of the operator imnplementations are compatible

is_in_topological_order() → bool[source]
name() → str[source]

Returns the name of the operator.

sort_topologically() → None[source]
steps() → List[OpType][source]
subst_steps(m: Dict[OpType, OpType]) → None[source]
validate_schema(X, y=None)[source]
class lale.operators.Planned[source]

Bases: lale.operators.MetaModel

Base class to tag an operator’s state as Planned.

Warning: This class is not to be used directly by users/developers.

abstract auto_configure(X, y=None, optimizer=None) → lale.operators.Trainable[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

abstract configure(*args, **kwargs) → lale.operators.Trainable[source]

Abstract method to configure an operator to make it Trainable.

Parameters

kwargs (args,) – The parameters are used to configure an operator in a Planned state to bind hyper-parameter values such that it becomes Trainable.

class lale.operators.PlannedIndividualOp(_name: str, _impl, _schemas)[source]

Bases: lale.operators.IndividualOp, lale.operators.PlannedOperator

This 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

configure(*args, **kwargs) → lale.operators.TrainableOperator[source]

Abstract method to configure an operator to make it Trainable.

Parameters

kwargs (args,) – The parameters are used to configure an operator in a Planned state to bind hyper-parameter values such that it becomes Trainable.

hyperparam_schema_with_hyperparams()[source]
set_params(**impl_params)[source]
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)
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

configure(*args, **kwargs) → lale.operators.TrainableOperator[source]

Make sure the args i.e. operators form a trainable pipeline and return it. It takes only one argument which is a list of steps like make_pipeline so, need to check that it is consistent with the steps and edges already present

class lale.operators.Trainable[source]

Bases: lale.operators.Planned

Base 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 freeze_trainable()[source]
abstract is_frozen_trainable()[source]
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.

free_hyperparams()[source]
freeze_trainable()[source]
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

get_params_all()[source]
get_params_set_by_user()[source]
hyperparams()[source]
is_frozen_trainable()[source]
is_supervised() → bool[source]

Checks if the this operator needs labeled data for learning (the `y’ parameter for fit)

partial_fit(X, y=None, **fit_params) → lale.operators.TrainedOperator[source]
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.

set_params(**impl_params)[source]
transform(X, y=None)[source]

Deprecated since version 0.0.0: The transform method is deprecated on a trainable operator, because the learned coefficients could be accidentally overwritten by retraining. Call transform on the trained operator returned by fit instead.

transform_schema(s_X)[source]
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.

abstract is_supervised() → bool[source]

Checks if the this operator needs labeled data for learning (the `y’ parameter for fit)

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.

fit_with_batches(X, y=None, serialize=True)[source]

[summary]

Parameters
  • X – [description]

  • y ([type], optional) – For a supervised pipeline, this is an array with the unique class labels in the entire dataset, by default None

Returns

[description]

Return type

[type]

freeze_trainable()[source]
get_params(deep: bool = True) → Dict[str, Any][source]
classmethod import_from_sklearn_pipeline(sklearn_pipeline)[source]
is_frozen_trainable()[source]
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.

transform(X, y=None)[source]

Deprecated since version 0.0.0: The transform method is deprecated on a trainable operator, because the learned coefficients could be accidentally overwritten by retraining. Call transform on the trained operator returned by fit instead.

class lale.operators.Trained[source]

Bases: lale.operators.Trainable

Base class to tag an operator’s state as Trained.

Warning: This class is not to be used directly by users/developers.

abstract freeze_trained()[source]
abstract is_frozen_trained()[source]
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 predict_proba(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 transform(X, y=None)[source]

Abstract transform method to be overriden by trained operators as applicable.

Parameters

X – The type of X is as per input_predict schema of the operator.

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.

freeze_trained()[source]
is_frozen_trained()[source]
is_transformer() → bool[source]

Checks if the operator is a transformer

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.

transform(X, y=None)[source]

Deprecated since version 0.0.0.

The transform method is deprecated on a trainable operator, because the learned coefficients could be accidentally overwritten by retraining. Call transform on the trained operator returned by fit instead.

class lale.operators.TrainedOperator[source]

Bases: lale.operators.TrainableOperator, lale.operators.Trained

accept(visitor, *args, **kwargs)
abstract is_transformer() → bool[source]

Checks if the operator is a transformer

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)
export_to_sklearn_pipeline()[source]
freeze_trained()[source]
is_frozen_trained()[source]
is_transformer() → bool[source]

Checks if the operator is a transformer

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.

transform(X, y=None)[source]

Deprecated since version 0.0.0.

The transform method is deprecated on a trainable operator, because the learned coefficients could be accidentally overwritten by retraining. Call transform on the trained operator returned by fit instead.

transform_with_batches(X, y=None, serialize=True)[source]

[summary]

Parameters
  • X ([type]) – [description]

  • y ([type], optional) – by default None

Returns

[description]

Return type

[type]

lale.operators.fixup_hyperparams_dict(d)[source]
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]
lale.operators.make_union(*orig_steps: Union[lale.operators.Operator, Any]) → lale.operators.Operator[source]
lale.operators.make_union_no_concat(*orig_steps: Union[lale.operators.Operator, Any]) → lale.operators.Operator[source]