From the course: Machine Learning with Python: Decision Trees
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
How to build a classification tree in Python - Python Tutorial
From the course: Machine Learning with Python: Decision Trees
How to build a classification tree in Python
- [Instructor] In this exercise, we'll use a sample loans data set to build a classification tree that predicts whether a borrower will default or not default on a new loan. Before we get started, note that this video is the first in a three video sequence, that explains how to build, visualize, and prune a classification tree. We start by importing the Pandas package. Then we import the data into a data frame called loan and preview it to make sure that the input worked as expected. Now that we have our data, let's try to understand it. First, we get a concise summary of the structure of the data by calling the info method of the data frame. From the summary, we can tell that there are 30 instances in the dataset by looking at the range index. We can also tell that there are three features in the dataset. Looking at the D type column of the summary, we see that the income and loan amount columns hold integer values…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.