Kaggle competition: Titanic - Machine Learning from Disaster
<SOS> metric: categorizationaccuracy Kaggle data source: titanic-machine-learning-from-disaster<load_from_csv>
for dirname, _, filenames in os.walk('/kaggle/input'):
for filename in filenames:
print(os.path.join(dirname, filename))
%%time
pd.read_sql('SELECT * from users LIMIT 5', conn )<create_dataframe>
train_data = pd.read_csv('/kaggle/input/titanic/train.csv')
 test_data = pd.read_csv('/kaggle/input/titanic/test.csv' )
%%time
q_cols = [
'question_id',
'part',
'tag__0',
'part_correct_pct',
'tag__0_correct_pct',
'question_id_correct_pct'
]
df_questions[q_cols].to_sql('questions', conn, method='multi', index=False)
 _ = conn.execute('CREATE UNIQUE INDEX question_id_index ON questions(question_id)')
 del df_questions
gc.collect()<load_from_csv>
train_data['FamilySize'] = 1+train_data['Parch']+train_data['SibSp']
test_data['FamilySize'] = 1+test_data['Parch']+test_data['SibSp']
%%time
pd.read_sql('SELECT * from questions LIMIT 5', conn )<load_from_csv>
train_data['Age'].fillna(train_data['Age'].mean() , inplace=True)
 train_data['Embarked'].value_counts()
train_data['Embarked'].fillna('S',inplace=True)
 train_data.apply(lambda x: sum(x.isnull()),axis=0 )
db_size = pd.read_sql('SELECT page_count * page_size as size FROM pragma_page_count() , pragma_page_size() ', conn)['size'][0]
print(f'Total size of database is: {db_size/1e9:0.3f} GB' )<categorify>
test_data['Age'].fillna(test_data['Age'].mean() , inplace=True)
 test_data['Fare'].fillna(test_data['Fare'].mean() , inplace=True)
 test_data['Embarked'].value_counts()
test_data['Embarked'].fillna('S',inplace=True)
 test_data.apply(lambda x: sum(x.isnull()),axis=0 )
def select_state(batch_cols, records):
return f<categorify>
features = ["Pclass", "Sex", "SibSp", "Parch", "Embarked"]
train_data = pd.get_dummies(train_data, columns=features, prefix = features)
 test_data = pd.get_dummies(test_data, columns=features, prefix = features )
def update_state(df):
def get_select_params(r):
values_uc = f'({r.user_id}, {r.content_id}, {r.answered_correctly}, {1-r.answered_correctly})'
values_u = f'({r.user_id}, {r.answered_correctly}, {1-r.answered_correctly})'
return values_uc, values_u
values = df.apply(get_select_params, axis=1, result_type='expand')
 return f<feature_engineering>
train_data[['normalized_Age', 'normalized_Fare']] = preprocessing.StandardScaler().fit_transform(train_data[['Age', 'Fare']])
 test_data[['normalized_Age', 'normalized_Fare']] = preprocessing.StandardScaler().fit_transform(test_data[['Age', 'Fare']] )
%%time
df_batch_prior = None
counter = 0
for test_batch in iter_test:
counter += 1
if df_batch_prior is not None:
answers = eval(test_batch[0]['prior_group_answers_correct'].iloc[0])
 df_batch_prior['answered_correctly'] = answers
cursor.executescript(update_state(df_batch_prior[df_batch_prior.content_type_id == 0]))
if not counter % 100:
conn.commit()
df_batch_prior = test_batch[0][batch_cols_prior].astype({k: dtypes[k] for k in batch_cols_prior})
 df_batch = test_batch[0][test_batch[0].content_type_id == 0]
records = df_batch[batch_cols].fillna(0 ).to_records(index=False)
 df_batch = pd.read_sql(select_state(batch_cols, records), conn)
 predictions = model.predict(xgb.DMatrix(df_batch[test_cols]))
df_batch['answered_correctly'] = predictions
env.predict(df_batch[['row_id', 'answered_correctly']] )<import_modules>
bestfeatures = SelectKBest(score_func=chi2, k=10)
 X = train_data[['Age', 'Fare', 'FamilySize','Pclass_1', 'Pclass_2',
'Pclass_3', 'Sex_female', 'Sex_male', 'SibSp_0', 'SibSp_1', 'SibSp_2',
'SibSp_3', 'SibSp_4', 'SibSp_5', 'SibSp_8', 'Parch_0', 'Parch_1',
'Parch_2', 'Parch_3', 'Parch_4', 'Parch_5', 'Parch_6', 'Embarked_C',
'Embarked_Q', 'Embarked_S']]
y = train_data['Survived']
fit = bestfeatures.fit(X,y)
 dfscores = pd.DataFrame(fit.scores_)
 dfcolumns = pd.DataFrame(X.columns)
 featureScores = pd.concat([dfcolumns,dfscores],axis=1)
 featureScores.columns = ['Specs','Score']
print(featureScores.nlargest(10,'Score'))
import eli5
import numpy as np
import pandas as pd
from sklearn import set_config
from sklearn.base import TransformerMixin
from sklearn.compose import ColumnTransformer
from sklearn.impute import SimpleImputer
from sklearn.metrics import mean_absolute_error, mean_squared_log_error, make_scorer
from sklearn.model_selection import GridSearchCV, cross_validate, cross_val_score
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import LabelEncoder, OneHotEncoder, FunctionTransformer<define_variables>
features = ["AgeBin", "FareBin", "FamilyBin"]
train_data = pd.get_dummies(train_data, columns=features, prefix = features)
 test_data = pd.get_dummies(test_data, columns=features, prefix = features )
np.random.seed(42 )<load_from_csv>
X = train_data[['Pclass_1', 'Pclass_2', 'Pclass_3', 'Sex_female', 'Sex_male', 'Embarked_C', 'Embarked_Q', 'Embarked_S', 'AgeBin_1',
'AgeBin_2', 'AgeBin_3', 'AgeBin_4', 'AgeBin_5', 'FareBin_1',
'FareBin_2', 'FareBin_3', 'FareBin_4', 'FareBin_5', 'FamilyBin_1',
'FamilyBin_2', 'FamilyBin_3', 'FamilyBin_4']]
y = train_data['Survived']
k_fold = KFold(n_splits=10)
 classifier = RandomForestClassifier(n_estimators=100, max_depth=5, random_state=0)
 results_kfold_CV = cross_val_score(classifier, X, y, cv=k_fold, n_jobs=-1)
 results_kfold_CV.mean() *100
train_df = pd.read_csv('.. /input/house-prices-advanced-regression-techniques/train.csv')
 test_df = pd.read_csv('.. /input/house-prices-advanced-regression-techniques/test.csv')
 full_df = pd.concat([train_df, test_df], sort=True ).reset_index(drop=True )<compute_test_metric>
X = train_data[['Pclass_1', 'Pclass_2', 'Pclass_3', 'Sex_female', 'Sex_male', 'SibSp_0',
'SibSp_1', 'SibSp_2', 'SibSp_3', 'SibSp_4', 'SibSp_5', 'SibSp_8',
'Parch_0', 'Parch_1', 'Parch_2', 'Parch_3', 'Parch_4', 'Parch_5',
'Parch_6', 'Embarked_C', 'Embarked_Q', 'Embarked_S', 'AgeBin_1',
'AgeBin_2', 'AgeBin_3', 'AgeBin_4', 'AgeBin_5', 'FareBin_1',
'FareBin_2', 'FareBin_3', 'FareBin_4', 'FareBin_5']]
y = train_data['Survived']
k_fold = KFold(n_splits=10)
 classifier = RandomForestClassifier(n_estimators=100, max_depth=5, random_state=0)
 results_kfold_CV = cross_val_score(classifier, X, y, cv=k_fold, n_jobs=-1)
 results_kfold_CV.mean() *100
def neg_rmsle(y_true, y_pred):
y_pred = np.abs(y_pred)
 return -1 * np.sqrt(mean_squared_log_error(y_true, y_pred))<compute_train_metric>
classifier = XGBClassifier()
results_kfold_CV = cross_val_score(classifier, X, y, cv=k_fold, n_jobs=-1)
 results_kfold_CV.mean() *100
def score_model(model, X, Y):
scores = cross_validate(
 model, X, Y,
scoring=['r2', 'neg_mean_absolute_error', 'neg_mean_squared_error'], cv=2,
n_jobs=-1, verbose=0)
 rmsle_score = cross_val_score(model, X, Y, cv=2, scoring=make_scorer(neg_rmsle))
mse_score = np.sqrt(-1 * scores['test_neg_mean_squared_error'].mean())
 mse_std = np.sqrt(scores['test_neg_mean_squared_error'].std())
 mae_score = -1 * scores['test_neg_mean_absolute_error'].mean()
mae_std = scores['test_neg_mean_absolute_error'].std()
r2_score_mean = scores['test_r2'].mean()
r2_std = scores['test_r2'].std()
print('[CV] RMSE: %.4f(%.4f)' %(mse_score, mse_std))
print('[CV] MAE: %.4f(%.4f)' %(mae_score, mae_std))
print('[CV] R^2: %.4f(%.4f)' %(r2_score_mean, r2_std))
print('[CV] RMSLE: %.6f(%.4f)' %(-1 * rmsle_score.mean() , rmsle_score.std()))<feature_engineering>
classifier = DecisionTreeClassifier(max_depth=5)
 results_kfold_CV = cross_val_score(classifier, X, y, cv=k_fold, n_jobs=-1)
 results_kfold_CV.mean() *100
def get_columns_from_transformer(column_transformer, input_colums):
col_name = []
for transformer_in_columns in column_transformer.transformers_[:-1]:
raw_col_name = transformer_in_columns[2]
if isinstance(transformer_in_columns[1],Pipeline):
transformer = transformer_in_columns[1].steps[-1][1]
else:
transformer = transformer_in_columns[1]
try:
names = transformer.get_feature_names(raw_col_name)
 except AttributeError:
names = raw_col_name
if isinstance(names,np.ndarray):
col_name += names.tolist()
elif isinstance(names,list):
col_name += names
elif isinstance(names,str):
col_name.append(names)
 [_, _, reminder_columns] = column_transformer.transformers_[-1]
for col_idx in reminder_columns:
col_name.append(input_colums[col_idx])
 return col_name<categorify>
clf = RandomForestClassifier(n_estimators=200, bootstrap=False, criterion='gini',min_samples_leaf = 1,
min_samples_split=2, max_depth=5, random_state=42 ).fit(X,y)
 clf.score(X,y )
for feature in(
 'PoolQC',
'FireplaceQu',
'Alley',
'Fence',
'MiscFeature',
'BsmtQual',
'BsmtCond',
'BsmtExposure',
'BsmtFinType1',
'BsmtFinType2',
'GarageType',
'GarageFinish',
'GarageQual',
'GarageCond',
'BsmtQual',
'BsmtCond',
'BsmtExposure',
'BsmtFinType1',
'BsmtFinType2',
'MasVnrType', 
):
train_df[feature] = train_df[feature].fillna('None')
 test_df[feature] = test_df[feature].fillna('None')
 full_df[feature] = full_df[feature].fillna('None')
 for feature in(
 'BsmtFinSF1',
'BsmtFinSF2',
'BsmtUnfSF',
'TotalBsmtSF',
'BsmtFullBath',
'BsmtHalfBath',
'MasVnrArea',
'GarageCars',
'GarageArea',
'GarageYrBlt', 
):
train_df[feature] = train_df[feature].fillna(0)
 test_df[feature] = test_df[feature].fillna(0)
 full_df[feature] = full_df[feature].fillna(0)
 for feature in(
 'Electrical',
'KitchenQual',
'Exterior1st',
'Exterior2nd',
'SaleType',
'Utilities', 
):
train_df[feature] = train_df[feature].fillna(train_df[feature].mode() [0])
 test_df[feature] = test_df[feature].fillna(test_df[feature].mode() [0])
 full_df[feature] = full_df[feature].fillna(full_df[feature].mode() [0])
 for dataframe in [train_df, test_df, full_df]:
dataframe['MSZoning'] = dataframe.groupby(['Neighborhood'])['MSZoning'].transform(lambda x: x.fillna(x.mode() [0]))
dataframe['MSSubClass'] = dataframe.groupby(['HouseStyle'])['MSSubClass'].transform(lambda x: x.fillna(x.mode() [0]))
dataframe['LotFrontage'] = dataframe.groupby(['Neighborhood', 'MSSubClass'])['LotFrontage'].transform(lambda x: x.fillna(x.median()))
dataframe['Functional'] = dataframe['Functional'].fillna('Typ' )<drop_column>
k_fold = KFold(n_splits=10)
 classifier = RandomForestClassifier(n_estimators=200, bootstrap=False, criterion='gini',min_samples_leaf = 1,
min_samples_split=2, max_depth=5, random_state=42)
 results_kfold_CV = cross_val_score(classifier, X, y, cv=k_fold, n_jobs=-1)
 results_kfold_CV.mean() *100
