Created
November 2, 2016 03:20
-
-
Save pavlov99/65fe67de331da2f55332630d4a1a4335 to your computer and use it in GitHub Desktop.
Dump xgboost trees visualisation to the file system in pdf format.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model = xgb.Booster(model_file='your.model') | |
model.feature_names = xgtrain.feature_names # Note: xgtrain is your train file with features. | |
model.feature_types = xgtrain.feature_types | |
# Number of trees in the model | |
num_trees = len(model.get_dump()) | |
# dump all of the trees to tree folder | |
for tree_index in range(num_trees): | |
dot = xgb.to_graphviz(model, num_trees=tree_index) | |
dot.render("trees/tree{}".format(tree_index)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment