Kaggle competition: House Prices - Advanced Regression Techniques
del model
model = Sequential()
droprate = 0.15
model.add(Conv2D(kernel_size=(2,2), filters=128, strides=(1,1), padding='same',activation='relu', input_shape=(28,28,1)))
 model.add(MaxPool2D(pool_size=(2,2), strides=(2,2)))
 model.add(Dropout(droprate))
model.add(Conv2D(kernel_size=(2,2), filters=64, strides=(1,1), padding='same',activation='relu'))
model.add(MaxPool2D(pool_size=(2,2), strides=(2,2)))
 model.add(Dropout(droprate))
model.add(Conv2D(kernel_size=(2,2), filters=32, strides=(1,1), padding='same',activation='relu'))
model.add(MaxPool2D(pool_size=(2,2), strides=(2,2)))
 model.add(Dropout(droprate))
model.add(Flatten())
 model.add(Dense(256, activation='relu'))
model.add(Dropout(droprate))
model.add(Dense(10, activation='softmax'))
model2 = model
model2.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'] )<train_model>
df_train = pd.read_csv('.. /input/train.csv')
 df_test = pd.read_csv('.. /input/test.csv' )
epochsN = 35
batch_sizeN = 63
history2 = model2.fit_generator(datagen.flow(X_train, Y_train, batch_size=batch_sizeN), validation_data=(X_valid, Y_valid), steps_per_epoch=len(X_train)/batch_sizeN, epochs=epochsN, verbose=2 )<compute_test_metric>
warnings.filterwarnings('ignore')
 %matplotlib inline
model2.evaluate(X_test, Y_test, verbose=0 )<save_model>
test_ID = df_test['Id']
model2.save('model_2.h5' )<choose_model_class>
del df_train['Id']
del df_test['Id']
del model
model = Sequential()
droprate = 0.2
model.add(Conv2D(kernel_size=(2,2), filters=128, strides=(1,1), padding='same',activation='relu', input_shape=(28,28,1)))
 model.add(Conv2D(kernel_size=(2,2), filters=128, strides=(1,1), padding='same',activation='relu'))
model.add(MaxPool2D(pool_size=(2,2), strides=(2,2)))
 model.add(Dropout(droprate))
model.add(Conv2D(kernel_size=(2,2), filters=64, strides=(1,1), padding='same',activation='relu'))
model.add(Conv2D(kernel_size=(2,2), filters=64, strides=(1,1), padding='same',activation='relu'))
model.add(MaxPool2D(pool_size=(2,2), strides=(2,2)))
 model.add(Dropout(droprate))
model.add(Conv2D(kernel_size=(2,2), filters=32, strides=(1,1), padding='same',activation='relu'))
model.add(Conv2D(kernel_size=(2,2), filters=32, strides=(1,1), padding='same',activation='relu'))
model.add(MaxPool2D(pool_size=(2,2), strides=(2,2)))
 model.add(Dropout(droprate))
model.add(Flatten())
 model.add(Dense(256, activation='relu'))
model.add(Dropout(droprate))
model.add(Dense(10, activation='softmax'))
model3 = model
model3.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'] )<train_model>
all_data = pd.concat(( df_train, df_test)).reset_index(drop=True )
epochsN = 40
batch_sizeN = 63
history3 = model3.fit_generator(datagen.flow(X_train, Y_train, batch_size=batch_sizeN), validation_data=(X_valid, Y_valid), steps_per_epoch=len(X_train)/batch_sizeN, epochs=epochsN, verbose=2 )<compute_test_metric>
all_data.drop(columns={'3SsnPorch','BedroomAbvGr','BsmtFinSF2','BsmtFullBath','BsmtHalfBath','BsmtUnfSF','EnclosedPorch','KitchenAbvGr','LotArea','LowQualFinSF','MSSubClass','MiscVal','MoSold','OverallCond','PoolArea','ScreenPorch','YrSold'},inplace=True )
model3.evaluate(X_test, Y_test, verbose=0 )<save_model>
all_data_na =(all_data.isnull().sum() / len(all_data)) * 100
all_data_na = all_data_na.drop(all_data_na[all_data_na == 0].index ).sort_values(ascending=False)[:30]
missing_data = pd.DataFrame({'Missing Ratio' :all_data_na})
 missing_data.head(20 )
