Decision tree for titanic dataset in Python
Build decision tree model to predict survival based on certain parameters :
import library
In this file using following columns build a model to predict if person would survive or not 1.Pclass 2.Sex 3.Age 4.Fare
so we will drop unnecessary columns :
Now we separate dependent and independent data frame for pass into our model
Gender column contain categorical data so we have too convert it into numerical for this we will use map method of pandas. and also it contain missing value which we will handle using fillna method.
Now train test split :
Building Decision tree model for titanic dataset in Python
Confusion matrix :
if you want to download data set then click here.
Comments
Post a Comment