text_html_output_1.png
import numpy as np

import numpy as np # linear algebra

import pandas as pd

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

df = pd.read_csv('../input/titanic/train.csv')
df

df.drop(['Pclass', 'Name', 'Ticket', 'Fare', 'Cabin', 'Embarked'], axis=1, inplace=True)

df.isna().sum()

round(df.isna().sum() / len(df.index) * 100, 2)

round(df.isna().sum() / len(df.index) * 100, 2)

categrocal_col = df.select_dtypes(exclude=np.number)
categrocal_col

labels_ = ['child', 'young', 'teenage', 'adult', 'old']
bins_ = [0, 10, 18, 28, 45, 80]

df['Age'] = pd.cut(df['Age'], bins=bins_, labels=labels_)

age = pd.get_dummies(df['Age'])

data = pd.concat([df, age], axis=1)

data.drop(['Age'], axis=1, inplace=True)

x = data.drop(['Survived'], axis=1, inplace=True)
y = data['Survived']