Install graphviz under windows and view the decision tree diagram generated by python

1. Download the software

Download the stable version from the official website: https://www2.graphviz.org/Packages/stable/windows/10/msbuild/Release/Win32/graphviz-2.44.1-win32.zip
Although the software is 32bit, it is a 64bit computer It can also be used normally.

2. Install the software

It depends on the version you downloaded, if it is free to install, just unzip it directly. If it is an installation package in msi format, just install it directly.

3. Add environment variables

My computer → \rightarrow Properties→ \rightarrow Advanced system settings→ \rightarrow Environment Variables→ \rightarrow System variables:
Add thebindirectoryunder the installationdirectory (that is, the directory where dot.exe is located)under the path variable of the system variable.
Insert picture description here

4. Check if the installation is successful

Enter the dos system, enter the command dot -version, as shown in the figure below, the installation is successful:
Insert picture description here

5.python save the decision tree model and use graphviz to view

Save : export_graphviz(estimator,out_file='tree.dot',feature_names=['','']])Export the model to dot format in python
View : Enter the directory where the dot file is located under dos, and enterdot -Tpng tree.dot -o tree.png

Insert picture description here

Guess you like

Origin blog.csdn.net/Zeno_wrj/article/details/108557886