Kaggle competition: House Prices - Advanced Regression Techniques
<SOS> metric: rmsle Kaggle data source: house-prices-advanced-regression-techniques<predict_on_test>
warnings.simplefilter('ignore')
predictions = model.predict_generator(val_generator(BATCH_SIZE),steps=val_steps)
<train_model>
df = pd.read_csv('.. /input/house-prices-advanced-regression-techniques/train.csv', index_col='Id')
 df.head()
with tf.Session() as sess:
print(sess.run(f1(y_val, predictions)) )<load_from_csv>
numeric_cols=[]
rScaler = RobustScaler()
mmScaler = MinMaxScaler()
def transform_data(X, ft = 'fit'):
global numeric_cols, rScaler,mmScaler
X['MSSubClass']=X['MSSubClass'].astype(np.object)
 numeric_cols = [cname for cname in X.columns if X[cname].dtype in ['int64', 'float64']]
categorical_cols = [cname for cname in X.columns if X[cname].dtype == 'object']
scaled_cols = ['OverallQual','OverallCond','YearBuilt','YearRemodAdd','BsmtFullBath','BsmtHalfBath','FullBath',
'HalfBath','BedroomAbvGr','KitchenAbvGr','TotRmsAbvGrd','Fireplaces','GarageYrBlt','GarageCars','MoSold','YrSold']
X = pd.get_dummies(X, prefix=categorical_cols, dummy_na=True, columns=categorical_cols)
 numeric_cols = list(set(numeric_cols)-set(scaled_cols))
if ft == 'fit':
X[scaled_cols] = mmScaler.fit_transform(X[scaled_cols])
 X[numeric_cols] = rScaler.fit_transform(X[numeric_cols])
 else:
X[scaled_cols] = mmScaler.transform(X[scaled_cols])
 X[numeric_cols] = rScaler.transform(X[numeric_cols])
 X[scaled_cols] = X[scaled_cols].fillna(0)
 X[numeric_cols] = X[numeric_cols].fillna(0)
 return X
submission = pd.read_csv(os.path.join(data_path, 'sample_submission.csv'), index_col=False )<predict_on_test>
save_errors = []
num_steps = int(np.ceil(len(submission)/BATCH_SIZE))
test_pred = model.predict_generator(test_generator(BATCH_SIZE), steps=num_steps )<compute_test_metric>
df.dropna(axis=0, subset=['SalePrice'], inplace=True)
 y_df = df['SalePrice']
X = df.drop(['SalePrice'], axis=1)
 y = np.log(y_df)
 X_train2, X_test2, y_train, y_test = train_test_split(X, y, train_size=0.8, test_size=0.2, random_state=42)
 X_train1 = transform_data(X_train2)
 X_test1 = transform_data(X_test2, 'transform')
 missing = list(set(X_train1.columns)- set(X_test1.columns))
for col in missing:
X_test1[col]=np.zeros(len(X_test1.index))
with pd.option_context('display.max_columns', None):
display(X_train1.head() ,X_train1.shape, X_test1.head() , X_test1.shape )
def binary_prf1(y_true, y_pred):
num_pos = np.sum(y_true)
 pred_pos = np.sum(y_pred)
 tp = np.sum(y_true * y_pred)
 if pred_pos > 0:
precision = tp/pred_pos
else:
precision = 0
if num_pos > 0:
recall = tp/num_pos
else:
recall = 0
print('no pos cases for this class')
 if precision >0 or recall > 0:
f1 = 2*precision*recall/(precision + recall)
 else:
f1 = 0
return precision, recall, f1
def max_thresh(y_val, predictions, n=100):
x = np.linspace(0,1,n+1)[1 : -1]
f1_matrix = np.zeros(( len(x), 28))
for i in range(28):
class_f1 = []
for thresh in x:
pred_class =(predictions > thresh ).astype(int)
 class_f1.append(( binary_prf1(y_val[ :, i], pred_class[ : , i])[2]))
f1_matrix[ :, i] = np.array(class_f1)
 max_loc = np.argmax(f1_matrix, axis=0)
 max_thresh = [x[i] for i in max_loc]
return max_thresh<compute_test_metric>
nlist=[]
las_scores=[]
las_scores2=[]
for i in np.linspace(0.000001,0.001,21):
est = linear_model.LassoCV(eps=i,cv=5,random_state=5)
 ft = SelectFromModel(est)
 rf = RFECV(est, cv=5)
 df1 = ft.fit_transform(X_train1,y_train)
 df2 = rf.fit_transform(df1,y_train)
 nlist.append(i)
 las_scores.append(rf.score(df1,y_train))
las_scores2.append(rf.score(X_test1[X_train1.columns].loc[:,ft.get_support() ],y_test))
plt.figure(figsize=(10,5))
plt.plot(nlist,las_scores,'b+-')
 plt.plot(nlist,las_scores2,'r+-')
 plt.xlabel('eps')
 plt.ylabel('R^2')
 plt.show()
max_t = max_thresh(y_val, predictions)
 with tf.Session() as sess:
print(sess.run(f1(y_val, predictions, thresholds=max_t)) )<data_type_conversions>
display(pd.DataFrame({'ScoreTrain':[round(x,3)for x in las_scores],'ScoreTest':[round(x,3)for x in las_scores2]},index=[round(x, -int(floor(log10(x)))+1)for x in nlist]))
pred_classes =(test_pred > max_t ).astype(int )<categorify>
est = linear_model.LassoCV(eps=0.00015,cv=5,random_state=5)
 ft = SelectFromModel(est)
 rf = RFECV(est, cv=5)
 print('Starting...')
 df1 = ft.fit_transform(X_train1,y_train)
 df2 = rf.fit_transform(df1,y_train)
 print('Done')
pred_labels = mlb.inverse_transform(pred_classes)
 pred_labels = [' '.join(item)for item in pred_labels] 
<count_values>
dfXtr = transform_data(X.loc[X_train.index,:])
 for col in list(set(X_train.columns)- set(dfXtr.columns)) :
dfXtr[col]=np.zeros(len(dfXtr.index))
dfXtr[X_train.columns]
np.sum(submission["Predicted"] == '' )<feature_engineering>
est.fit(X_train,y_train)
 with pd.option_context('display.max_rows', None):
display(pd.DataFrame({'Coef':est.coef_},index=X_train.columns ).sort_values('Coef', ascending=False))
submission[submission["Predicted"] == ''] = '0 25'<save_to_csv>
def cvScore(df1, y, outL=[]):
scores = []
kf = KFold(n_splits=5,shuffle =True,random_state=11)
 kfs = kf.split(df1.index)
 dfXtr = X.loc[df1.index,:]
for train_index,test_index in kfs:
X_tr2 = dfXtr.reset_index().loc[train_index,:]
X_tr = transform_data(X_tr2.drop('Id', axis=1))
X_tr['Id'] = X_tr2['Id']
col = X_tr.columns.tolist()
X_tr = X_tr[col[-1:] + col[:-1]]
for col in list(set(df1.columns)- set(X_tr.columns)) :
X_tr[col]=np.zeros(len(X_tr.index))
X_tr = X_tr.drop([idx[0] for idx in X_tr.iterrows() if idx[1][0] in outL])
 X_tr = X_tr[df1.columns]
X_tst2 = dfXtr.reset_index().loc[test_index,:]
X_tst = transform_data(X_tst2.drop('Id', axis=1))
X_tst['Id'] = X_tst2['Id']
col = X_tst.columns.tolist()
X_tst = X_tst[col[-1:] + col[:-1]]
for col in list(set(df1.columns)- set(X_tst.columns)) :
X_tst[col]=np.zeros(len(X_tst.index))
X_tst = X_tst[df1.columns]
y_tr = y.reset_index().loc[train_index]
y_tr = y_tr.drop([idx[0] for idx in y_tr.iterrows() if idx[1][0] in outL])
 y_tr = y_tr.drop('Id',axis=1)
 y_tst = y.reset_index(drop=True ).loc[test_index]
est.fit(X_tr,y_tr)
 p = est.predict(X_tst)
 scores.append(round(np.sqrt(mean_squared_error(y_tst, p)) ,4))
