When trying to write out a pipeline with a GradientBoostingRegressor, I get an error. For example, using the example code from the previous now closed issue:
import numpy as np
from sklearn.ensemble import GradientBoostingRegressor
from sklearn.pipeline import Pipeline
from nyoka import skl_to_pmml
X = np.array([572,565,647,514,571,447,529,586,763,572]).reshape(-1, 1)
y = np.array([513, 593, 565, 571, 517, 586, 517, 460, 521, 620])
est = GradientBoostingRegressor(n_estimators=1, max_depth=1, random_state=1)
pipe = Pipeline([('est', est)])
pipe.fit(X, y)
skl_to_pmml(pipe, ['feature1'], 'est', "..\\nyoka_out.pmml")
yields this error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-210-9b2c81fdcff7> in <module>
----> 1 skl_to_pmml(pipe, ['feature1'], 'est', "..\\nyoka_out.pmml")
/opt/anaconda3/lib/python3.7/site-packages/nyoka/skl/skl_to_pmml.py in skl_to_pmml(pipeline, col_names, target_name, pmml_f_name, model_name, description)
64 mining_imp_val,
65 categoric_values,
---> 66 model_name)
67
68 pmml = pml.PMML(
/opt/anaconda3/lib/python3.7/site-packages/nyoka/skl/skl_to_pmml.py in get_PMML_kwargs(model, derived_col_names, col_names, target_name, mining_imp_val, categoric_values, model_name)
185 mining_imp_val,
186 categoric_values,
--> 187 model_name)}
188 elif any_in(neurl_netwk_model_names, skl_mdl_super_cls_names):
189 algo_kwargs = {'NeuralNetwork': get_neural_models(model,
/opt/anaconda3/lib/python3.7/site-packages/nyoka/skl/skl_to_pmml.py in get_ensemble_models(model, derived_col_names, col_names, target_name, mining_imp_val, categoric_values, model_name)
1033 model_kwargs = get_model_kwargs(model, col_names, target_name, mining_imp_val,categoric_values)
1034 if model.__class__.__name__ == 'GradientBoostingRegressor':
-> 1035 model_kwargs['Targets'] = get_targets(model, target_name)
1036
1037 mining_models = list()
/opt/anaconda3/lib/python3.7/site-packages/nyoka/skl/skl_to_pmml.py in get_targets(model, target_name)
1067 pml.Target(
1068 field=target_name,
-> 1069 rescaleConstant="{:.16f}".format(model.init_.mean),
1070 rescaleFactor="{:.16f}".format(model.learning_rate)
1071 )
AttributeError: 'DummyRegressor' object has no attribute 'mean'
I get the same error when trying to do the same with a different GRB pipeline
Hi @doolingdavid, currently Nyoka has support for scikit-learn with version <= 0.20.4. We are planning to release a new version of Nyoka which will support latest version of scikit-learn.
When trying to write out a pipeline with a GradientBoostingRegressor, I get an error. For example, using the example code from the previous now closed issue: