Decision trees

Let's take a look at decision trees, another intuitive classifier. In this section, we will see how decision trees make predictions. We will discuss important decision tree hyperparameters, and when decision trees may go awry. While we do this, I will demonstrate decision trees by using them to predict who did or did not survive the sinking of the Titanic.

A decision tree is a classification algorithm that asks a series of true or false questions. It uses those questions to decide how to classify a data point. Decision trees are implemented using the scikit-learn object DecisionTreeClassifier. Let's go over this now:

  1. The first thing we will do is load in the Titanic dataset, along with some useful functions:

  1. Then, we will load in the first few rows of the Titanic dataset with pandas, as follows:

  1. We're also going to see the first few rows of the training data:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.236.96