model3.save('model_3.h5' )<choose_model_class>
all_data.drop(columns={'PoolQC','MiscFeature','Alley','Fence','FireplaceQu'},inplace=True )
del model
model = Sequential()
droprate = 0.20
model.add(Conv2D(kernel_size=(2,2), filters=128, strides=(1,1), padding='same',activation='relu', input_shape=(28,28,1)))
 model.add(Conv2D(kernel_size=(2,2), filters=128, strides=(1,1), padding='same',activation='relu'))
model.add(MaxPool2D(pool_size=(2,2), strides=(2,2)))
 model.add(Dropout(droprate))
model.add(Conv2D(kernel_size=(2,2), filters=64, strides=(1,1), padding='same',activation='relu'))
model.add(Conv2D(kernel_size=(2,2), filters=64, strides=(1,1), padding='same',activation='relu'))
model.add(MaxPool2D(pool_size=(2,2), strides=(2,2)))
 model.add(Dropout(droprate))
model.add(Conv2D(kernel_size=(2,2), filters=32, strides=(1,1), padding='same',activation='relu'))
model.add(Conv2D(kernel_size=(2,2), filters=32, strides=(1,1), padding='same',activation='relu'))
model.add(MaxPool2D(pool_size=(2,2), strides=(2,2)))
 model.add(Dropout(droprate))
model.add(Conv2D(kernel_size=(2,2), filters=16, strides=(1,1), padding='same',activation='relu'))
model.add(Conv2D(kernel_size=(2,2), filters=16, strides=(1,1), padding='same',activation='relu'))
model.add(MaxPool2D(pool_size=(2,2), strides=(2,2)))
 model.add(Dropout(droprate))
model.add(Flatten())
 model.add(Dense(256, activation='relu'))
model.add(Dropout(droprate))
model.add(Dense(10, activation='softmax'))
model4 = model
model4.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'] )<train_model>
ntrain = df_train.shape[0]
ntest = df_test.shape[0]
y_train = df_train.SalePrice.values
all_data.drop(['SalePrice'], axis=1, inplace=True)
 print("all_data size is : {}".format(all_data.shape))
epochsN = 90
batch_sizeN = 63
history4 = model4.fit_generator(datagen.flow(X_train, Y_train, batch_size=batch_sizeN), validation_data=(X_valid, Y_valid), steps_per_epoch=len(X_train)/batch_sizeN, epochs=epochsN, verbose=2 )<compute_test_metric>
all_data['GarageYrBlt']=all_data['GarageYrBlt'].fillna(0 )
model4.evaluate(X_test, Y_test, verbose=0 )<save_model>
all_data['MasVnrType']=all_data['MasVnrType'].fillna('None')
 all_data['MasVnrArea']=all_data['MasVnrArea'].fillna(0 )
model4.save('model_4.h5' )<choose_model_class>
for col in('BsmtQual','BsmtCond','BsmtExposure','BsmtFinType1','BsmtFinType2'):
all_data[col]=all_data.fillna('None' )
del model
model = Sequential()
droprate = 0.1
model.add(Conv2D(kernel_size=(2,2), filters=64, strides=(1,1), padding='same',activation='relu', input_shape=(28,28,1)))
 model.add(Conv2D(kernel_size=(2,2), filters=64, strides=(2,2), padding='valid',activation='relu'))
model.add(Dropout(droprate))
model.add(Conv2D(kernel_size=(2,2), filters=32, strides=(1,1), padding='same',activation='relu'))
model.add(Conv2D(kernel_size=(2,2), filters=32, strides=(2,2), padding='valid',activation='relu'))
model.add(Dropout(droprate))
model.add(Conv2D(kernel_size=(2,2), filters=16, strides=(1,1), padding='same',activation='relu'))
model.add(Conv2D(kernel_size=(3,3), filters=16, strides=(2,2), padding='valid',activation='relu'))
model.add(Flatten())
 model.add(Dropout(droprate))
