yobx.sklearn.preprocessing.function_transformer#
Converter for sklearn.preprocessing.FunctionTransformer.
The converter traces the user-supplied function with a
NumpyArray proxy so that every numpy operation is
recorded as an ONNX node directly in the graph being built.
When func is None (identity transformer) an Identity node is
emitted instead.
- yobx.sklearn.preprocessing.function_transformer.sklearn_function_transformer(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator: FunctionTransformer, X: str, name: str = 'func_transformer') str[source]#
Converts a
sklearn.preprocessing.FunctionTransformerinto ONNX.The function stored in
estimator.funcis traced usingtrace_numpy_function(): every arithmetic operation, ufunc, or reduction is recorded as an ONNX node in g. IffuncisNonethe transformer is an identity and a singleIdentitynode is emitted.- Parameters:
g – graph builder to add nodes to
sts – shapes defined by scikit-learn (may be empty)
outputs – desired output tensor names
estimator – a
FunctionTransformerinstanceX – input tensor name
name – prefix for added node names
- Returns:
output tensor name