text_html_output_1.png
import matplotlib.pyplot as plt

import numpy as np # linear algebra

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

import seaborn as sns

train = pd.read_csv('../input/train.csv', dtype={'Age': np.float64})
test = pd.read_csv('../input/test.csv', dtype={'Age': np.float64})

train.isnull().sum(axis=0)

def replace_titles(x):
    title = x['Title']
    if title in ['Don', 'Major', 'Capt', 'Jonkheer', 'Rev', 'Col']:
        return 'Mr'
    elif title in ['Countess', 'Mme']:
        return 'Mrs'
    elif title in ['Mlle', 'Ms']:
        return 'Miss'
    elif title == 'Dr':
        if x['Sex'] == 'Male':
            return 'Mr'
        else:
            return 'Mrs'
    else:
        return title

train['Title'] = train.apply(replace_titles, axis=1)
test['Title'] = test.apply(replace_titles, axis=1)

train = train.drop(['Name', 'PassengerId', 'Survived', 'Ticket', 'Cabin'], axis=1)
test = test.drop(['Name', 'PassengerId', 'Ticket', 'Cabin'], axis=1)

corrmat = train.corr()
f, ax = plt.subplots(figsize=(5, 5))
sns.heatmap(corrmat, vmax=0.8, square=True)