Skip to content

Commit fdbd2b4

Browse files
clhnexaduprewenbingl
authored
Update XGBoost.py (#423)
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 <clc.test.com> Co-authored-by: Xavier Dupré <[email protected]> Co-authored-by: Wenbing Li <[email protected]>
1 parent 0bb2231 commit fdbd2b4

File tree

1 file changed

+1
-1
lines changed
  • onnxmltools/convert/xgboost/operator_converters

1 file changed

+1
-1
lines changed

onnxmltools/convert/xgboost/operator_converters/XGBoost.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def _add_node(attr_pairs, is_classifier, tree_id, tree_weight, node_id,
7575
feature_id))
7676
else:
7777
try:
78-
feature_id = int(feature_id)
78+
feature_id = int(float(feature_id))
7979
except ValueError:
8080
raise RuntimeError(
8181
"Unable to interpret '{0}', feature "

0 commit comments

Comments
 (0)