I’ve used XGBoost to fit a model and want to visualize a single tree. However, I keep getting a really stretched out visualization in my notebook and the output .png file appears blank. I’m looking for a solution to print it in a readable format and aspect ratio.
Click here for stretched out visualization.
The model is an object called clf
and I’ve implemented it in a Jupyter notebook like so:
import os
os.environ["PATH"] += os.pathsep + 'C:/Program Files/Graphviz/bin/'
fig, ax = plt.subplots(figsize=(300, 300))
ax.set_aspect('0.33') # Set aspect ratio to 1:1
xgb.plot_tree(clf, num_trees=1, ax=ax)
plt.show()
plt.savefig("temp.png")
Thank you in advance!
New contributor
amartinstrong is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.