1. Download and install graphviz
Download URL: http://www.graphviz.org/download/
Choose the right version to download
1.1 Double click to install
1.2 Click Next
1.3 Click I Accept
1.4 Add to system path
Check Add to the current user's system path, create a desktop icon is optional, click Next
1.5 Select the installation location
Browse for the location to install and click Next
1.6 Installation
2. Check whether the installation is successful
Use the command dot -version, if the following interface is displayed, the installation is successful
Three, graphviz is simple to use
3.1 Generate tree.dot file
Generate a tree.dot file using the following statement
export_graphviz(estimator, out_file="../data/tree.dot", feature_names=['Age', 'Pclass', 'male', 'female'])
Specific cases can be read: Decision Tree Generation, Decision Tree Visualization, Decision Tree Algorithm API, Titanic Passenger Survival Prediction Case Code
3.2 Execute the tree.dot file
Switch to the data directory where the generated tree.dot file is located, and execute the following command
dot -Tpng tree.dot -o tree.png
若在其他目录下则执行:dot -Tpng C:\Users\username\Desktop\FL_code\pythonStudy\data\tree.dot -o tree.png
其中生成的格式类型可改为pdf、jpg等
as follows
Generate a tree.png decision tree in the data or bin directory, as follows
tree.png is as follows
Attached decision tree visualization URL: http://www.webgraphviz.com/
The URL is invalid when used.
Learning navigation recommendation: http://xqnav.top/