You can extract the decision rules from an XGBoost model using the get_dump() method. Here's an example code:
main.py233 chars12 linesThis will print out the decision rules for each tree in the XGBoost model. Each rule is represented as a string in the format of:
main.py97 chars5 lines
Where <feature_index> is the index of the feature being split, <threshold> is the threshold value for the split, and <left_child> and <right_child> are the indices of the left and right child nodes respectively.
Note that the get_dump() method returns each tree as a string. You may need to parse the strings into a more convenient format for your usage.
gistlibby LogSnag