From d7471a4be89e9ba82fed3425cc0408c05b7aed9a Mon Sep 17 00:00:00 2001 From: Just do it <1467221872@qq.com> Date: Sun, 27 Sep 2020 16:30:04 +0800 Subject: [PATCH] Update XGBoost.py When the type of feature_id is float there throw an error: "ValueError: invalid literal for int() with base 10:" Because you get a ValueError if you pass a string representation of a float into int, or a string representation of anything but an integer (including empty string). If you do want to pass a string representation of a float to an int, as it points out above, you can convert to a float first, then to an integer. Ref: https://stackoverflow.com/questions/1841565/valueerror-invalid-literal-for-int-with-base-10 Signed-off-by: clc --- onnxmltools/convert/xgboost/operator_converters/XGBoost.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onnxmltools/convert/xgboost/operator_converters/XGBoost.py b/onnxmltools/convert/xgboost/operator_converters/XGBoost.py index cb43ca1f..6f3fdc2e 100644 --- a/onnxmltools/convert/xgboost/operator_converters/XGBoost.py +++ b/onnxmltools/convert/xgboost/operator_converters/XGBoost.py @@ -75,7 +75,7 @@ def _add_node(attr_pairs, is_classifier, tree_id, tree_weight, node_id, feature_id)) else: try: - feature_id = int(feature_id) + feature_id = int(float(feature_id)) except ValueError: raise RuntimeError( "Unable to interpret '{0}', feature "