lale.lib.sklearn.function_transformer module

class lale.lib.sklearn.function_transformer.FunctionTransformer(*, func=None, inverse_func=None, validate=False, accept_sparse=False, check_inverse=True, kw_args=None, inv_kw_args=None, feature_names_out=None)

Bases: PlannedIndividualOp

FunctionTransformer from scikit-learn constructs a transformer from an arbitrary callable that operates at the level of an entire dataset.

This documentation is auto-generated from JSON schemas.

Parameters
  • func (union type, not for optimizer, default None) –

    The callable to use for the transformation.

    • callable

    • or None

  • inverse_func (union type, not for optimizer, default None) –

    The callable to use for the inverse transformation.

    • callable

    • or None

  • validate (boolean, not for optimizer, default False) –

    Indicate that the input X array should be checked before calling func.

    See also constraint-1.

  • accept_sparse (boolean, not for optimizer, default False) –

    Indicate that func accepts a sparse matrix as input.

    See also constraint-1.

  • check_inverse (boolean, not for optimizer, default True) – Whether to check that func followed by inverse_func leads to the original inputs.

  • kw_args (union type, not for optimizer, default None) –

    Dictionary of additional keyword arguments to pass to func.

    • dict

    • or None

  • inv_kw_args (union type, not for optimizer, default None) –

    Dictionary of additional keyword arguments to pass to inverse_func.

    • dict

    • or None

  • feature_names_out (union type, optional, not for optimizer, default None) –

    Determines the list of feature names that will be returned by the get_feature_names_out method. If it is ‘one-to-one’, then the output feature names will be equal to the input feature names. If it is a callable, then it must take two positional arguments: this FunctionTransformer (self) and an array-like of input feature names (input_features). It must return an array-like of output feature names. The get_feature_names_out method is only defined if feature_names_out is not None.

    • callable

    • or ‘one-to-one’ or None

Notes

constraint-1 : union type

If validate is False, then accept_sparse has no effect. Otherwise, if accept_sparse is false, sparse matrix inputs will cause an exception to be raised.

  • validate : False

  • or negated type of ‘X/isSparse’

  • or accept_sparse : True

fit(X, y=None, **fit_params)

Train the operator.

Note: The fit method is not available until this operator is trainable.

Once this method is available, it will have the following signature:

Parameters
  • X (array) –

    • items : array

      • items : union type

        • float

        • or string

  • y (Any, optional) –

transform(X, y=None)

Transform the data.

Note: The transform method is not available until this operator is trained.

Once this method is available, it will have the following signature:

Parameters

X (array) –

  • items : array

    • items : union type

      • float

      • or string

Returns

result

Return type

array of items : Any