Open ShuningL opened 1 year ago
I cannot replicate this issue with the latest development version. This should be fixed with the next release.
I am having the same issue with v1.11.1
(on an M1 mac).
I am having the same issue with1.11.1 processing XGBoost core 1.6.2 model (not sklearn).
@xadupre I am facing this with the latest v1.11.2 as well. These are the version I have on my system.
onnx==1.13.0
onnxconverter-common==1.13.0
onnxmltools==1.11.2
onnxruntime==1.14.0
onnxruntime-extensions==0.4.2
skl2onnx==1.13
xgboost==1.6.2
This bug was reported on v1.11.1, @xadupre indicated it was fixed on the development branch, and some folks are now seeing it on the subsequently released v1.11.2. My hunch is it's worth checking:
There may be something missing in terms of the recreate. It's odd to see works-for-me not make it into a subsequent cut.
Hi @xadupre , can you please confirm the version in which this issue is fixed?
I checked in PR #597 the example works. It is working with xgboost 1.7.4. If it is not working in your case, is it possible to share an example which fails or point me to one?
@xadupre Thanks. Seems like an issue with the xgboost version. Worked fine with 1.7.4
I was trying to run the sample code of convert_xgboost(onnxmltools/docs/examples/plot_convert_xgboost.py), and I got an error ["AssertionError: Missing required property "tree_info".] which is only for Dmatrix ( for sklearn model, it's ok). Looking forward to your responses.
------------------------- The Output is as follow ----------------------------
XGBClassifier(base_score=0.5, booster='gbtree', colsample_bylevel=1, colsample_bynode=1, colsample_bytree=1, gamma=0, gpu_id=-1, importance_type='gain', interaction_constraints='', learning_rate=0.300000012, max_delta_step=0, max_depth=6, min_child_weight=1, missing=nan, monotone_constraints='()', n_estimators=100, n_jobs=0, num_parallel_tree=1, objective='multi:softprob', random_state=0, reg_alpha=0, reg_lambda=1, scale_pos_weight=None, subsample=1, tree_method='exact', validate_parameters=1, verbosity=None) [1 2 2 0 2 0 0 1 0 1 1 2 2 1 2 2 2 2 2 2 0 1 2 0 2 1 1 0 2 2 2 1 2 0 0 2 2 2]
AssertionError Traceback (most recent call last) Input In [10], in <cell line: 71>() 68 bst = train_xgb(param, dtrain, 10) 70 initial_type = [('float_input', FloatTensorType([None, 4]))] ---> 71 onx = convert_xgboost(bst, initial_types=initial_type) 73 sess = rt.InferenceSession(onx.SerializeToString()) 74 input_name = sess.get_inputs()[0].name
File ~/miniconda3/envs/mlflow/lib/python3.8/site-packages/onnxmltools/convert/main.py:177, in convert_xgboost(*args, *kwargs) 174 raise RuntimeError('xgboost is not installed. Please install xgboost to use this feature.') 176 from .xgboost.convert import convert --> 177 return convert(args, **kwargs)
File ~/miniconda3/envs/mlflow/lib/python3.8/site-packages/onnxmltools/convert/xgboost/convert.py:39, in convert(model, name, initial_types, doc_string, target_opset, targeted_onnx, custom_conversion_functions, custom_shape_calculators) 36 name = str(uuid4().hex) 38 if isinstance(model, xgboost.Booster): ---> 39 model = WrappedBooster(model) 40 target_opset = target_opset if target_opset else get_maximum_opset_supported() 41 topology = parse_xgboost(model, initial_types, target_opset, custom_conversion_functions, custom_shape_calculators)
File ~/miniconda3/envs/mlflow/lib/python3.8/site-packages/onnxmltools/convert/xgboost/parse.py:85, in WrappedBooster.init(self, booster) 83 def init(self, booster): 84 self.booster = booster ---> 85 self.kwargs = _get_attributes(booster) 87 if self.kwargs['numclass'] > 0: 88 self.classes = self._generate_classes(self.kwargs)
File ~/miniconda3/envs/mlflow/lib/python3.8/site-packages/onnxmltools/convert/xgboost/_parse.py:35, in _get_attributes(booster) 33 reg = re.compile(b'("tree_info":\[[0-9,]*\])') 34 objs = list(set(reg.findall(bstate))) ---> 35 assert len(objs) == 1, 'Missing required property "tree_info".' 36 tree_info = json.loads("{{{}}}".format(objs[0].decode('ascii')))['tree_info'] 37 num_class = len(set(tree_info))
AssertionError: Missing required property "tree_info".
---------------------------------------------------------------