From the course: Data Science Foundations: Data Mining in Python

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Decision trees

Decision trees - Python Tutorial

From the course: Data Science Foundations: Data Mining in Python

Start my 1-month free trial

Decision trees

- [Instructor] I'm a visual person. And consequently, one of my favorite methods for classification is decision trees, because it gives you this graphical output that can be so easy to interpret and get insight into what's happening in the classification process. To show you how this works, we'll start by loading a few packages again going back to Scikit-learn, and then loading the spam based data which we will again split into training and testing. And we'll again look at the first few rows. These are the attribute variables, X0 through X56, and here's the class variable Y at the end. And we'll do a decision tree. Now we'll use the decision tree classifier object from Scikit-learn, really easy to do. All we need to do is tell it what our criteria are and the number of leaf nodes. And we can then fit it to the training data, it's very quick model there. And from that we can actually get the mean accuracy and it's 89%…

Contents