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.FunctionTransformer into ONNX.

The function stored in estimator.func is traced using trace_numpy_function(): every arithmetic operation, ufunc, or reduction is recorded as an ONNX node in g. If func is None the transformer is an identity and a single Identity node 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 FunctionTransformer instance

  • X – input tensor name

  • name – prefix for added node names

Returns:

output tensor name