class sklearn.preprocessing.FunctionTransformer(func=None, inverse_func=None, validate=None, accept_sparse=False, pass_y=’deprecated’, check_inverse=True, kw_args=None, inv_kw_args=None)
[source]
Constructs a transformer from an arbitrary callable.
A FunctionTransformer forwards its X (and optionally y) arguments to a user-defined function or function object and returns the result of this function. This is useful for stateless transformations such as taking the log of frequencies, doing custom scaling, etc.
Note: If a lambda is used as the function, then the resulting transformer will not be pickleable.
New in version 0.17.
Read more in the User Guide.
Parameters: |
|
---|
fit (X[, y]) | Fit transformer by checking X. |
fit_transform (X[, y]) | Fit to data, then transform it. |
get_params ([deep]) | Get parameters for this estimator. |
inverse_transform (X[, y]) | Transform X using the inverse function. |
set_params (**params) | Set the parameters of this estimator. |
transform (X[, y]) | Transform X using the forward function. |
__init__(func=None, inverse_func=None, validate=None, accept_sparse=False, pass_y=’deprecated’, check_inverse=True, kw_args=None, inv_kw_args=None)
[source]
fit(X, y=None)
[source]
Fit transformer by checking X.
If validate
is True
, X
will be checked.
Parameters: |
|
---|---|
Returns: |
|
fit_transform(X, y=None, **fit_params)
[source]
Fit to data, then transform it.
Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.
Parameters: |
|
---|---|
Returns: |
|
get_params(deep=True)
[source]
Get parameters for this estimator.
Parameters: |
|
---|---|
Returns: |
|
inverse_transform(X, y=’deprecated’)
[source]
Transform X using the inverse function.
Parameters: |
|
---|---|
Returns: |
|
set_params(**params)
[source]
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form <component>__<parameter>
so that it’s possible to update each component of a nested object.
Returns: |
|
---|
transform(X, y=’deprecated’)
[source]
Transform X using the forward function.
Parameters: |
|
---|---|
Returns: |
|
sklearn.preprocessing.FunctionTransformer
© 2007–2018 The scikit-learn developers
Licensed under the 3-clause BSD License.
http://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.FunctionTransformer.html