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)

train = pd.read_csv('../input/train.csv')
holdout = pd.read_csv('../input/test.csv')
train.isnull().sum()

gender_pivot = train.pivot_table(index='Sex', values='Survived')
class_pivot = train.pivot_table(index='Pclass', values='Survived')
family_cols = ['SibSp', 'Parch', 'Survived']
family = train[family_cols].copy()
family['familysize'] = family[['SibSp', 'Parch']].sum(axis=1)
familySize = family[['SibSp', 'Parch']].sum(axis=1)
family['isalone'] = np.where(familySize >= 1, 1, 0)
family_pivot = family.pivot_table(index='familysize', values='Survived')
isalone_pivot = family.pivot_table(index='isalone', values='Survived')

train['Fare'] = train['Fare'].fillna(train['Fare'].mean())
train['Embarked'] = train['Embarked'].fillna('S')
holdout['Fare'] = holdout['Fare'].fillna(train['Fare'].mean())
holdout['Embarked'] = holdout['Embarked'].fillna('S')
train['Age'] = train['Age'].fillna(-0.5)
holdout['Age'] = holdout['Age'].fillna(-0.5)
train.head(2)
holdout.head(2)