@@ -11,6 +11,13 @@ def _identity(X):
11
11
class FunctionTransformer (BaseEstimator , TransformerMixin ):
12
12
"""Constructs a transformer from an arbitrary callable.
13
13
14
+ A FunctionTransformer forwards its X (and optionally y) arguments to a
15
+ user-defined function or function object and returns the result of this
16
+ function. This is useful for stateless transformations such as taking the
17
+ log of frequencies, doing custom scaling, etc.
18
+
19
+ A FunctionTransformer will not do any checks on its function's output.
20
+
14
21
Note: If a lambda is used as the function, then the resulting
15
22
transformer will not be pickleable.
16
23
@@ -24,9 +31,14 @@ class FunctionTransformer(BaseEstimator, TransformerMixin):
24
31
validate : bool, optional default=True
25
32
Indicate that the input X array should be checked before calling
26
33
func. If validate is false, there will be no input validation.
34
+ If it is true, then X will be converted to a 2-dimensional NumPy
35
+ array or sparse matrix. If this conversion is not possible or X
36
+ contains NaN or infinity, an exception is raised.
27
37
28
38
accept_sparse : boolean, optional
29
- Indicate that func accepts a sparse matrix as input.
39
+ Indicate that func accepts a sparse matrix as input. If validate is
40
+ False, this has no effect. Otherwise, if accept_sparse is false,
41
+ sparse matrix inputs will cause an exception to be raised.
30
42
31
43
pass_y: bool, optional default=False
32
44
Indicate that transform should forward the y argument to the
0 commit comments