Skip to content

Commit

Permalink
Update XGBoost.py (#423)
Browse files Browse the repository at this point in the history
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é <xadupre@users.noreply.github.com>
Co-authored-by: Wenbing Li <10278425+wenbingl@users.noreply.github.com>
  • Loading branch information
3 people authored Jan 6, 2021
1 parent 0bb2231 commit fdbd2b4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion onnxmltools/convert/xgboost/operator_converters/XGBoost.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down

0 comments on commit fdbd2b4

Please sign in to comment.