February 2018
Intermediate to advanced
450 pages
11h 27m
English
These variables are also known as categorical or binary features. This approach will be a good choice if we have a small number of distinct values for the feature to be transformed. In the Titanic data samples, the Embarked feature has only three distinct values (S, C, and Q) that occur frequently. So, we can transform the Embarked feature into three dummy variables, ('Embarked_S', 'Embarked_C', and 'Embarked_Q') to be able to use the random forest classifier.
The following code will show you how to do this kind of transformation:
# constructing binary featuresdef process_embarked(): global df_titanic_data # replacing the missing values with the most common value in the variable df_titanic_data.Embarked[df.Embarked.isnull()] ...
Read now
Unlock full access