Kaggle competition: House Prices - Advanced Regression Techniques
<SOS> metric: rmsle Kaggle data source: house-prices-advanced-regression-techniques<define_variables>
import pandas as pd
import numpy as np
from scipy.stats import skew
from scipy.special import boxcox1p
from scipy.stats import boxcox_normmax
from abc import abstractmethod
import lightgbm as lgb
import xgboost as xgb
from catboost import CatBoostRegressor as cat
from sklearn.ensemble import GradientBoostingRegressor
from sklearn.ensemble import RandomForestRegressor
from sklearn.kernel_ridge import KernelRidge
from sklearn.svm import SVR
from sklearn.linear_model import ElasticNet, Lasso, Ridge, BayesianRidge, LassoLarsIC, LinearRegression, RANSACRegressor
from sklearn.preprocessing import RobustScaler
from sklearn.pipeline import make_pipeline
from sklearn.model_selection import StratifiedKFold
from sklearn.metrics import mean_squared_log_error
from sklearn import metrics
DEVICE = 'TPU'<train_on_grid>
train = pd.read_csv('.. /input/house-prices-advanced-regression-techniques/train.csv')
 test = pd.read_csv('.. /input/house-prices-advanced-regression-techniques/test.csv')
 features = pd.concat([train.drop(['Id', 'SalePrice'], axis=1), test.drop('Id', axis=1)])
 features['MSSubClass'] = features['MSSubClass'].apply(str )
if DEVICE == 'TPU':
print('Connecting to TPU...')
 try:
tpu = tf.distribute.cluster_resolver.TPUClusterResolver()
print('Running on TPU :',tpu.master())
 except ValueError:
print('Could not connect to TPU')
 tpu = None
if tpu:
try:
print('Initializing TPU...')
 tf.config.experimental_connect_to_cluster(tpu)
 tf.tpu.experimental.initialize_tpu_system(tpu)
 strategy = tf.distribute.experimental.TPUStrategy(tpu)
 print('TPU initialized!')
 except _:
print('Failed to initialized TPU')
 else:
DEVICE='GPU'
if DEVICE != 'TPU':
print('Using default strategy for CPU and single GPU')
 strategy = tf.distribute.get_strategy()
if DEVICE == 'GPU':
print('Num GPUs available : ',len(tf.config.experimental.list_physical_devices('GPU')))
 AUTO = tf.data.experimental.AUTOTUNE
REPLICAS = strategy.num_replicas_in_sync
print('REPLICAS : ',REPLICAS )<define_variables>
temporal_features = [feature for feature in features.columns if 'Yr' in feature or 'Year' in feature or 'Mo' in feature]
numeric_features = [feature for feature in features.columns if features[feature].dtype !=
'O' and feature not in temporal_features]
categorical_features = [feature for feature in features.columns if features[feature].dtype == 'O' and feature not in temporal_features]
Batch_size = 16 * strategy.num_replicas_in_sync
epochs = 13
AUTO = tf.data.experimental.AUTOTUNE
MODEL = 'jplu/tf-xlm-roberta-large'<load_from_csv>
def fixing_skewness(df):

 numeric_feats = df.dtypes[df.dtypes != "object"].index
skewed_feats = df[numeric_feats].apply(lambda x: skew(x)).sort_values(ascending=False)
 high_skew = skewed_feats[abs(skewed_feats)> 0.5]
skewed_features = high_skew.index
for feat in skewed_features:
df[feat] = boxcox1p(df[feat], boxcox_normmax(df[feat] + 1))
return df
def overfit_reducer(df):

 overfit = []
for i in df.columns:
counts = df[i].value_counts()
zeros = counts.iloc[0]
if zeros / len(df)* 100 > 99:
overfit.append(i)
 overfit = list(overfit)
 return overfit
train = pd.read_csv(r'.. /input/contradictory-my-dear-watson/train.csv')
 test = pd.read_csv(r'.. /input/contradictory-my-dear-watson/test.csv')
 submission = pd.read_csv(r'.. /input/contradictory-my-dear-watson/sample_submission.csv' )<create_dataframe>
def create_temporal_features(features):
df = features[temporal_features].copy()
for feature in temporal_features:
if feature == 'YrSold' or feature == 'MoSold':
pass
else:
df[feature + "_diff"] = df['YrSold'] - df[feature]
df[feature + "_diff"] = df[feature + "_diff"].fillna(df[feature + "_diff"].max())
 df['YrBltAndRemod'] = df['YearBuilt']+df['YearRemodAdd']
for feature in temporal_features:
df[feature] = df[feature].astype(str)
 df[feature] = df[feature].fillna("Missing")
 df = pd.get_dummies(df)
 df = df.drop(overfit_reducer(df), axis=1)
 return df
test_num_lang = test.groupby('language')['id'].count().sort_values(ascending=False ).reset_index()
test_num_lang = pd.DataFrame(test_num_lang)
 test_num_lang['count'] = test_num_lang['id']
test_num_lang = test_num_lang.drop('id',axis=1)
 test_num_lang_data = test_num_lang.style.background_gradient(cmap='Oranges')
 test_num_lang_data<define_variables>
def create_categorical_features(features):
df = features[categorical_features].copy()
df['Functional'] = df['Functional'].fillna('Typ')
 df['Utilities'] = df['Utilities'].fillna('AllPub')
 df['Electrical'] = df['Electrical'].fillna("SBrkr")
 df['KitchenQual'] = df['KitchenQual'].fillna("TA")
 df['Exterior1st'] = df['Exterior1st'].fillna(df['Exterior1st'].mode() [0])
 df['Exterior2nd'] = df['Exterior2nd'].fillna(df['Exterior2nd'].mode() [0])
 df['SaleType'] = df['SaleType'].fillna(df['SaleType'].mode() [0])
 for col in ['GarageType', 'GarageFinish', 'GarageQual', 'GarageCond']:
df[col] = df[col].fillna('None')
 for col in('BsmtQual', 'BsmtCond', 'BsmtExposure', 'BsmtFinType1', 'BsmtFinType2'):
features[col] = features[col].fillna('None')
 features['MSZoning'] = features.groupby('MSSubClass')['MSZoning'].transform(lambda x: x.fillna(x.mode() [0]))
for feature in categorical_features:
df[feature] = df[feature].fillna("Missing")
 df = pd.get_dummies(df)
 df = df.drop(overfit_reducer(df), axis=1)
 return df
num_words_train_h = [None] * len(train)
 for i in range(len(train)) :
num_words_train_h[i] = len(train['hypothesis'][i])
 num_words_train_p = [None] * len(train)
 for i in range(len(train)) :
num_words_train_p[i] = len(train['premise'][i])
 num_words_test_h = [None] * len(test)
 for i in range(len(test)) :
num_words_test_h[i] = len(test['hypothesis'][i])
 num_words_test_p = [None] * len(test)
 for i in range(len(test)) :
num_words_test_p[i] = len(test['premise'][i] )<feature_engineering>
def create_numeric_features(features):
df = features[numeric_features + ["Neighborhood"]].copy()
for col in('GarageArea', 'GarageCars'):
df[col] = df[col].fillna(0)
 for feature in numeric_features:
df[feature] = df.groupby("Neighborhood")[feature].transform(lambda x: x.fillna(x.median()))
df = df.drop("Neighborhood", axis=1)
 df['TotalHouseSF'] = df['TotalBsmtSF'] + df['1stFlrSF'] + df['2ndFlrSF']
df['TotalArea'] = df['TotalBsmtSF'] + df['1stFlrSF'] + df['2ndFlrSF'] + df['GrLivArea'] + df['GarageArea']
df['Total_Bathrooms'] =(df['FullBath'] +(0.5 * df['HalfBath'])+
df['BsmtFullBath'] +(0.5 * df['BsmtHalfBath']))
df['TotalBath'] = df['FullBath'] + 0.5 * df['HalfBath']
df['TotalLot'] = df['LotFrontage'] + df['LotArea']
df['TotalPorch'] = df['OpenPorchSF'] + df['EnclosedPorch'] + df['ScreenPorch']
df['Total_sqr_footage'] =(df['BsmtFinSF1'] + df['BsmtFinSF2'] +
df['1stFlrSF'] + df['2ndFlrSF'])
 df['TotalBsmtFin'] = df['BsmtFinSF1'] + df['BsmtFinSF2']
df['Total_porch_sf'] =(df['OpenPorchSF'] + df['3SsnPorch'] +
df['EnclosedPorch'] + df['ScreenPorch'] +
df['WoodDeckSF'])
 df['haspool'] = df['PoolArea'].apply(lambda x: 1 if x > 0 else 0)
 df['has2ndfloor'] = df['2ndFlrSF'].apply(lambda x: 1 if x > 0 else 0)
 df['hasgarage'] = df['GarageArea'].apply(lambda x: 1 if x > 0 else 0)
 df['hasbsmt'] = df['TotalBsmtSF'].apply(lambda x: 1 if x > 0 else 0)
 df['hasfireplace'] = df['Fireplaces'].apply(lambda x: 1 if x > 0 else 0)
 df = df.drop(overfit_reducer(df), axis=1)
 df = fixing_skewness(df)
 return df
train['num_words_hypothesis'] = num_words_train_h
train['num_words_premise'] = num_words_train_p
test['num_words_hypothesis'] = num_words_test_h
test['num_words_premise'] = num_words_test_p<create_dataframe>
temporal_df = create_temporal_features(features)
 categorical_df = create_categorical_features(features)
 numeric_df = create_numeric_features(features)
 all_df = pd.concat([temporal_df,categorical_df,numeric_df],axis=1)
 X_train_all = all_df[:train.shape[0]]
X_test = all_df[train.shape[0]:]
y_train_all = train["SalePrice"]
labels = train['label'].sort_values().value_counts().reset_index()
labels = pd.DataFrame(labels)
 labels.columns = ['label','count']
labels_ = labels.style.background_gradient(cmap='Blues')
 labels_<prepare_x_and_y>
class Model:
@abstractmethod
def train_and_predict(self, X_train, X_valid, y_train, y_valid, X_test, params):
raise NotImplementedError
target = train['label']
train = train.drop('label',axis=1)
 train_text = [None] * len(train)
 test_text = [None] * len(test)
 for i in range(len(train)) :
train_text[i] = train['premise'][i] + ' ' + train['hypothesis'][i]
for i in range(len(test)) :
test_text[i] = test['premise'][i] + ' ' + test['hypothesis'][i]<load_pretrained>
class RandomForestWrapper(Model):
def train_and_predict(self, X_train, X_valid, y_train, y_valid, X_test, params):
reg = make_pipeline(RobustScaler() , RandomForestRegressor(**params))
reg.fit(X_train, y_train)
 y_valid_pred = reg.predict(X_valid)
 y_pred = reg.predict(X_test)
 return y_pred, y_valid_pred, reg
class GradientBoostingRegressorWrapper(Model):
def train_and_predict(self, X_train, X_valid, y_train, y_valid, X_test, params):
reg = make_pipeline(RobustScaler() , GradientBoostingRegressor(**params))
reg.fit(X_train, y_train)
 y_valid_pred = reg.predict(X_valid)
 y_pred = reg.predict(X_test)
 return y_pred, y_valid_pred, reg
class CatBoost(Model):
def train_and_predict(self, X_train, X_valid, y_train, y_valid, X_test, params):
reg = make_pipeline(RobustScaler() , cat(**params))
reg.fit(X_train, y_train)
 y_valid_pred = reg.predict(X_valid)
 y_pred = reg.predict(X_test)
 return y_pred, y_valid_pred, reg
class LightGBM(Model):
def train_and_predict(self, X_train, X_valid, y_train, y_valid, X_test, params):
lgb_train = lgb.Dataset(X_train, y_train)
 lgb_eval = lgb.Dataset(X_valid, y_valid, reference=lgb_train)
 model = lgb.train(
 params, lgb_train,
valid_sets=lgb_eval,
num_boost_round=5000,
early_stopping_rounds=100,
verbose_eval = False 
)
 y_valid_pred = model.predict(X_valid, num_iteration=model.best_iteration)
 y_pred = model.predict(X_test, num_iteration=model.best_iteration)
 return y_pred, y_valid_pred, model
class XGBoost(Model):
def train_and_predict(self, X_train, X_valid, y_train, y_valid, X_test, params):
dtrain = xgb.DMatrix(X_train, y_train)
 deval = xgb.DMatrix(X_valid, y_valid)
 watchlist = [(deval, 'eval'),(dtrain, 'train')]
model = xgb.train(
 params, dtrain,
num_boost_round=5000,
evals=watchlist,
early_stopping_rounds=10,
verbose_eval = False 
)
 y_valid_pred = model.predict(deval)
 dtest = xgb.DMatrix(X_test)
 y_pred = model.predict(dtest)
 return y_pred, y_valid_pred, model
tokenizer = transformers.AutoTokenizer.from_pretrained(MODEL )<categorify>
class KernelRidgeWrapper(Model):
def train_and_predict(self, X_train, X_valid, y_train, y_valid, X_test, params):
reg = make_pipeline(RobustScaler() , KernelRidge(alpha=params['alpha'], kernel=params['kernel'], degree=params['degree'], coef0=params['coef0']))
reg.fit(X_train, y_train)
 y_valid_pred = reg.predict(X_valid)
 y_pred = reg.predict(X_test)
 return y_pred, y_valid_pred, reg
class SVRWrapper(Model):
def train_and_predict(self, X_train, X_valid, y_train, y_valid, X_test, params):
reg = make_pipeline(RobustScaler() , SVR(kernel=params['kernel'], degree=params['degree'], coef0=params['coef0'], C=params['C'], epsilon=params['epsilon']))
reg.fit(X_train, y_train)
 y_valid_pred = reg.predict(X_valid)
 y_pred = reg.predict(X_test)
 return y_pred, y_valid_pred, reg
def roberta_encode(texts, maxlen=512):
enc_di = tokenizer.batch_encode_plus(
 texts,
pad_to_max_length=True,
max_length=maxlen 
)
 return np.array(enc_di['input_ids'] )<categorify>
class LinearRegressionWrapper(Model):
def train_and_predict(self, X_train, X_valid, y_train, y_valid, X_test, params):
lr = make_pipeline(RobustScaler() , LinearRegression())
 lr.fit(X_train, y_train)
 y_valid_pred = lr.predict(X_valid)
 y_pred = lr.predict(X_test)
 return y_pred, y_valid_pred, lr
class LassoWrapper(Model):
def train_and_predict(self, X_train, X_valid, y_train, y_valid, X_test, params):
lr = make_pipeline(RobustScaler() , Lasso(alpha=params['alpha']))
lr.fit(X_train, y_train)
 y_valid_pred = lr.predict(X_valid)
 y_pred = lr.predict(X_test)
 return y_pred, y_valid_pred, lr
class RidgeWrapper(Model):
def train_and_predict(self, X_train, X_valid, y_train, y_valid, X_test, params):
lr = make_pipeline(RobustScaler() , Ridge(alpha=params['alpha']))
lr.fit(X_train, y_train)
 y_valid_pred = lr.predict(X_valid)
 y_pred = lr.predict(X_test)
 return y_pred, y_valid_pred, lr
class ElasticNetWrapper(Model):
def train_and_predict(self, X_train, X_valid, y_train, y_valid, X_test, params):
lr = make_pipeline(RobustScaler() , ElasticNet(alpha=params['alpha'], l1_ratio=params['l1_ratio']))
lr.fit(X_train, y_train)
 y_valid_pred = lr.predict(X_valid)
 y_pred = lr.predict(X_test)
 return y_pred, y_valid_pred, lr
train_input_ids = roberta_encode(train_text,maxlen=100)
 test_input_ids = roberta_encode(test_text,maxlen=100 )<split>
BASE_FOLDS = 3
META_FOLDS = 3
SK_NUM = 50
SEED = [0, 1, 2, 3, 4]
train_input_ids,validation_input_ids,train_labels,validation_labels = train_test_split(train_input_ids,target,test_size=0.2 )<define_variables>
config = {
"model": "stacking",
"features": [
"temporal",
"numerical_engineering",
"objects"
],
"base_models":{
"LightGBM":{
"learning_rate": 0.01,
"num_leaves": 9,
"boosting_type": "gbdt",
"colsample_bytree": 0.7270015196871651,
"reg_alpha": 0.33858409141362755,
"reg_lambda": 0.749028887833709,
"objective": "root_mean_squared_error",
"max_bin" : 55,
"bagging_fraction" : 0.8105497285545641,
"bagging_freq" : 5,
"feature_fraction" : 0.41935759813141693,
"feature_fraction_seed":9,
"bagging_seed":9,
"min_data_in_leaf" :3,
"min_sum_hessian_in_leaf" : 1
},
"XGBoost":{
"colsample_bytree":0.6959168479765205,
"gamma":0.00679351239097101,
"learning_rate":0.01,
"max_depth":3,
"min_child_weight":1.204206891928091,
"reg_lambda":0.4013441917300995,
"subsample":0.9834112317433976,
"random_state" :7,
"nthread" : -1
},
"CatBoost":{
"learning_rate": 0.01,
"iterations": 6000,
"eval_metric": "RMSE",
"random_seed": 42,
"logging_level": "Silent",
"loss_function": "RMSE",
"od_type": "Iter",
"od_wait": 100,
"one_hot_max_size": 20,
"l2_leaf_reg": 1.4264966279202298,
"depth": 5,
"rsm": 0.6253447219486281,
"random_strength": 0.009926214908500652,
"bagging_temperature": 23
},
"GradientBoosting": {
"n_estimators":6000,
"learning_rate":0.01,
"max_depth":3,
"max_features":"sqrt",
"min_samples_leaf":5,
"min_samples_split":24,
"loss":"huber",
"random_state" :5
},
"RandomForest":{
"n_estimators": 100,
"criterion": "mse",
"max_depth": 30,
"min_samples_split": 0.0020129928930074648,
"min_samples_leaf": 1,
"max_features":"sqrt",
"random_state" :7
},
"ElasticNet":{
"alpha" : 0.0005958821579546562,
"l1_ratio": 0.9497862368719193
},
"KernelRidge":{
"alpha" : 9.2304694336833,
"kernel":"polynomial",
"degree": 3,
"coef0": 7.405346770365897
},
"Lasso":{
"alpha" : 0.0006320636127160412
},
"Ridge":{
"alpha" : 21.580134483773218
},
"SVR":{
"kernel":"poly",
"degree": 2,
"coef0": 7.865345479478388,
"C": 0.09111385520064191,
"epsilon": 0.0026048466307931843
}
},
"meta_model": "CatBoost",
"params":{
"learning_rate": 0.01,
"iterations": 6000,
"eval_metric": "RMSE",
"random_seed": 42,
"logging_level": "Silent",
"loss_function": "RMSE",
"od_type": "Iter",
"od_wait": 100,
"one_hot_max_size": 20,
"l2_leaf_reg": 1.4264966279202298,
"depth": 5,
"rsm": 0.6253447219486281,
"random_strength": 0.009926214908500652,
"bagging_temperature": 23
},
"loss": "rmse",
"target_name": "SalePrice",
"ID_name": "Id"
}
train_dataset =(
 tf.data.Dataset 
.from_tensor_slices(( train_input_ids,train_labels)) 
.repeat() 
.shuffle(2048)
.batch(Batch_size)
.prefetch(AUTO)
)
 validation_dataset =(
 tf.data.Dataset 
.from_tensor_slices(( validation_input_ids, validation_labels)) 
.batch(Batch_size)
.cache() 
.prefetch(AUTO)
)
 test_dataset =(
 tf.data.Dataset 
.from_tensor_slices(test_input_ids)
.batch(Batch_size)
 )<choose_model_class>
def evaluate_score(true, predicted, metric_name):
if metric_name == 'rmse':
return np.sqrt(metrics.mean_squared_error(true, predicted))
def create_model(bert_model):
input_ids = tf.keras.Input(shape=(100,),dtype='int32')
 output = bert_model(input_ids)[0]
output = output[:,0,:]
output = tf.keras.layers.Dense(3,activation='softmax' )(output)
 model = tf.keras.models.Model(inputs = input_ids,outputs = output)
 model.compile(optimizer=tf.keras.optimizers.Adam(lr=1e-5), loss='sparse_categorical_crossentropy', metrics=['accuracy'])
 return model<load_pretrained>
qcut_target = pd.qcut(y_train_all, SK_NUM, labels=False)
 y_train_log = np.log(y_train_all + 1)
 base_models = config['base_models']
oof_df = pd.DataFrame(index=[i for i in range(X_train_all.shape[0])])
 y_preds_df = pd.DataFrame(index=[i for i in range(X_test.shape[0])])
 for name, params in base_models.items() :
oof = np.zeros(( X_train_all.shape[0], 1))
y_preds = []
scores = []
for seed in SEED:
kf = StratifiedKFold(n_splits=BASE_FOLDS, shuffle=True, random_state=seed)
 for train_index, valid_index in kf.split(X_train_all, qcut_target):
X_train, X_valid =(X_train_all.iloc[train_index, :], X_train_all.iloc[valid_index, :])
 y_train, y_valid =(y_train_log.iloc[train_index], y_train_log.iloc[valid_index])
 if name == "LightGBM":
