from sklearn.preprocessing import StandardScaler,MinMaxScaler
from sklearn2pmml.pipeline import PMMLPipeline
from sklearn.impute import SimpleImputer
from sklearn_pandas import DataFrameMapper
mapper = DataFrameMapper([
(model_col,[SimpleImputer(strategy = "most_frequent"),MinMaxScaler()])
])
clf = GradientBoostingClassifier(n_estimators=200,learning_rate=0.1,max_depth=5,random_state=10)
gbdt_pipeline = PMMLPipeline([('mapper', mapper), ("classifier", clf)])
sklearn2pmml(gbdt_pipeline,"gbdt.pmml",with_repr=True)
Преобразовать в PMML, чтобы сообщить об ошибке. Ошибка выглядит следующим образом:
Standard output is empty
Standard error:
28, 2020 4:04:05 org.jpmml.sklearn.Main run
Ϣ: Parsing PKL..
28, 2020 4:04:05 org.jpmml.sklearn.Main run
Ϣ: Parsed PKL in 80 ms.
28, 2020 4:04:05 org.jpmml.sklearn.Main run
Ϣ: Converting..
28, 2020 4:04:05 org.jpmml.sklearn.Main run
: Failed to convert
java.lang.IllegalArgumentException: The value object (Python class sklearn.preprocessing._data.MinMaxScaler) is not a supported Transformer
at org.jpmml.sklearn.CastFunction.apply(CastFunction.java:43)
at com.google.common.collect.Lists$TransformingRandomAccessList$1.transform(Lists.java:612)
at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:47)
at sklearn_pandas.DataFrameMapper.initializeFeatures(DataFrameMapper.java:72)
at sklearn.Initializer.encodeFeatures(Initializer.java:41)
at sklearn.Transformer.updateAndEncodeFeatures(Transformer.java:85)
at sklearn.pipeline.Pipeline.encodeFeatures(Pipeline.java:83)
at sklearn2pmml.pipeline.PMMLPipeline.encodePMML(PMMLPipeline.java:203)
at org.jpmml.sklearn.Main.run(Main.java:145)
at org.jpmml.sklearn.Main.main(Main.java:94)
Caused by: java.lang.ClassCastException: Cannot cast net.razorvine.pickle.objects.ClassDict to sklearn.Transformer
at java.lang.Class.cast(Unknown Source)
at org.jpmml.sklearn.CastFunction.apply(CastFunction.java:41)
... 9 more
Используемый мной scikit-learn - 0.22.2, и когда я использую версию 0.21, ошибок нет. Спасибо за любую помощь!