num_features = [f for f in train_df.columns if train_df.dtypes[f] != 'object']
num_features.remove('Id')
 num_features.remove('SalePrice')
 cat_features = [f for f in train_df.columns if train_df.dtypes[f] == 'object']<define_variables>
clf = XGBClassifier(n_estimators=70, eta=0.06, gamma=0.1, max_depth = 5, objective = 'binary:logistic', reg_lambda = 2 ).fit(X,y)
 clf.score(X,y )
ordinal_feature_mapping = {
'ExterQual': {'Po': 0, 'Fa': 1, 'TA': 2, 'Gd': 3, 'Ex': 4},
'ExterCond': {'Po': 0, 'Fa': 1, 'TA': 2, 'Gd': 3, 'Ex': 4},
'BsmtQual': {'None': 0, 'Po': 1, 'Fa': 2, 'TA': 3, 'Gd': 4, 'Ex': 5},
'BsmtCond': {'None': 0, 'Po': 1, 'Fa': 2, 'TA': 3, 'Gd': 4, 'Ex': 5},
'BsmtFinType1': {'None': 0, 'Unf': 1, 'LwQ': 2, 'Rec': 3, 'BLQ': 4, 'ALQ': 5, 'GLQ': 6},
'BsmtFinType2': {'None': 0, 'Unf': 1, 'LwQ': 2, 'Rec': 3, 'BLQ': 4, 'ALQ': 5, 'GLQ': 6},
'HeatingQC': {'Po': 0, 'Fa': 1, 'TA': 2, 'Gd': 3, 'Ex': 4},
'KitchenQual': {'Po': 0, 'Fa': 1, 'TA': 2, 'Gd': 3, 'Ex': 4},
'FireplaceQu': {'None': 0, 'Po': 1, 'Fa': 2, 'TA': 3, 'Gd': 4, 'Ex': 5},
'GarageFinish': {'None': 0, 'Unf': 1, 'RFn': 2, 'Fin': 3},
'GarageQual': {'None': 0, 'Po': 1, 'Fa': 2, 'TA': 3, 'Gd': 4, 'Ex': 5},
'GarageCond': {'None': 0, 'Po': 1, 'Fa': 2, 'TA': 3, 'Gd': 4, 'Ex': 5},
'PoolQC': {'None': 0, 'Po': 1, 'Fa': 2, 'TA': 3, 'Gd': 4, 'Ex': 5},
'Fence': {'None': 0, 'MnWw': 1, 'GdWo': 2, 'MnPrv': 3, 'GdPrv': 4},
'PavedDrive': {'N': 0, 'P': 1, 'Y': 2},
'CentralAir': {'N': 0, 'Y': 1},
'Alley': {'None': 0, 'Pave': 1, 'Grvl': 2},
'Street': {'Pave': 0, 'Grvl': 1},
'BsmtExposure': {'None': 0, 'No': 1, 'Mn': 2, 'Av': 3, 'Gd': 4},
'Functional': {'Sal': 0, 'Sev': 1, 'Maj2': 2, 'Maj1': 3, 'Mod': 4, 'Min2': 5, 'Min1': 6, 'Typ': 7}
}
non_ordinal_cat_features = list(set(cat_features)- set(ordinal_feature_mapping.keys()))
for cat_feature in non_ordinal_cat_features:
train_df[cat_feature + 'Enc'] = LabelEncoder().fit_transform(train_df[cat_feature])
 test_df[cat_feature + 'Enc'] = LabelEncoder().fit_transform(test_df[cat_feature])
 full_df[cat_feature + 'Enc'] = LabelEncoder().fit_transform(full_df[cat_feature])
 for ordinal_feature, feature_mapping in ordinal_feature_mapping.items() :
train_df[ordinal_feature + 'Enc'] = train_df[ordinal_feature].map(feature_mapping)
 test_df[ordinal_feature + 'Enc'] = test_df[ordinal_feature].map(feature_mapping)
 full_df[ordinal_feature + 'Enc'] = full_df[ordinal_feature].map(feature_mapping )<create_dataframe>
k_fold = KFold(n_splits=10)
 classifier = XGBClassifier(n_estimators=70, eta=0.06, gamma=0.1, max_depth = 5, objective = 'binary:logistic', reg_lambda = 2)
 results_kfold_CV = cross_val_score(classifier, X, y, cv=k_fold, n_jobs=-1)
 results_kfold_CV.mean() *100
