text_plain_output_1.png
import matplotlib.pyplot as plt

import pandas as pd

train_full_set = pd.read_csv('../input/train.csv')

full_set_initial = pd.get_dummies(data=train_full_set, columns=['Embarked', 'Sex', 'Survived'], drop_first=True)
full_set_initial = full_set_initial.drop(['PassengerId', 'Name', 'Ticket', 'Cabin'], axis=1)
corr = full_set_initial.corr()
plt.colorbar()
plt.xticks(range(len(corr)), corr.columns, rotation='vertical')
plt.yticks(range(len(corr)), corr.columns)

test_full_set = pd.read_csv('../input/test.csv')

full_set = pd.concat([train_full_set, test_full_set])
full_set = full_set.reset_index(drop=True)

""" We have to drop three columns from our study,namely: Cabin,Ticket, PassengerId
We dropped Cabin because of two main reasons:
    a. Cabin has 687 Null Values out of 891 i.e almost 77% values are null.
    b. Cabin number is directly related to the Class as cabin was alotted based on the level
    of class.
    So, cabin can easily be dropped from our analysis.
We dropped Ticket and PassengerId from our analysis because these two could not have affected the survival of the passengers.
It is just a demographic information."""
full_set.drop(['Ticket', 'Cabin', 'PassengerId'], axis=1, inplace=True)

full_set.loc[full_set['Title'].isin(['Dona.', 'Lady.', 'Countess.', 'Capt.', 'Col.', 'Don.', 'Dr.', 'Major.', 'Rev.', 'Sir.', 'Jonkheer.']), 'Title'] = 'Rare'

full_set.loc[full_set['Title'].isin(['Mlle.', 'Ms.', 'Mme.']), 'Title'] = 'Miss.'

""" 1 ---Family Size =1
    2 ---Family Size between 2 and 4(included)
    3 ---Family Size more than 4"""
family_size = []
for row in full_set.FamilyMembers:
    if row in [1]:
        family_size.append(1)
    elif row in [2, 3, 4]:
        family_size.append(2)
    else:
        family_size.append(3)
full_set['FamilySize'] = family_size

full_set[full_set['Embarked'].isnull()]