return scores
submission.to_csv('submission.csv', index=False )<save_to_csv>
print('Train R^2:',rf.score(X_train_selected,y_train))
scores = cvScore(X_train,y_train)
 error1 = round(np.mean(scores),4)
 print("Scores:", scores, '
Average Train RMSE:', error1)
 print("Accuracy: %0.2f(+/- %0.2f)" %(error1, np.std(scores)* 2))
submission.to_csv('submission.csv', index=False )<install_modules>
print('Test R^2:', rf.score(X_test,y_test))
est.fit(X_train,y_train)
 preds = est.predict(X_test[X_train.columns])
 rmse1 = round(np.sqrt(mean_squared_error(y_test, preds)) ,4)
 print('Test RSME:',rmse1)
 display(pd.DataFrame({'Predicted Prices':np.around(np.e**preds,-2)},index=y_test.index)
.join(pd.DataFrame({'Actual Prices':np.around(np.e**y_test,2)})).head())
!pip install fastai==1.0.34<import_modules>
num_feature_df = [colname for colname in X_train.columns if colname in numeric_cols]
eps_test(X_train[num_feature_df] )
from sklearn.model_selection import train_test_split
import numpy as np
import scipy.optimize as opt
from lib.data.utils import read_dataset_info, save_pred, Oversampling
from lib.constants import *
from lib.data.data_visualization import visualize_samples
from torchvision.transforms import *
from torch.utils.data import DataLoader, WeightedRandomSampler
import fastai
import fastai.vision
from fastai.vision.learner import create_cnn, cnn_config, create_body, create_head
from fastai.torch_core import *
from fastai import DatasetType
from fastai.metrics import accuracy_thresh
from lib.torch.dataset import ProteinDataset, get_sample_weights
from lib.torch.losses import FocalLoss
from lib.torch.metrics import f1_macro, fbeta, fit_thresholds
from lib.torch.augmentation import tta, train_transforms
from lib.torch.fit_custom_cycle import *<load_from_csv>
def get_eps(df,max_percent=9):
eps=0
j=0
for p in range(3):
for i in range(1,11):
j = j + 1/(10**p)
 check_outliers = DBSCAN(eps=j)
 clusters = check_outliers.fit_predict(df)
 outliers_found = [i for i in clusters if i != 0]
if(( len(np.unique(clusters)))<=2)and(len(outliers_found)<len(df.index)) :
if p != 2:
j = j-(1/(10**p))
eps = j
break
eps = round(eps,2)
 if eps > 0:
print('Epsilon=',eps,', Outliers: ',len(outliers_found),', ',round(len(outliers_found)/len(clusters)*100,2),'%')
 if(len(outliers_found)/len(clusters)*100)>= max_percent or eps==0:
print('eps=',eps,' Trying again...')
 for i in range(1,50):
check_outliers = DBSCAN(eps=i)
 clusters = check_outliers.fit_predict(df)
 outliers_found = [x for x in clusters if x !=0]
if(len(outliers_found)/len(clusters)*100)< max_percent:
j = i-1
for p in range(1,3):
for i in range(1,11):
j = j + 1/(10**p)
 check_outliers = DBSCAN(eps=j)
 clusters = check_outliers.fit_predict(df)
 outliers_found = [x for x in clusters if x !=0]
if(len(outliers_found)/len(clusters)*100)<= max_percent:
if p != 2:
j = j-(1/(10**p))
eps = j
break
break
eps = round(eps,2)
 print('Epsilon=',eps,', Outliers: ',len(outliers_found),', ',round(len(outliers_found)/len(clusters)*100,4),'%')
 return eps
labeled_dataset_info = read_dataset_info(".. /input/human-protein-atlas-image-classification/train", ".. /input/human-protein-atlas-image-classification/train.csv", target_col='Target')
 test_dataset_info = read_dataset_info(".. /input/human-protein-atlas-image-classification/test", ".. /input/human-protein-atlas-image-classification/sample_submission.csv" )<prepare_x_and_y>
eps = get_eps(X_train[num_feature_df] )
label_count = np.zeros(len(CLASS_LABEL_DICT))
for info in labeled_dataset_info:
label_count[info['labels']] += 1
labeled_fractions = torch.cuda.FloatTensor(( label_count / len(labeled_dataset_info)).astype(np.float32))
image_size =(256, 256)
 batch_size = 256
train_stats =([0.08069, 0.05258, 0.05487, 0.08282], [0.13704, 0.10145, 0.15313, 0.13814])
 test_stats =([0.05913, 0.0454, 0.04066, 0.05928], [0.11734, 0.09503, 0.129, 0.11528])
 y = [x['labels'] for x in labeled_dataset_info]
stratifiing_y = [labels[np.argmin(label_count[labels])] for labels in y]
train_indices, validation_indices, _, _ = train_test_split(range(len(y)) , y, test_size=0.08, stratify=stratifiing_y,
random_state=13)
 train_dataset_info = labeled_dataset_info
print('Train dataset len = {} / {}(oversampling)'.format(len(train_indices), len(train_dataset_info)))
 print('Validation dataset len = {}'.format(len(validation_indices)))
 print('Test dataset len = {}'.format(len(test_dataset_info)))
 train_dataset = ProteinDataset(train_dataset_info, image_size, train_stats, train_transforms)
 validation_dataset = ProteinDataset(labeled_dataset_info[validation_indices], image_size, train_stats)
 test_dataset = ProteinDataset(test_dataset_info, image_size, train_stats)
 weigths = get_sample_weights(train_dataset_info, label_count)
 train_loader = DataLoader(train_dataset, batch_size, sampler=WeightedRandomSampler(weigths, len(train_dataset_info)))
 validation_loader = DataLoader(validation_dataset, batch_size)
 test_loader = DataLoader(test_dataset, batch_size)
 data_bunch = fastai.DataBunch(train_loader, validation_loader, test_loader )<choose_model_class>
check_outliers = DBSCAN(eps=eps)
 clusters = check_outliers.fit_predict(X_train[num_feature_df])
 results = pd.DataFrame({'Result':clusters,'Count':X_train[num_feature_df].index},index=X_train[num_feature_df].index)
 display(results.groupby('Result' ).count())
 outliers = results[results['Result'] !=0]
print('Outliers: ',outliers.shape[0],', ',outliers.shape[0]/results.shape[0]*100,'%' )
classes_number = 28
def create_model() :
pretrain_model = fastai.vision.models.resnet34
meta = cnn_config(pretrain_model)
 body = create_body(pretrain_model(True), meta['cut'])
 w = body[0].weight
body[0] = nn.Conv2d(4,64,kernel_size=(7,7),stride=(2,2),padding=(3, 3), bias=False)
 body[0].weight = torch.nn.Parameter(torch.cat(( w, w[:,:1,:,:]),dim=1))
resnet_body_output = 512
head = create_head(resnet_body_output*2, nc=classes_number)
 head[3].p = 0.5
model = nn.Sequential(body, head)
 return model
model = create_model()
layer_groups = split_model_idx(model, [0,41,92,100] )<choose_model_class>
get_graphs(X_train.join(y_train),results, num_feature_df )
learn = fastai.Learner(data_bunch, model, loss_func=FocalLoss() , metrics=[accuracy_thresh, f1_macro], layer_groups=layer_groups)
 learn.freeze()
learn.clip_grad(1.)
lr = 5e-3<train_model>
scores2 = cvScore(X_train.drop([idx for idx in X_train.index if idx in list(outliers.index)]),
y_train.drop([idx for idx in y_train.index if idx in list(outliers.index)]))
error2 = round(np.mean(scores2),4)
 est.fit(X_train.drop([idx for idx in X_train.index if idx in list(outliers.index)]),
y_train.drop([idx for idx in y_train.index if idx in list(outliers.index)]))
print('Train R^2:',est.score(X_train.drop([idx for idx in X_train.index if idx in list(outliers.index)]),
y_train.drop([idx for idx in y_train.index if idx in list(outliers.index)])))
 print("Scores:", scores2, '
Average Train RMSE:', error2)
 print('Original CV Train RMSE mean:',error1)
 print("Accuracy: %0.2f(+/- %0.2f)" %(error2, np.std(scores2)* 2))
weight_history = []
learn.load('.. /.. /input/resnet34-optimized-lr-freezedpth/ResNet34_1st_phase')
 learn.unfreeze()
lrs=np.array([lr/2,lr/2, lr])
 for i in range(2):
pred_y, true_y = learn.get_preds(DatasetType.Train)
 sample_loss =(pred_y.sigmoid() - true_y ).abs().sum(dim=1 ).numpy()
weights = get_sample_weights(train_dataset_info, label_count, sample_loss=sample_loss)
 learn.data.train_dl.sampler.weights = torch.tensor(weights)
 fit_custom_cycle(learn, 4, lrs/16, div_factor=15, pct_start=0.05)
 learn.save('ResNet34_2nd_phase' )<predict_on_test>
scores3 = cvScore(X_train,y_train,outliers.index)
 error3 = round(np.mean(scores3),4)
 est.fit(X_train.drop([idx for idx in X_train.index if idx in list(outliers.index)]),
y_train.drop([idx for idx in y_train.index if idx in list(outliers.index)]))
print('Train R^2:',est.score(X_train,y_train))
print("Scores:", scores3, '
Average Train RMSE:', error3)
 print('Original CV Train RMSE mean:',error1)
 print("Accuracy: %0.2f(+/- %0.2f)" %(error3, np.std(scores3)* 2))
pred_y, true_y = learn.get_preds()
class_f1 = fbeta(pred_y, true_y, beta=1, thresh=0.5 ).numpy()
print(class_f1)
 print(np.mean(class_f1))<set_options>
est.fit(X_train.drop([idx for idx in X_train.index if idx in list(outliers.index)]),
y_train.drop([idx for idx in y_train.index if idx in list(outliers.index)]))
print('Test R^2:',est.score(X_test[X_train.columns],y_test))
preds = est.predict(X_test[X_train.columns])
 rmse2 = round(np.sqrt(mean_squared_error(y_test, preds)) ,4)
 print('RMSE:',rmse2,'
Old RMSE:',rmse1)
 display(pd.DataFrame({'Predicted Prices':np.around(np.e**preds,-2)},index=y_test.index)
.join(pd.DataFrame({'Actual Prices':np.e**y_test})).head() )
%reload_ext autoreload
%autoreload 2
%matplotlib inline<import_modules>
be = BaggingRegressor(est, random_state=11)
 be.fit(X_train.drop([idx for idx in X_train.index if idx in list(outliers.index)])
 ,y_train.drop([idx for idx in X_train.index if idx in list(outliers.index)]))
preds4 = be.predict(X_test[X_train.columns])
 error4 = np.sqrt(mean_squared_error(y_test, preds4))
print('LASSO RSME:', rmse1, rmse2, 'BaggingRegressor RMSE:', round(error4,4))
print('Score train',be.score(X_train.drop([idx for idx in X_train.index if idx in list(outliers.index)])
 ,y_train.drop([idx for idx in X_train.index if idx in list(outliers.index)])) ,'Score test:',
be.score(X_test[X_train.columns],y_test))
import os
from pathlib import Path
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from fastai import *
from fastai.vision import *
from fastai.vision.image import *<categorify>
abr = AdaBoostRegressor(est, random_state=11)
 abr.fit(X_train1.drop([idx for idx in X_train.index if idx in list(outliers.index)]),
y_train.drop([idx for idx in y_train.index if idx in list(outliers.index)]))
preds5 = abr.predict(X_test1[X_train1.columns])
 error5 = np.sqrt(mean_squared_error(y_test, preds5))
print('LASSO RSME:', rmse1, rmse2, 'AdaBoostRegressor RMSE:', round(error5,4))
print('Score train',abr.score(X_train1.drop([idx for idx in X_train.index if idx in list(outliers.index)])
 ,y_train.drop([idx for idx in X_train.index if idx in list(outliers.index)])) ,'Score test:',
abr.score(X_test1[X_train1.columns],y_test))
RESNET_ENCODERS = {
34: torchvision.models.resnet34,
50: torchvision.models.resnet50,
101: torchvision.models.resnet101,
152: torchvision.models.resnet152,
}
class Resnet4Channel(nn.Module):
def __init__(self, encoder_depth=34, pretrained=True, num_classes=28, copy_extra_channel=False, adjust_first_layer=False):
super().__init__()
encoder = RESNET_ENCODERS[encoder_depth](pretrained=pretrained)
 w = encoder.conv1.weight
self.conv1 = nn.Conv2d(4, 64, kernel_size=7, stride=2, padding=3,
bias=False)
 if copy_extra_channel:
to_concat = w[:, :1, :, :].clone()
else:
to_concat = torch.zeros(64,1,7,7)
 self.conv1.weight = nn.Parameter(torch.cat(( w,to_concat),dim=1)*(0.75 if adjust_first_layer else 1.))
 self.bn1 = encoder.bn1
self.relu = nn.ReLU(inplace=True)
 self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1)
 self.layer1 = encoder.layer1
self.layer2 = encoder.layer2
self.layer3 = encoder.layer3
self.layer4 = encoder.layer4
self.avgpool = encoder.avgpool
self.fc = nn.Linear(512 *(1 if encoder_depth==34 else 4), num_classes)
 def forward(self, x):
x = self.conv1(x)
 x = self.bn1(x)
 x = self.relu(x)
 x = self.maxpool(x)
 x = self.layer1(x)
 x = self.layer2(x)
 x = self.layer3(x)
 x = self.layer4(x)
 x = self.avgpool(x)
 x = x.view(x.size(0), -1)
 x = self.fc(x)
 return x<define_variables>
gbr = GradientBoostingRegressor(random_state=11)
 gbr.fit(X_train1.drop([idx for idx in X_train.index if idx in list(outliers.index)]),
y_train.drop([idx for idx in y_train.index if idx in list(outliers.index)]))
preds6 = gbr.predict(X_test1[X_train1.columns])
 error6 = np.sqrt(mean_squared_error(y_test, preds6))
print('LASSO RSME:', rmse1, rmse2, 'GradientBoostingRegressor RMSE:', round(error6,4))
print('Score train',gbr.score(X_train1.drop([idx for idx in X_train.index if idx in list(outliers.index)])
 ,y_train.drop([idx for idx in X_train.index if idx in list(outliers.index)])) ,'Score test:',
gbr.score(X_test1[X_train1.columns],y_test))
bs = 64<define_variables>
print('Starting...')
 X1 = transform_data(X)
 df1 = ft.fit_transform(X1,y)
 df2 = rf.fit_transform(df1,y)
 print('Done')
 selected_columns1 = ft.get_support()
X_selected = pd.DataFrame(data=df1, columns = X1.columns[selected_columns1],index=X1.index)
 selected_columns2 = rf.get_support()
X_New = pd.DataFrame(data=df2, columns = X_selected.columns[selected_columns2],index=X1.index)
 display(X_New.head())
 num_feature_dfX = [colname for colname in X_New.columns if colname in numeric_cols]
eps_test(X_New[num_feature_dfX])
path = Path('/kaggle/input/' )<load_from_csv>
eps = get_eps(X1[num_feature_dfX],3)
 check_outliers = DBSCAN(eps=eps)
 clustersX = check_outliers.fit_predict(X1[num_feature_dfX])
 resultsX = pd.DataFrame({'Result':clustersX,'Count':X1[num_feature_dfX].index},index=X1[num_feature_dfX].index)
 display(resultsX.groupby('Result' ).count())
 outliersX = resultsX[resultsX['Result'] !=0]
get_graphs(X1.join(y),resultsX, num_feature_dfX)
df = pd.read_csv(path/'train.csv')
 df.head()<load_from_csv>
scoresX = cvScore(X_New,y,outliersX.index)
 print("Scores:", scoresX, '
Average:', round(np.mean(scoresX),4))
est.fit(X_New.drop(outliersX.index), y.drop(outliersX.index))
print('R^2:', est.score(X_New,y))
pd.DataFrame({'Coef':est.coef_},index=X_New.columns ).sort_values('Coef', ascending=False)
 predsX = est.predict(X_New)
 display(pd.DataFrame({'Predicted Prices':np.around(np.e**predsX,-2)},index=y.index)
.join(pd.DataFrame({'Actual Prices':np.around(np.e**y,2)})).head() )
np.random.seed(42)
 src =(ImageItemList.from_csv(path, 'train.csv', folder='train', suffix='.png')
.random_split_by_pct(0.2)
.label_from_df(sep=' ', classes=[str(i)for i in range(28)]))<set_options>
df_test = pd.read_csv('.. /input/house-prices-advanced-regression-techniques/test.csv', index_col='Id')
 display(df_test.head())
 df_test = transform_data(df_test,'transform')
 missing = list(set(X_New.columns)- set(df_test.columns))
for col in missing:
df_test[col]=np.zeros(len(df_test.index))
display(df_test.head() )
src.train.x.create_func = open_4_channel
src.train.x.open = open_4_channel<set_options>
est.fit(X_New.drop(outliersX.index), y.drop(outliersX.index))
test_preds = est.predict(df_test[X_New.columns])
 e_test_preds = np.e**test_preds
df_out = pd.DataFrame({'SalePrice':e_test_preds},index=df_test.index)
 df_out.head()
<define_variables><EOS> 
df_out.to_csv('results.csv' )