model.add(Dense(128, activation='relu'))
model.add(Dropout(droprate))
model.add(Dense(10, activation='softmax'))
model5 = model
model5.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'] )<train_model>
all_data['Electrical']=all_data['Electrical'].fillna(all_data['Electrical'].mode() [0] )
epochsN = 90
batch_sizeN = 63
history5 = model5.fit_generator(datagen.flow(X_train, Y_train, batch_size=batch_sizeN), validation_data=(X_valid, Y_valid), steps_per_epoch=len(X_train)/batch_sizeN, epochs=epochsN, verbose=2 )<compute_test_metric>
for col in('BsmtFinSF1','TotalBsmtSF'):
all_data[col] = all_data[col].fillna(0 )
model5.evaluate(X_test, Y_test, verbose=0 )<save_model>
for col in('GarageType', 'GarageFinish', 'GarageQual', 'GarageCond'):
all_data[col] = all_data[col].fillna('None' )
model5.save('model_5.h5' )<choose_model_class>
all_data['MSZoning'] = all_data['MSZoning'].fillna(all_data['MSZoning'].mode() [0] )
del model
model = Sequential()
droprate = 0.15
model.add(Conv2D(kernel_size=(2,2), filters=64, strides=(1,1), padding='same',activation='relu', input_shape=(28,28,1)))
 model.add(Conv2D(kernel_size=(2,2), filters=64, strides=(1,1), padding='same',activation='relu'))
model.add(Conv2D(kernel_size=(2,2), filters=64, strides=(1,1), padding='same',activation='relu'))
model.add(Conv2D(kernel_size=(2,2), filters=64, strides=(2,2), padding='valid',activation='relu'))
model.add(Dropout(droprate))
model.add(Conv2D(kernel_size=(2,2), filters=32, strides=(1,1), padding='same',activation='relu'))
model.add(Conv2D(kernel_size=(2,2), filters=32, strides=(1,1), padding='same',activation='relu'))
model.add(Conv2D(kernel_size=(2,2), filters=32, strides=(1,1), padding='same',activation='relu'))
model.add(Conv2D(kernel_size=(2,2), filters=16, strides=(2,2), padding='valid',activation='relu'))
model.add(Flatten())
 model.add(Dropout(droprate))
model.add(Dense(256, activation='relu'))
model.add(Dropout(droprate))
model.add(Dense(10, activation='softmax'))
model6 = model
model6.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'] )<train_model>
all_data = all_data.drop(['Utilities'], axis=1 )
epochsN = 45
batch_sizeN = 63
history6 = model6.fit_generator(datagen.flow(X_train, Y_train, batch_size=batch_sizeN), validation_data=(X_valid, Y_valid), steps_per_epoch=len(X_train)/batch_sizeN, epochs=epochsN, verbose=2 )<compute_test_metric>
all_data["Functional"] = all_data["Functional"].fillna("Typ" )
model6.evaluate(X_test, Y_test, verbose=0 )<save_model>
all_data['KitchenQual'] = all_data['KitchenQual'].fillna(all_data['KitchenQual'].mode() [0] )
model6.save('model_6.h5' )<choose_model_class>
all_data['Exterior1st'] = all_data['Exterior1st'].fillna(all_data['Exterior1st'].mode() [0])
 all_data['Exterior2nd'] = all_data['Exterior2nd'].fillna(all_data['Exterior2nd'].mode() [0] )
del model
model = Sequential()
droprate = 0.35
model.add(Conv2D(kernel_size=(2,2), filters=64, strides=(1,1), padding='same',activation='relu', input_shape=(28,28,1)))
 model.add(Conv2D(kernel_size=(2,2), filters=64, strides=(1,1), padding='same',activation='relu'))
model.add(Conv2D(kernel_size=(2,2), filters=64, strides=(2,2), padding='valid',activation='relu'))
model.add(Dropout(droprate))
model.add(Conv2D(kernel_size=(3,3), filters=128, strides=(1,1), padding='same',activation='relu'))
model.add(Conv2D(kernel_size=(3,3), filters=128, strides=(1,1), padding='same',activation='relu'))
model.add(Conv2D(kernel_size=(2,2), filters=128, strides=(2,2), padding='valid',activation='relu'))
model.add(Dropout(droprate))
model.add(Conv2D(kernel_size=(3,3), filters=256, strides=(1,1), padding='valid',activation='relu'))
model.add(Conv2D(kernel_size=(3,3), filters=256, strides=(1,1), padding='valid',activation='relu'))
model.add(Conv2D(kernel_size=(3,3), filters=256, strides=(2,2), padding='valid',activation='relu'))
model.add(Dropout(droprate))
model.add(Flatten())
 model.add(Dense(10, activation='softmax'))
