text_plain_output_1.png
from sklearn.cross_validation import cross_val_score

from sklearn.cross_validation import cross_val_score

from sklearn.ensemble import RandomForestClassifier, GradientBoostingClassifier, VotingClassifier, ExtraTreesClassifier, AdaBoostClassifier, BaggingClassifier

from sklearn.gaussian_process import GaussianProcessClassifier

from sklearn.linear_model import LogisticRegression, LogisticRegressionCV

from sklearn.metrics import accuracy_score, make_scorer

from sklearn.naive_bayes import MultinomialNB, BernoulliNB, GaussianNB

from sklearn.neighbors import KNeighborsClassifier

from sklearn.svm import LinearSVC,SVC

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

import xgboost as xgb

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)

test_id = test['PassengerId']
target = train['Survived']

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)

#correlation matrix
corrmat = train.corr()
f, ax = plt.subplots(figsize=(5, 5))
sns.heatmap(corrmat, vmax=.8, square=True);

vote_est = [('ada', AdaBoostClassifier()), ('bc', BaggingClassifier()), ('etc', ExtraTreesClassifier()), ('gbc', GradientBoostingClassifier()), ('rfc', RandomForestClassifier()), ('gpc', GaussianProcessClassifier()), ('lr', LogisticRegressionCV()), ('bnb', BernoulliNB()), ('gnb', GaussianNB()), ('knn', KNeighborsClassifier()), ('svc', SVC(probability=True)), ('xgb', xgb.XGBClassifier())]
model = VotingClassifier(estimators=vote_est, voting='hard')

from sklearn.cross_validation import cross_val_score
from sklearn.metrics import accuracy_score, make_scorer
print(cross_val_score(model, train, target, cv=5, scoring=make_scorer(accuracy_score)))