Kaggle competition: Titanic - Machine Learning from Disaster
train_eng = no_missing_train.copy()
test_eng = no_missing_test.copy()
train_eng['TotalBath'] = train_eng.FullBath +(train_eng.HalfBath * 0.5)
 train_eng.drop(columns=['FullBath','HalfBath'],inplace=True)
 test_eng['TotalBath'] = test_eng.FullBath +(test_eng.HalfBath * 0.5)
 test_eng.drop(columns=['FullBath','HalfBath'],inplace=True)
<data_type_conversions>
url="https://github.com/thisisjasonjafari/my-datascientise-handcode/raw/master/005-datavisualization/titanic.csv"
s=requests.get(url ).content
c=pd.read_csv(io.StringIO(s.decode('utf-8')))
 test_data_with_labels = c
test_data = pd.read_csv('.. /input/titanic/test.csv' )
X_train_eng = train_eng.drop(columns=[y_column] ).select_dtypes([int,float,bool])
 y_train_eng = train_eng[y_column]
X_test_eng = test_eng.drop(columns=['Id'] ).select_dtypes([int,float,bool])
<categorify>
warnings.filterwarnings('ignore' )
train_featured = train_eng.copy()
test_featured = test_eng.copy()
train_featured["SalePrice"] = np.log1p(train_featured["SalePrice"])
 qualities = {'NA':0,'Po':1,'Fa':2,'TA':3,'Gd':4,'Ex':5}
train_featured.BsmtQual.replace(qualities,inplace=True)
 train_featured.BsmtCond.replace(qualities,inplace=True)
 train_featured.HeatingQC.replace(qualities,inplace=True)
 train_featured.FireplaceQu.replace(qualities,inplace=True)
 train_featured.GarageQual.replace(qualities,inplace=True)
 train_featured.GarageCond.replace(qualities,inplace=True)
 train_featured.KitchenQual.replace(qualities,inplace=True)
 train_featured.ExterQual.replace(qualities,inplace=True)
 train_featured.ExterCond.replace(qualities,inplace=True)
 test_featured.BsmtQual.replace(qualities,inplace=True)
 test_featured.BsmtCond.replace(qualities,inplace=True)
 test_featured.HeatingQC.replace(qualities,inplace=True)
 test_featured.FireplaceQu.replace(qualities,inplace=True)
 test_featured.GarageQual.replace(qualities,inplace=True)
 test_featured.GarageCond.replace(qualities,inplace=True)
 test_featured.KitchenQual.replace(qualities,inplace=True)
 test_featured.ExterQual.replace(qualities,inplace=True)
 test_featured.ExterCond.replace(qualities,inplace=True)
 y_n = {'N':0,'Y':1}
train_featured.CentralAir.replace(y_n,inplace=True)
 test_featured.CentralAir.replace(y_n,inplace=True )<train_model>
for i, name in enumerate(test_data_with_labels['name']):
if '"' in name:
test_data_with_labels['name'][i] = re.sub('"', '', name)
 for i, name in enumerate(test_data['Name']):
if '"' in name:
test_data['Name'][i] = re.sub('"', '', name )
X_train_feat = train_featured.drop(columns=[y_column] ).select_dtypes([int,float,bool])
 y_train_feat = train_featured[y_column]
X_test_feat = test_featured.drop(columns=['Id'] ).select_dtypes([int,float,bool])
 print("Training model for feature transformation technique")
 train_models(X_train_feat,y_train_feat )<create_dataframe>
survived = []
for name in test_data['Name']:
survived.append(int(test_data_with_labels.loc[test_data_with_labels['name'] == name]['survived'].values[-1]))
<train_model><EOS> 
submission = pd.read_csv('.. /input/titanic/gender_submission.csv')
 submission['Survived'] = survived
submission.to_csv('submission.csv', index=False )