model7 = model
model7.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'] )<train_model>
all_data['SaleType'] = all_data['SaleType'].fillna(all_data['SaleType'].mode() [0] )
epochsN = 60
batch_sizeN = 63
history7 = model7.fit_generator(datagen.flow(X_train, Y_train, batch_size=batch_sizeN), validation_data=(X_valid, Y_valid), steps_per_epoch=len(X_train)/batch_sizeN, epochs=epochsN, verbose=2 )<compute_test_metric>
for col in('GarageArea', 'GarageCars'):
all_data[col] = all_data[col].fillna(0 )
model7.evaluate(X_test, Y_test, verbose=0 )<save_model>
all_data["LotFrontage"] = all_data.groupby("Neighborhood")["LotFrontage"].transform(lambda x: x.fillna(x.median()))
model7.save('model_7.h5' )<define_variables>
null_columns=all_data.columns[all_data.isnull().any() ]
all_data[null_columns].isnull().sum()
trained_models = [model1, model2, model3, model4, model5, model6, model7]<compute_train_metric>
cols =('BsmtQual', 'BsmtCond', 'GarageQual', 'GarageCond',
'ExterQual', 'ExterCond','HeatingQC', 'KitchenQual', 'BsmtFinType1',
'BsmtFinType2', 'Functional', 'BsmtExposure', 'GarageFinish', 'LandSlope',
'LotShape', 'PavedDrive', 'Street', 'CentralAir')
 for c in cols:
lbl = LabelEncoder()
lbl.fit(list(all_data[c].values))
all_data[c] = lbl.transform(list(all_data[c].values))
print('Shape all_data: {}'.format(all_data.shape))
acc_scores = pd.Series()
for num, model in enumerate(trained_models):
acc_scores.loc['Model ' + str(num + 1)] = accuracy_score(np.argmax(Y_test, axis=1), np.argmax(model.predict(X_test), axis=1))<predict_on_test>
all_data['TotalSF'] = all_data['TotalBsmtSF'] + all_data['1stFlrSF'] + all_data['2ndFlrSF']
def summing_classifier(data, model_list):
total_pred_prob = model_list[0].predict(data)
 for model in model_list[1:]:
total_pred_prob += model.predict(data)
 return np.argmax(total_pred_prob, axis=1 )<compute_test_metric>
