In [1]:
import numpy as np
import pandas as pd

In [2]:
xgboost = pd.read_csv('XGBoost_w_Hyperparameters.csv')
randomforest = pd.read_csv('Random_Forest_w_Hyperparameters.csv')
genderclass = pd.read_csv('genderclassmodel.csv')

In [9]:
dfcomb = pd.merge(xgboost, randomforest, how='outer', on='PassengerId')

dfcomb = pd.merge(dfcomb, genderclass, how='outer', on='PassengerId')

In [10]:
dfcomb.head()


Out[10]:
PassengerId Survived_x Survived_y Survived
0 892 0 0 0
1 893 1 0 1
2 894 0 0 0
3 895 0 0 0
4 896 1 1 1

In [41]:
dfcomb['SurvivedF'] = dfcomb.mode(axis=1)

In [42]:
dfcomb.head()


Out[42]:
PassengerId Survived_x Survived_y Survived SurvivedF
0 892 0 0 0 0
1 893 1 0 1 1
2 894 0 0 0 0
3 895 0 0 0 0
4 896 1 1 1 1

In [43]:
dfcomb.drop(['Survived_x', 'Survived_y', 'Survived'], axis=1, inplace=True)

In [46]:
dfcomb.head()


Out[46]:
PassengerId SurvivedF
0 892 0
1 893 1
2 894 0
3 895 0
4 896 1

In [47]:
dfcomb.rename(columns = {'SurvivedF' : 'Survived'}, inplace=True)

In [48]:
dfcomb.head()


Out[48]:
PassengerId Survived
0 892 0
1 893 1
2 894 0
3 895 0
4 896 1

In [50]:
dfcomb[['PassengerId','Survived']].to_csv('Ensemble_XG_RF_GenClass.csv',index=False)