`# Define preprocessing steps for continuous and categorical variables
# Create transformers for continuous and categorical features
continuous_transformer = Pipeline([
('imputer', SimpleImputer(strategy='constant', fill_value=-10000) )
])
#SimpleImputer(strategy='constant', fill_value=-10000)
categorical_transformer = Pipeline([
('imputer',SimpleImputer(strategy='constant', fill_value='No Value') ),
('onehot',OneHotEncoder(handle_unknown='ignore',drop = 'first'))
])
#SimpleImputer(strategy='constant', fill_value='No Value')
#OneHotEncoder(handle_unknown='ignore')
# Combine transformers for both continuous and categorical features
preprocessor = ColumnTransformer(
transformers=[
('cont', continuous_transformer, numerical_features),
('cat', categorical_transformer, categorical_features)
])
# Create the final preprocessing pipeline
pipeline = PMMLPipeline([
('preprocessor', preprocessor),
('classifier', dt)
])
pipeline.active_fields = np.array(list(final_data_train.columns))
pipeline.target_fields = ["TARGET"]
# Save the PMML pipeline to a file
sklearn2pmml(pipeline, "logistic_regression_model.pmml")`
I'm trying to create PMML pipeline for a logistic regression model.
if I simply pass my classifier, it is successfully creating a pmml file, but when I try to do the preprocessing steps, I'm getting this error:
Standard output is empty
Standard error:
Exception in thread "main" java.lang.IllegalArgumentException: Attribute 'sklearn.compose._column_transformer.ColumnTransformer.transformers_' not set
at org.jpmml.python.PythonObject.get(PythonObject.java:82)
at org.jpmml.python.PythonObject.getList(PythonObject.java:282)
at org.jpmml.python.PythonObject.getList(PythonObject.java:286)
at org.jpmml.python.PythonObject.getTupleList(PythonObject.java:300)
at sklearn.compose.ColumnTransformer.getFittedTransformers(ColumnTransformer.java:68)
at sklearn.compose.ColumnTransformer.encodeFeatures(ColumnTransformer.java:50)
at sklearn.Transformer.encode(Transformer.java:70)
at sklearn.Composite.encodeFeatures(Composite.java:119)
at sklearn2pmml.pipeline.PMMLPipeline.encodePMML(PMMLPipeline.java:154)
at com.sklearn2pmml.Main.run(Main.java:91)
at com.sklearn2pmml.Main.main(Main.java:66)