numeric_feats = all_data.dtypes[all_data.dtypes != "object"].index
skewed_feats = all_data[numeric_feats].apply(lambda x: skew(x.dropna())).sort_values(ascending=False)
 print("
Skew in numerical features:
")
 skewness = pd.DataFrame({'Skew' :skewed_feats})
 skewness.head(10 )
acc_scores.loc['Summing Classifier'] = accuracy_score(np.argmax(Y_test, axis=1), summing_classifier(X_test, trained_models))
acc_scores.loc['Summing Classifier']<predict_on_test>
skewness = skewness[abs(skewness)> 0.75]
print("There are {} skewed numerical features to Box Cox transform".format(skewness.shape[0]))
skewed_features = skewness.index
lam = 0.15
for feat in skewed_features:
all_data[feat] = boxcox1p(all_data[feat], lam )
def voting_classifier(data, model_list):
pred_list = np.argmax(model_list[0].predict(data), axis=1 ).reshape(( 1,len(data)))
 for model in model_list[1:]:
pred_list = np.append(pred_list, [np.argmax(model.predict(data), axis=1)], axis=0)
 return np.array(list(map(lambda x: np.bincount(x ).argmax() , pred_list.T)) )<compute_test_metric>
all_data = pd.get_dummies(all_data)
 print(all_data.shape )
acc_scores.loc['Voting Classifier'] = accuracy_score(np.argmax(Y_test, axis=1), voting_classifier(X_test, trained_models))
acc_scores.loc['Voting Classifier']<save_to_csv>
train = all_data[:ntrain]
test = all_data[ntrain:]
best_model_results = pd.DataFrame({'Label' : np.argmax(trained_models[ind_best_model].predict(X_comp), axis=1)})
 best_model_results = best_model_results.reset_index().rename(columns={'index' : 'ImageId'})
 best_model_results['ImageId'] = best_model_results['ImageId'] + 1
best_model_results.to_csv('best_model_result_kaggle.csv', index=False )<save_to_csv>
from sklearn.linear_model import ElasticNet, Lasso, BayesianRidge, LassoLarsIC
from sklearn.ensemble import RandomForestRegressor, GradientBoostingRegressor
from sklearn.kernel_ridge import KernelRidge
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import RobustScaler
from sklearn.base import BaseEstimator, TransformerMixin, RegressorMixin, clone
from sklearn.model_selection import KFold, cross_val_score, train_test_split
from sklearn.metrics import mean_squared_error
import xgboost as xgb
import lightgbm as lgb
esmbl_sum_results = pd.DataFrame({'Label' : summing_classifier(X_comp, trained_models)})
 esmbl_sum_results = esmbl_sum_results.reset_index().rename(columns={'index' : 'ImageId'})
 esmbl_sum_results['ImageId'] = esmbl_sum_results['ImageId'] + 1
esmbl_sum_results.to_csv('esmbl_sum_result_kaggle.csv', index=False )<save_to_csv>
y = df_train['SalePrice']
y_train = y
X_train_sparse, X_test_sparse, y_train_sparse, y_test_sparse = train_test_split(
 train, y_train,
test_size=0.25,
random_state=42
)
esmbl_vote_results = pd.DataFrame({'Label' : voting_classifier(X_comp, trained_models)})
 esmbl_vote_results = esmbl_vote_results.reset_index().rename(columns={'index' : 'ImageId'})
 esmbl_vote_results['ImageId'] = esmbl_vote_results['ImageId'] + 1
esmbl_vote_results.to_csv('esmbl_vote_result_kaggle.csv', index=False )<set_options>
n_folds = 5
def rmsle_cv(model):
kf = KFold(n_folds, shuffle=True, random_state=42 ).get_n_splits(train.values)
 rmse= np.sqrt(-cross_val_score(model, train.values, y_train, scoring="neg_mean_squared_error", cv = kf))
return(rmse )
warnings.filterwarnings('ignore')
 %matplotlib inline
seed = 5
np.random.seed(seed )<load_from_csv>
model_xgb = xgb.XGBRegressor(colsample_bytree=0.4603, gamma=0.0468,
learning_rate=0.05, max_depth=3,
min_child_weight=1.7817, n_estimators=2200,
reg_alpha=0.4640, reg_lambda=0.8571,
subsample=0.5213, silent=1,
random_state =7, nthread = -1)
 score = rmsle_cv(model_xgb)
 regression(model_xgb,X_test_sparse,y_test_sparse)
 regressionPlot(model_xgb,X_test_sparse,y_test_sparse,"XGBoost" )
train = pd.read_csv(".. /input/train.csv")
 test = pd.read_csv(".. /input/test.csv")
 print(train.shape, test.shape)
 train.tail()<data_type_conversions>
model_lgb = lgb.LGBMRegressor(objective='regression',num_leaves=5,
learning_rate=0.05, n_estimators=720,
max_bin = 55, bagging_fraction = 0.8,
bagging_freq = 5, feature_fraction = 0.2319,
feature_fraction_seed=9, bagging_seed=9,
min_data_in_leaf =6, min_sum_hessian_in_leaf = 11)
 score = rmsle_cv(model_lgb)
 regression(model_lgb,X_test_sparse,y_test_sparse)
 regressionPlot(model_lgb,X_test_sparse,y_test_sparse,"LightGBM" )
X_train =(train.iloc[:,1:].values ).astype('float32')
 y_train = train.iloc[:,0].values.astype('int32')
 X_train = X_train.reshape(-1, 28, 28,1)
 X_train = X_train / 255.0
print(X_train.shape , y_train.shape)
 test = test.values.reshape(-1, 28, 28, 1)
 test = test.astype(float)
 test /= 255.0
print(test.shape )<categorify>
class AveragingModels(BaseEstimator, RegressorMixin, TransformerMixin):
def __init__(self, models):
self.models = models
def fit(self, X, y):
self.models_ = [clone(x)for x in self.models]
for model in self.models_:
model.fit(X, y)
 return self
def predict(self, X):
predictions = np.column_stack([
model.predict(X)for model in self.models_
])
 return np.mean(predictions, axis=1 )
y_train= to_categorical(y_train)
 num_classes = y_train.shape[1]
print("Number of classes: ",num_classes )<split>
averaged_models = AveragingModels(models =(ENet, GBoost, KRR, lasso))
score = rmsle_cv(averaged_models)
 print(" Averaged base models score: {:.4f}({:.4f})
 ".format(score.mean() , score.std()))
X_train, X_val, Y_train, Y_val = train_test_split(X_train, y_train, test_size = 0.15, random_state=seed)
 print("Shapes of train, validation dataset ")
 print(X_train.shape , Y_train.shape)
 print(X_val.shape , Y_val.shape )<choose_model_class>
def rmsle(y, y_pred):
return np.sqrt(mean_squared_error(y, y_pred))
filters_1 = 32
filters_2 = 64
filters_3 = 128
model = models.Sequential()
model.add(conv.Convolution2D(filters_1,(3,3), activation="relu", input_shape=(28, 28, 1), border_mode='same'))
model.add(conv.Convolution2D(filters_1,(3,3), activation="relu", border_mode='same'))
model.add(conv.MaxPooling2D(strides=(2,2)))
 model.add(conv.Convolution2D(filters_2,(3,3), activation="relu", border_mode='same'))
model.add(conv.Convolution2D(filters_2,(3,3), activation="relu", border_mode='same'))
model.add(conv.MaxPooling2D(strides=(2,2)))
 model.add(core.Flatten())
 model.add(core.Dropout(0.2))
model.add(core.Dense(128, activation="relu"))
model.add(core.Dense(10, activation="softmax"))
model.compile(loss="categorical_crossentropy", optimizer="adam", metrics=["accuracy"])
 model.summary()<init_hyperparams>
averaged_models.fit(train.values, y_train)
 stacked_train_pred = averaged_models.predict(train.values)
 stacked_pred = np.expm1(averaged_models.predict(test.values))
print(rmsle(y_train, stacked_train_pred))
%%time
print("apply augumentation or data noisy...")
 datagen = ImageDataGenerator(
 featurewise_center=False,
samplewise_center=False,
featurewise_std_normalization=False,
samplewise_std_normalization=False,
zca_whitening=False,
rotation_range=10,
zoom_range = 0.1,
width_shift_range=0.1,
height_shift_range=0.1,
horizontal_flip=False,
vertical_flip=False)
 datagen.fit(X_train)
 print("training started...")
 epochs = 15
batch_size = 128
checkpoint = ModelCheckpoint('model-best-trained.h5', verbose=0, monitor='loss',save_best_only=True, mode='auto')
 learning_rate_reduction = ReduceLROnPlateau(monitor='val_acc', patience=5, verbose=1, factor=0.5, min_lr=0.00001)
 history = model.fit_generator(datagen.flow(X_train,Y_train, batch_size=batch_size),
epochs = epochs, validation_data =(X_val,Y_val),
verbose = 1, steps_per_epoch=X_train.shape[0] // batch_size
, callbacks=[learning_rate_reduction,checkpoint])
 print("training finished!" )<predict_on_test>
model_xgb.fit(train, y_train)
 xgb_train_pred = model_xgb.predict(train)
 xgb_pred = np.expm1(model_xgb.predict(test))
print(rmsle(y_train, xgb_train_pred))
print("Running prediction test.... ")
 predictions = model.predict_classes(test,verbose=1)
 print("done" )<load_from_csv>
model_lgb.fit(train, y_train)
 lgb_train_pred = model_lgb.predict(train)
 lgb_pred = np.expm1(model_lgb.predict(test.values))
print(rmsle(y_train, lgb_train_pred))
np.savetxt('digits-mnist-cnn-3.csv', np.c_[range(1,len(predictions)+1),predictions], delimiter=',', header = 'ImageId,Label', comments = '', fmt='%d')
 print("saved prediction to file")
 sub = pd.read_csv("digits-mnist-cnn-3.csv")
 sub.tail(10 )<load_from_csv>

 print('Average RMSLE score:')
 print(rmsle(y_train,stacked_train_pred*0.70 +
xgb_train_pred*0.15 + lgb_train_pred*0.15))
train_data = pd.read_csv('.. /input/train.csv')
 test_data = pd.read_csv('.. /input/test.csv' )<feature_engineering>
ensemble = stacked_pred*0.70 + xgb_pred*0.15 + lgb_pred*0.15
<split><EOS> 
sub = pd.DataFrame()
sub['Id'] = test_ID
sub['SalePrice'] = ensemble
sub.to_csv('submission.csv',index=False )