for dataframe in [train_df, test_df, full_df]:
dataframe['AvgRoomSF'] = dataframe['GrLivArea'] / dataframe['TotRmsAbvGrd']
dataframe['OverallHouseQC'] = dataframe['OverallQual'] + dataframe['OverallCond']
dataframe['IsNeighborhoodElite'] =(dataframe['Neighborhood'].isin(['NridgHt', 'CollgeCr', 'Crawfor', 'StoreBr', 'Timber'])) * 1
dataframe['NeighborhoodGroups'] = dataframe['Neighborhood'].map({
'MeadowV': 0,
'IDOTRR': 1,
'BrDale': 1,
'OldTown': 1,
'Edwards': 1,
'BrkSide': 1,
'Sawyer': 1,
'Blueste': 1,
'SWISU': 2,
'NAmes': 2,
'NPkVill': 2,
'Mitchel': 2,
'SawyerW': 2,
'Gilbert': 2,
'NWAmes': 2,
'Blmngtn': 2,
'CollgCr': 2,
'ClearCr': 3,
'Crawfor': 3,
'Veenker': 3,
'Somerst': 3,
'Timber': 3,
'StoneBr': 4,
'NoRidge': 4,
'NridgHt': 4,
})
 dataframe['HasFireplace'] = dataframe['Fireplaces'].apply(lambda x: int(x > 0))
dataframe['TotalBathrooms'] =(dataframe['FullBath'] +(0.5 * dataframe['HalfBath'])+
dataframe['BsmtFullBath'] +(0.5 * dataframe['BsmtHalfBath']))
dataframe['IsPavedDrive'] =(dataframe['PavedDrive'] == 'Y')* 1
year_built_bins = np.linspace(1871, 2010, 10)
 dataframe['YearBuiltBin'] = pd.cut(dataframe['YearBuilt'], bins=year_built_bins, labels=range(1, 10))
dataframe['HouseAge'] = dataframe['YrSold'] - dataframe['YearBuilt'].astype('int')
 dataframe['IsRecentlyBuilt'] =(full_df['YearBuilt'] == full_df['YrSold'].astype(int)) * 1
dataframe['IsRecentlyRemod'] =(full_df['YearRemodAdd'] == full_df['YrSold'].astype(int)) * 1
dataframe['ExterQC'] = dataframe['ExterQualEnc'] + dataframe['ExterCondEnc']
dataframe['FunctionalGroup'] = dataframe['Functional'].map({
'Typ': 2,
'Min1': 1,
'Min2': 1,
'Mod': 1,
'Maj1': 0,
'Maj2': 0,
'Sev': 0,
'Sav': 0,
})
 dataframe['IsGasHeating'] = dataframe['Heating'].map({'GasA': 1, 'GasW': 1, 'Grav': 0, 'Wall': 0, 'OthW': 0, 'Floor': 0})
 dataframe['IsHeatingGood'] = dataframe['HeatingQC'].map({'Po': 0, 'Fa': 0, 'TA': 0, 'Gd': 1, 'Ex': 1})
 dataframe['IsNewElectrBreakers'] = dataframe['Electrical'].map({'SBrkr': 1, 'FuseF': 0, 'FuseA': 0, 'FuseP': 0, 'Mix': 0})
 dataframe['IsGarageCondGood'] = dataframe['GarageCond'].map({'None': 0, 'Po': 0, 'Fa': 0, 'TA': 1, 'Gd': 1, 'Ex': 1})
 dataframe['RoofMatlCost'] = dataframe['RoofMatl'].map({
'CompShg': 0,
'WdShake': 1,
'ClyTile': 1,
'WdShngl': 1,
'Roll': 0,
'Metal': 1,
'Membran': 0,
'Tar&Grv': 0,
})
 dataframe['IsWoodenRoof'] = dataframe['RoofMatl'].map({
'CompShg': 0,
'WdShake': 1,
'ClyTile': 0,
'WdShngl': 1,
'Roll': 0,
'Metal': 0,
'Membran': 0,
'Tar&Grv': 0,
})
 dataframe['IsAdjArterialStreat'] =(( dataframe['Condition1'] == 'Artery')|(dataframe['Condition2'] == 'Artery')) * 1
