jpmml / jpmml-sklearn

Java library and command-line application for converting Scikit-Learn pipelines to PMML
GNU Affero General Public License v3.0
531 stars 117 forks source link

Support for `sklearn_pandas.transformers.FunctionTransformer` #122

Closed wuangKKK closed 4 years ago

wuangKKK commented 4 years ago

java.lang.IllegalArgumentException: The transformer object (Python class sklearn_pandas.transformers.FunctionTransformer) is not a supported Transformer

How to solve this problem?

vruusmann commented 4 years ago

This class looks like a dummy wrapper for a Python function. As such, it cannot be converted into PMML (because Python functions cannot be pickled and so on).

You have two replacements:

  1. sklearn.preprocessing.FunctionTransformer
  2. sklearn2pmml.preprocessing.ExpressionTransformer

Use the former when dealing with simple functions (eg. Numpy universal functions), and the latter for everything else.