This article was written by Will Koehrsen.
Here’s the complete code: just copy and paste into a Jupyter Notebook or Python script, replace with your data and run:
The final result is a complete decision tree as an image.
random forest for modeling it’s used in this example. (The trees will be slightly different from one another!).
export_graphviz
function in Scikit-Learn. There are many parameters here that control the look and information displayed. Take a look at the documentation for specifics.dot
to png
using a system command: running system commands in Python can be handy for carrying out simple tasks. This requires installation of graphviz which includes the dot utility. For the complete options for conversion, take a look at the documentation.matplotlib
to show images).To read the rest of this article with code and illustrations, click here.
Comment
It's a great contribution, I'm working on something similar with R and the Tensorflow package but for analysis
in emergency detection and mine tailings. but this for ecology is a big initial contribution
© 2021 TechTarget, Inc.
Powered by
Badges | Report an Issue | Privacy Policy | Terms of Service
Most Popular Content on DSC
To not miss this type of content in the future, subscribe to our newsletter.
Other popular resources
Archives: 2008-2014 | 2015-2016 | 2017-2019 | Book 1 | Book 2 | More
Most popular articles
You need to be a member of Data Science Central to add comments!
Join Data Science Central