dataframe['IsAdjFeederStreat'] =(( dataframe['Condition1'] == 'Feedr')|(dataframe['Condition2'] == 'Feedr')) * 1
dataframe['IsNormalCondition'] =(( dataframe['Condition1'] == 'Norm')|(dataframe['Condition2'] == 'Norm')) * 1
dataframe['IsAjdOffSiteFeature'] =(( dataframe['Condition1'] == 'PosA')|(dataframe['Condition2'] == 'PosA')) * 1
dataframe['IsNearOffSiteFeature'] =(( dataframe['Condition1'] == 'PosN')|(dataframe['Condition2'] == 'PosN')) * 1
dataframe['IsNearRailroad'] =(( dataframe['Condition1'].isin(['RRNn', 'RRNe'])) |(dataframe['Condition2'].isin(['RRNn', 'RRNe'])))* 1
dataframe['IsAdjRailroad'] =(( dataframe['Condition1'].isin(['RRAn', 'RRAe'])) |(dataframe['Condition2'].isin(['RRAn', 'RRAe'])))* 1
dataframe['WoodDeckGroups'] = pd.cut(dataframe['WoodDeckSF'], bins=[-1, 1, 200, 500, 2000], labels=[0, 1, 2, 3])
 dataframe['HasEnclosedPorch'] =(dataframe['EnclosedPorch'] > 0)* 1
dataframe['HasScreenPorch'] =(dataframe['ScreenPorch'] > 0)* 1
dataframe['HasEnclosedPorch'] =(dataframe['EnclosedPorch'] > 0)* 1
dataframe['Shed'] =(dataframe['MiscFeature'] == 'Shed')* 1 * full_df['MiscVal']
dataframe['Season'] = dataframe['MoSold'].map({
12: 0, 1: 0, 2: 0,
3: 1, 4: 1, 5: 1,
6: 2, 7: 2, 8: 2,
9: 3, 10: 3, 11: 3,
})
 dataframe['InflationFactor'] = dataframe['YrSold'] - 2006<define_variables>
X_test = test_data[['Pclass_1', 'Pclass_2', 'Pclass_3', 'Sex_female', 'Sex_male', 'SibSp_0',
'SibSp_1', 'SibSp_2', 'SibSp_3', 'SibSp_4', 'SibSp_5', 'SibSp_8',
'Parch_0', 'Parch_1', 'Parch_2', 'Parch_3', 'Parch_4', 'Parch_5',
'Parch_6', 'Embarked_C', 'Embarked_Q', 'Embarked_S', 'AgeBin_1',
'AgeBin_2', 'AgeBin_3', 'AgeBin_4', 'AgeBin_5', 'FareBin_1',
'FareBin_2', 'FareBin_3', 'FareBin_4', 'FareBin_5']]
pred = clf.predict(X_test )
features = [
'GrLivArea',
'1stFlrSF',
'2ndFlrSF',
'LotArea',
'BsmtFinSF1',
'BsmtFinSF2',
'BsmtUnfSF',
'BsmtFinType1Enc',
'BsmtFinType2Enc',
'GarageCars',
'OverallCond',
'Neighborhood',
'LotShape',
'LandSlope',
'BsmtCondEnc',
'BsmtQualEnc',
'SaleCondition',
'CentralAirEnc',
'IsAdjArterialStreat',
'IsAdjFeederStreat',
'IsNormalCondition',
'IsNearOffSiteFeature',
'IsAjdOffSiteFeature',
'IsAdjRailroad',
'TotalBathrooms',
'GarageFinishEnc',
'KitchenQualEnc',
'BedroomAbvGr',
'MSZoning',
'IsRecentlyBuilt',
'LandContour',
'HasFireplace',
'FunctionalGroup',
'HouseAge',
'FenceEnc',
'IsGasHeating',
'IsHeatingGood',
'IsNewElectrBreakers',
'IsGarageCondGood',
'IsWoodenRoof',
'RoofMatlCost',
'BldgType',
'HouseStyle',
'MasVnrType',
'TotRmsAbvGrd',
'WoodDeckGroups',
'HasEnclosedPorch',
'YearBuiltBin',
'HasScreenPorch',
'AvgRoomSF',
'BsmtExposureEnc',
'Shed',
'Season',
'NeighborhoodGroups',
'OverallHouseQC',
'ExterQC',
'InflationFactor',
'IsPavedDrive',
]
X = train_df[features]
Y = train_df['SalePrice']
x_test = test_df[features]<categorify>
testDF = pd.DataFrame()
testDF['PassengerId'] = test_data['PassengerId']
testDF['Survived'] = pred
testDF.to_csv('submission.csv', index=False )