The exploratory analysis helps users gain insights into how single or multiple variables may affect the survival rate. However, it does not determine what combinations may generate a prediction model, so as to predict the passengers' survival. On the other hand, machine learning can generate a prediction model from a training dataset, so that the user can apply the model to predict the possible labels from the given attributes. In this recipe, we will introduce how to use a decision tree to predict passenger survival rates from the given variables.
Perform the following steps to predict the passenger survival with the decision tree:
First, we construct a data split
split.data
function with three input parameters:data
,p
, ands
. Thedata
parameter stands for the input dataset, thep
parameter stands for the proportion of generated...