model = LightGBM()
elif name == "Lasso":
model = LassoWrapper()
elif name == "Ridge":
model = RidgeWrapper()
elif name == "ElasticNet":
model = ElasticNetWrapper()
elif name == "KernelRidge":
model = KernelRidgeWrapper()
elif name == "SVR":
model = SVRWrapper()
elif name == "XGBoost":
model = XGBoost()
elif name == "RandomForest":
model = RandomForestWrapper()
elif name == "GradientBoosting":
model = GradientBoostingRegressorWrapper()
elif name == "CatBoost":
model = CatBoost()
y_pred, y_valid_pred, m = model.train_and_predict(X_train, X_valid, y_train, y_valid, X_test, params)
 oof[valid_index, :] += y_valid_pred.reshape(len(y_valid_pred), 1)/len(SEED)
 y_preds.append(y_pred)
 rmse_valid = evaluate_score(y_valid, y_valid_pred, config['loss'])
 scores.append(rmse_valid)
 score = sum(scores)/ len(scores)
 print('===CV scores===')
 print(f"\tmodel: {name}, scores: {scores}")
 print(f"\tmodel: {name}, score: {score}")
 oof_df[name] = oof
y_preds_df[name] = sum(y_preds)/ len(y_preds)
with strategy.scope() :
bert_model =(
 transformers.TFAutoModel 
.from_pretrained(MODEL)
)
 model = create_model(bert_model )<train_model>
oof_df = pd.concat([X_train_all, oof_df], axis=1)
 y_preds_df = pd.concat([X_test, y_preds_df], axis=1)
 y_preds = []
scores = []
for seed in SEED:
kf = StratifiedKFold(n_splits=META_FOLDS, shuffle=True, random_state=seed)
 for train_index, valid_index in kf.split(X_train_all, qcut_target):
X_train, X_valid =(oof_df.iloc[train_index, :], oof_df.iloc[valid_index, :])
 y_train, y_valid =(y_train_log.iloc[train_index], y_train_log.iloc[valid_index])
 name = config['meta_model']
if name == "LightGBM":
model = LightGBM()
elif name == "Lasso":
model = LassoWrapper()
elif name == "Ridge":
model = RidgeWrapper()
elif name == "ElasticNet":
model = ElasticNetWrapper()
elif name == "KernelRidge":
model = KernelRidgeWrapper()
elif name == "SVR":
model = SVRWrapper()
elif name == "XGBoost":
model = XGBoost()
elif name == "RandomForest":
model = RandomForestWrapper()
elif name == "GradientBoosting":
model = GradientBoostingRegressorWrapper()
elif name == "CatBoost":
model = CatBoost()
y_pred, y_valid_pred, m = model.train_and_predict(X_train, X_valid, y_train, y_valid, y_preds_df, config['params'])
 y_preds.append(y_pred)
 rmse_valid = evaluate_score(y_valid, y_valid_pred, config['loss'])
 scores.append(rmse_valid)
 score = sum(scores)/ len(scores)
 print('===CV scores===')
 print(scores)
 print(score )
history = model.fit(train_dataset,
validation_data = validation_dataset,
epochs = epochs,
batch_size = Batch_size,
steps_per_epoch = len(train_input_ids)//Batch_size
)<save_to_csv>
ID_name = "Id"
target_name = "SalePrice"
sub_stacking = pd.DataFrame(pd.read_csv(".. /input/house-prices-advanced-regression-techniques/sample_submission.csv")[ID_name])
 y_sub = sum(y_preds)/ len(y_preds)
 y_sub = np.exp(y_sub)- 1
sub_stacking[target_name] = y_sub
<import_modules><EOS> 
sub = pd.DataFrame(pd.read_csv(".. /input/house-prices-advanced-regression-techniques/sample_submission.csv")[ID_name])
 sub[target_name] = 0
base_subs = [
np.exp(y_preds_df["CatBoost"])- 1 ,
np.exp(y_preds_df["ElasticNet"])- 1 ,
np.exp(y_preds_df["Lasso"])- 1 ,
np.exp(y_preds_df["LightGBM"])- 1 ,
sub_stacking[target_name],
]
weight = [0.1,0.1,0.1,0.1,0.6]
for i in range(len(base_subs)) :
sub[target_name] += base_subs[i]*weight[i]
sub.to_csv(
 './submission.csv',
index=False 
)