Transformer
FunctionTransformer
Constructs a transformer from an arbitrary callable.
Quickstart
python
from sktime.transformations.func_transform import FunctionTransformer
estimator = FunctionTransformer(func=None, inverse_func=None, *, check_inverse=True, kw_args=None, inv_kw_args=None, X_type=None)Parameters(6)
- funccallable (X: X_type, ** kwargs) -> X_type, default=identity (return X)
- The callable to use for the transformation. This will be passed the same arguments as transform, with args and kwargs forwarded. If func is None, then func will be the identity function.
- inverse_funccallable (X: X_type, ** kwargs) -> X_type, default=identity
- The callable to use for the inverse transformation. This will be passed the same arguments as inverse transform, with args and kwargs forwarded. If inverse_func is None, then inverse_func will be the identity function.
- check_inversebool, default=True
Whether to check that or
funcfollowed byinverse_funcleads to the original inputs. It can be used for a sanity check, raising a warning when the condition is not fulfilled.- kw_argsdict, default=None
- Dictionary of additional keyword arguments to pass to func.
- inv_kw_argsdict, default=None
- Dictionary of additional keyword arguments to pass to inverse_func.
- X_typestr, one of “pd.DataFrame, pd.Series, np.ndarray”, or list thereof
default = [“pd.DataFrame”, “pd.Series”, “np.ndarray”] list of types that func is assumed to allow for X (see signature above) if X passed to transform/inverse_transform is not on the list,
it will be converted to the first list element before passed to funcs
Examples
>>> import numpy as np
>>> from sktime.transformations.func_transform import FunctionTransformer
>>> transformer = FunctionTransformer (np. log1p, np. expm1)
>>> X = np. array ([[0, 1 ], [2, 3 ]])
>>> transformer. fit_transform (X) array([[0., 0.69314718], [1.09861229, 1.38629436]])