Kaggle competition: House Prices - Advanced Regression Techniques
<SOS> metric: rmsle Kaggle data source: house-prices-advanced-regression-techniques<prepare_x_and_y>
!pip install dabl
models = []
oof_predictions = np.zeros(shape=(X.shape[0]))
rkf = GroupKFold(11)
 FOLD_LIST = list(rkf.split(train_basetable['GameId'],train_basetable['GameId'],train_basetable['GameId']))
for fold_id,(tr_idx, vl_idx)in enumerate(FOLD_LIST):
print(fold_id)
 x_tr, y_tr = X[tr_idx], y[tr_idx]
x_vl, y_vl = X[vl_idx], y[vl_idx]
model= get_model(X.shape[1])
 es = EarlyStopping(monitor='val_loss',
mode='min',
restore_best_weights=True,
verbose=1,
patience=5)
 model.fit(x_tr, y_tr, epochs=200, batch_size=1024, validation_data=[x_vl, y_vl], callbacks=[es])
 oof_predictions[vl_idx] += model.predict(x_vl ).reshape(-1)
 models.append(model)
<import_modules>
warnings.filterwarnings('ignore')
 %matplotlib inline
plt.style.use('ggplot')
 warnings.filterwarnings(action="ignore")
 pd.options.display.max_seq_items = 8000
pd.options.display.max_rows = 8000
pd.options.display.max_columns = 8000
from scipy.stats import spearmanr, pearsonr<compute_test_metric>
from sklearn.model_selection import train_test_split
from sklearn.model_selection import cross_val_score, GridSearchCV, KFold
from sklearn.preprocessing import RobustScaler, StandardScaler
from sklearn.pipeline import make_pipeline
from collections import Counter
from sklearn.preprocessing import scale
from sklearn.preprocessing import LabelEncoder
print(
 pearsonr(y.reshape(-1), oof_predictions.reshape(-1)) ,
spearmanr(y.reshape(-1), oof_predictions.reshape(-1))
)<concatenate>
file_path = '.. /input/house-prices-advanced-regression-techniques'
train=pd.read_csv(f'{file_path}/train.csv')
 test= pd.read_csv(f'{file_path}/test.csv' )
_X = np.hstack([X, oof_predictions.reshape(-1,1)] )<prepare_x_and_y>
train.isna().sum()
class Metric(Callback):
def __init__(self, model, callbacks, data):
super().__init__()
self.model = model
self.callbacks = callbacks
self.data = data
def on_train_begin(self, logs=None):
for callback in self.callbacks:
callback.on_train_begin(logs)
 def on_train_end(self, logs=None):
for callback in self.callbacks:
callback.on_train_end(logs)
 def on_epoch_end(self, batch, logs=None):
logs['tr_CRPS'] = 0
X_valid, y_valid = self.data[1][0], self.data[1][1]
y_pred = self.model.predict(X_valid)
 y_true = np.clip(np.cumsum(y_valid, axis=1), 0, 1)
 y_pred = np.clip(np.cumsum(y_pred, axis=1), 0, 1)
 val_s =(( y_true - y_pred)** 2 ).sum(axis=1 ).sum(axis=0)/(199 * X_valid.shape[0])
 val_s = np.round(val_s, 6)
 logs['val_CRPS'] = val_s
print('tr CRPS', 'Grr', 'val CRPS', val_s)
 for callback in self.callbacks:
callback.on_epoch_end(batch, logs )<prepare_x_and_y>
test.isna().sum()
_models = []
oof_predictions = np.zeros(shape=(_X.shape[0]))
for fold_id,(tr_idx, vl_idx)in enumerate(FOLD_LIST):
print(fold_id)
 x_tr, y_tr = _X[tr_idx], _y[tr_idx]
x_vl, y_vl = _X[vl_idx], _y[vl_idx]
model= get_model_v2(_X.shape[1])
 es = EarlyStopping(monitor='val_CRPS',
mode='min',
restore_best_weights=True,
verbose=1,
patience=3)
 es.set_model(model)
 metric = Metric(model, [es], [(x_tr, y_tr),(x_vl, y_vl)])
 model.fit(x_tr, y_tr, callbacks=[metric], epochs=5, batch_size=1024, validation_data=[x_vl, y_vl])
 _models.append(model)
<import_modules>
train_data=train.copy()
class GP:
def __init__(self):
self.classes = 20
self.class_names = [ 'class_0',
'class_1',
'class_2',
'class_3',
'class_4',
'class_5',
'class_6',
'class_7',
'class_8',
'class_9',
'class_10',
'class_11',
'class_12',
'class_13',
'class_14',
'class_15',
'class_16',
'class_17',
'class_18',
'class_19',
]
def GrabPredictions(self, data):
oof_preds = np.zeros(( len(data), len(self.class_names)))
 oof_preds[:,0] = self.GP_class_0(data)
 oof_preds[:,1] = self.GP_class_1(data)
 oof_preds[:,2] = self.GP_class_2(data)
 oof_preds[:,3] = self.GP_class_3(data)
 oof_preds[:,4] = self.GP_class_4(data)
 oof_preds[:,5] = self.GP_class_5(data)
 oof_preds[:,6] = self.GP_class_6(data)
 oof_preds[:,7] = self.GP_class_7(data)
 oof_preds[:,8] = self.GP_class_8(data)
 oof_preds[:,9] = self.GP_class_9(data)
 oof_preds[:,10] = self.GP_class_10(data)
 oof_preds[:,11] = self.GP_class_11(data)
 oof_preds[:,12] = self.GP_class_12(data)
 oof_preds[:,13] = self.GP_class_13(data)
 oof_preds[:,14] = self.GP_class_14(data)
 oof_preds[:,15] = self.GP_class_15(data)
 oof_preds[:,16] = self.GP_class_16(data)
 oof_preds[:,17] = self.GP_class_17(data)
 oof_preds[:,18] = self.GP_class_18(data)
 oof_preds[:,19] = self.GP_class_19(data)
 oof_df = pd.DataFrame(np.exp(oof_preds), columns=self.class_names)
 oof_df =oof_df.div(oof_df.sum(axis=1), axis=0)
 return oof_df.values
def GP_class_0(self,data):
return(0.250000*np.tanh(((((((data[:,0])-(((data[:,0])+(data[:,0])))))+(data[:,0])))+(((((data[:,0])* 2.0)) * 2.0)))) +
0.250000*np.tanh(((((((((((((data[:,2])-(data[:,7])))* 2.0)) +(data[:,7])))* 2.0)) +(data[:,0])))+(((((data[:,2])+(data[:,0])))-(data[:,7])))))+
0.250000*np.tanh(((((((((((((((((((data[:,3])-(data[:,7])))-(((data[:,0])/ 2.0)))) +(data[:,0])))-(data[:,7])))+(data[:,2])))+(((data[:,7])+(data[:,2])))))+(data[:,7])))-(data[:,7])))+(data[:,0])))+
0.250000*np.tanh(((((((((data[:,0])-(data[:,7])))-(data[:,14])))+(((data[:,17])-(data[:,14])))))+(((((((data[:,0])-(( 1.0)))) -(data[:,0])))+(data[:,20])))))+
0.250000*np.tanh(((((data[:,18])+(((((((data[:,0])-(data[:,7])))+(data[:,2])))+(data[:,0])))))-(((data[:,7])+(data[:,2])))))+
0.250000*np.tanh(((((((( data[:,8])+(((((((( data[:,13])+(data[:,3])))+(data[:,0])) /2.0)) +(((((((( data[:,0])+(((((data[:,0])-(data[:,0])))/ 2.0)))) +(data[:,17])) /2.0)) +(data[:,11])))))) /2.0)) +(data[:,0])))-(data[:,13])))+
0.250000*np.tanh(((((data[:,0])* 2.0)) +(((((((((data[:,2])+(data[:,2])))* 2.0)) -(((data[:,14])-(((np.tanh(( data[:,2])))* 2.0)))))) -(data[:,7])))))+
0.250000*np.tanh(((((((((((((data[:,17])-(((data[:,17])*(((((data[:,17])*(data[:,17])))* 2.0)))))) +(((((((data[:,17])* 2.0)) * 2.0)) * 2.0)))/2.0)) / 2.0)) +(((data[:,17])-(( 7.76236486434936523)))))/2.0)) +(((((((data[:,17])*(data[:,17])))* 2.0)) * 2.0)))) +
0.250000*np.tanh(((((((((((data[:,17])+(data[:,17])) /2.0)) +(((( data[:,17])+(((( data[:,17])+(data[:,17])) /2.0)))/2.0)))/2.0)) *(data[:,17])))-(data[:,13])))+
0.250000*np.tanh(((((( data[:,19])+(((((((((data[:,19])* 2.0)) +(data[:,19])))-(( 1.07645297050476074)))) +(((data[:,22])+(data[:,22])))))) /2.0)) +(((data[:,22])+(data[:,4]))))))
def GP_class_1(self,data):
return(0.250000*np.tanh(((((((((((((data[:,3])+(((np.tanh(( data[:,2])))-(data[:,14])))))-(( 10.0)))) -(( 4.88989353179931641)))) -(( 13.92175483703613281)))) / 2.0)) -(data[:,6])))+
0.250000*np.tanh(data[:,3])+
0.250000*np.tanh(((data[:,2])+(((((np.tanh(((( data[:,14])* 2.0)))) -(((((((data[:,7])* 2.0)) -(((((data[:,0])-(data[:,14])))-(data[:,7])))))-(data[:,0])))))+(data[:,0])))))+
0.250000*np.tanh(((((((data[:,0])-(( -1.0*(( data[:,14])))))) +(((((((((( data[:,0])-(data[:,7])))-(((( data[:,14])+(data[:,14])) /2.0)))) +(((data[:,2])-(((data[:,0])*(data[:,14])))))) /2.0)) -(data[:,14])))))-(data[:,7])))+
0.250000*np.tanh(((((data[:,0])/ 2.0)) +(data[:,0])))+
0.250000*np.tanh(((((data[:,19])-(data[:,19])))/ 2.0)) +
0.250000*np.tanh(((((np.tanh(((( np.tanh(( data[:,5])))-(((( 1.69341480731964111)) +(((((( np.tanh(( data[:,14])))-(data[:,14])))+(data[:,14])) /2.0)))))))) -(data[:,2])))-(((data[:,14])* 2.0)))) +
0.250000*np.tanh(((((( data[:,22])+(((data[:,0])+(((((((( data[:,22])/ 2.0)) +(( -1.0*(( data[:,13])))))/2.0)) +(data[:,19])))))) /2.0)) -(data[:,13])))+
0.250000*np.tanh(((((((data[:,17])/ 2.0)) *(data[:,17])))*(((data[:,17])+(((data[:,17])*(((((((((data[:,17])+(data[:,17])))*(data[:,17])))*(data[:,17])))+(((np.tanh(( data[:,17])))/ 2.0)))))))))) +
0.250000*np.tanh(((((( data[:,14])*(((data[:,13])+(data[:,3])))))+(((data[:,14])*(((data[:,14])-(( -1.0*(( data[:,3])))))))))/2.0)))
 def GP_class_2(self,data):
return(0.250000*np.tanh(((data[:,0])+(np.tanh(((((((((( data[:,2])+(((data[:,2])/ 2.0)))/2.0)) +(data[:,0])) /2.0)) *(data[:,7])))))))+
0.250000*np.tanh(((( data[:,22])+(data[:,22])) /2.0)) +
0.250000*np.tanh(((((( data[:,14])+(( -1.0*(((((( 4.73206138610839844)) +(((((((((((np.tanh(( data[:,7])))+(data[:,1])) /2.0)) -(np.tanh(((((( data[:,0])-(data[:,20])))-(data[:,14])))))))*(( 7.0)))) +(data[:,14])) /2.0)))/2.0)))))) /2.0)) -(data[:,14])))+
0.250000*np.tanh(((((data[:,1])+(( 4.15603733062744141)))) / 2.0)) +
0.250000*np.tanh(((((((((((((data[:,0])-(data[:,7])))-(data[:,7])))+(((( data[:,0])+(data[:,0])) /2.0)))) * 2.0)) +(data[:,0])))* 2.0)) +
0.250000*np.tanh(((((data[:,11])/ 2.0)) / 2.0)) +
0.250000*np.tanh(((((((((((((((((((((((data[:,2])/ 2.0)) +(((data[:,2])/ 2.0)))/2.0)) / 2.0)) / 2.0)) / 2.0)) +(((( -1.0*(((( data[:,0])/ 2.0)))))*(((data[:,0])/ 2.0)))))/2.0)) +(data[:,0])) /2.0)) +(np.tanh(( data[:,0])))) /2.0)) / 2.0)) +
0.250000*np.tanh(((((data[:,0])+(((data[:,0])+(((((((data[:,14])*(data[:,14])))+(data[:,14])))-(data[:,0])))))))-(data[:,14])))+
0.250000*np.tanh(((((( np.tanh(( np.tanh(((0.0)))))) *(data[:,15])))+(data[:,20])) /2.0)) +
0.250000*np.tanh(((data[:,14])*(((( data[:,13])+(((( data[:,13])+(((( data[:,14])+(((((( data[:,14])+(((( data[:,14])+(((data[:,13])-(((( -1.0*(((((data[:,14])+(data[:,14])) /2.0)))))* 2.0)))))/2.0)))) +(data[:,14])) /2.0)))/2.0)))/2.0)))/2.0)))))
 def GP_class_3(self,data):
return(0.250000*np.tanh(((((((((8.0)) +(((((((5.33416414260864258)) +(( 9.0)))/2.0)) +(((( 8.0)) * 2.0)))))) * 2.0)) +(( 5.33416414260864258)))/2.0)) +
0.250000*np.tanh(((( 9.48088836669921875)) +(((((10.56953334808349609)) +(((( 4.48959350585937500)) +(np.tanh(((((3.0)) +(( 9.0)))))))))/2.0)))) +
0.250000*np.tanh(((((((((( data[:,22])/ 2.0)) +(data[:,22])) /2.0)) * 2.0)) / 2.0)) +
0.250000*np.tanh(( 10.44883441925048828)) +
0.250000*np.tanh(((((data[:,0])+(((data[:,0])+(( -1.0*(( data[:,9])))))))) +(((((data[:,0])-(data[:,7])))-(data[:,9])))))+
0.250000*np.tanh(((np.tanh(( data[:,6])))-(data[:,21])))+
0.250000*np.tanh(((data[:,0])-(((((data[:,14])+(((((data[:,14])+(((data[:,14])+(((data[:,14])-(data[:,0])))))))-(((((data[:,0])-(data[:,14])))+(data[:,14])))))))-(((((data[:,14])*(data[:,14])))+(data[:,18])))))))+
0.250000*np.tanh(((data[:,14])*(((( data[:,13])+(data[:,14])) /2.0)))) +
0.250000*np.tanh(((((( data[:,8])*(((data[:,8])/ 2.0)))) +(((((( data[:,9])*(data[:,8])))+(data[:,8])) /2.0)))/2.0)) +
0.250000*np.tanh(((( data[:,2])+(((((((data[:,2])+(data[:,20])) /2.0)) +(((((((( data[:,2])+(data[:,8])) /2.0)) / 2.0)) -(data[:,8])))) /2.0)))/2.0)))
 def GP_class_4(self,data):
return(0.250000*np.tanh(((( 12.98819637298583984)) / 2.0)) +
0.250000*np.tanh(((((4.75780344009399414)) +(((((((8.66014671325683594)) +(( 4.18107128143310547)))/2.0)) *(( 8.97841739654541016)))))/2.0)) +
0.250000*np.tanh(((( 9.0)) / 2.0)) +
0.250000*np.tanh(((((((((((10.0)) +(np.tanh(((((( 6.0)) +(((( 13.80149555206298828)) +(( 7.0)))))/2.0)))))) +(( 10.0)))) +(((((((data[:,0])+(( 8.0)))) / 2.0)) / 2.0)))/2.0)) +(((( -1.0*(((( data[:,2])*(data[:,9])))))) * 2.0)))) +
0.250000*np.tanh(((((data[:,0])+(((((((data[:,22])+(data[:,22])) /2.0)) +(data[:,22])) /2.0)))) +(((((( data[:,22])+(((((( data[:,22])* 2.0)) +(data[:,22])) /2.0)))) +(data[:,18])) /2.0)))) +
0.250000*np.tanh(((((((((((((np.tanh(( data[:,18])))+(((( data[:,1])+(data[:,18])) /2.0)))/2.0)) *(data[:,18])))*(data[:,18])))+(((data[:,18])*(data[:,18])))) /2.0)) -(((((((np.tanh(( data[:,18])))+(((data[:,18])*(data[:,18])))) /2.0)) +(data[:,17])) /2.0)))) +
0.250000*np.tanh(((np.tanh(((((((np.tanh(( data[:,6])))-(((np.tanh(( data[:,6])))-(data[:,6])))))+(np.tanh(( data[:,6])))) /2.0)))) -(((( data[:,10])+(((( data[:,2])+(((np.tanh(( data[:,6])))-(((np.tanh(( np.tanh(( data[:,6])))))-(data[:,10])))))) /2.0)))/2.0)))) +
0.250000*np.tanh(((((((((((( data[:,10])+(data[:,4])))+(((data[:,10])+(((data[:,0])*(data[:,10])))))) /2.0)) +(((data[:,4])*(((data[:,10])+(data[:,4])))))) /2.0)) +(data[:,7])) /2.0)) +
0.250000*np.tanh(((((( data[:,11])+(((((data[:,18])/ 2.0)) *(((data[:,11])*(data[:,18])))))) /2.0)) *(((data[:,18])*(((((((((data[:,18])*(((((((data[:,11])/ 2.0)) / 2.0)) *(data[:,18])))))/ 2.0)) / 2.0)) *(( -1.0*(( data[:,21])))))))))) +
0.250000*np.tanh(((( -1.0*(((((((((((( data[:,2])-(data[:,2])))*(np.tanh(( data[:,2])))))+(np.tanh(((( data[:,14])* 2.0)))))/2.0)) +(data[:,2])) /2.0)))))-(data[:,2]))))
def GP_class_5(self,data):
return(0.250000*np.tanh(((((((((((3.46574378013610840)) +(((( np.tanh(((3.46574378013610840)))) +(( 8.46705245971679688)))/2.0)))/2.0)) * 2.0)) +(((( 3.46574378013610840)) +(( 4.0)))))) +(((( 4.0)) * 2.0)))) +
0.250000*np.tanh(((( 10.55856513977050781)) / 2.0)) +
0.250000*np.tanh(((( 3.76695251464843750)) / 2.0)) +
0.250000*np.tanh(((((( 6.0)) / 2.0)) +(((( 8.57984828948974609)) * 2.0)))) +
0.250000*np.tanh(((((((((((( 3.42168045043945312)) +(data[:,7])))+(np.tanh(( data[:,7])))))+(np.tanh(( np.tanh(( np.tanh(((3.42168045043945312)))))))))/2.0)) +(data[:,7])) /2.0)) +
0.250000*np.tanh(((((((((((data[:,6])-(data[:,9])))+(data[:,7])) /2.0)) * 2.0)) +(((((( data[:,7])+(data[:,9])) /2.0)) -(data[:,9])))) /2.0)) +
0.250000*np.tanh(((((((((((data[:,22])+(data[:,22])))+(data[:,11])) /2.0)) +(data[:,22])) /2.0)) / 2.0)) +
0.250000*np.tanh(((((((((( 0.76044219732284546)) / 2.0)) +(( 0.76044219732284546)))/2.0)) +(np.tanh(( np.tanh(((((((( 0.76043862104415894)) / 2.0)) +(( 1.0)))/2.0)))))))/2.0)) +
0.250000*np.tanh(((((((data[:,12])+(np.tanh(( data[:,9])))) /2.0)) +(((((((((((data[:,12])+(((((0.0)) +(np.tanh(((((((( data[:,7])+(data[:,6])) /2.0)) +(data[:,7])) /2.0)))))/2.0)))/2.0)) / 2.0)) / 2.0)) +(data[:,7])) /2.0)))/2.0)) +
0.250000*np.tanh(((((((((data[:,20])/ 2.0)) / 2.0)) *(((np.tanh(( data[:,20])))*(((data[:,20])/ 2.0)))))) *(((((( data[:,20])/ 2.0)) +(((data[:,20])/ 2.0)))/2.0)))))
 def GP_class_6(self,data):
return(0.250000*np.tanh(((((((11.68076229095458984)) +(((((11.68075847625732422)) +(((( 11.47270107269287109)) +(((((11.47269725799560547)) +(( 11.68076229095458984)))/2.0)))))/2.0)))/2.0)) +(((( 4.0)) * 2.0)))) +
0.250000*np.tanh(((( 8.0)) +(((( 10.0)) +(( 6.59042119979858398)))))) +
0.250000*np.tanh(((((((((((13.33760547637939453)) +(((((3.86388397216796875)) +(((((((8.18321037292480469)) +(data[:,4])))+(((((((5.95386552810668945)) +(( 12.93883609771728516)))) +(((((10.73907089233398438)) +(( 4.0)))/2.0)))/2.0)))/2.0)))/2.0)))/2.0)) +(np.tanh(((3.0)))))) -(( 2.0)))) +(((((10.61559963226318359)) +(data[:,1])) /2.0)))) +
0.250000*np.tanh(((np.tanh(((((((((((7.13513946533203125)) +(( 12.48778533935546875)))/2.0)) +(((((((7.13513565063476562)) -(( 8.12031841278076172)))) +(((((((((7.13513565063476562)) +(((( 10.69830417633056641)) +(( 10.69830799102783203)))))) +(( 10.69830799102783203)))) +(( 7.83078956604003906)))/2.0)))/2.0)))/2.0)) * 2.0)))) +(( 3.0)))) +
0.250000*np.tanh(((((((((((data[:,7])-(data[:,0])))* 2.0)) -(data[:,7])))+(data[:,7])))+(data[:,0])))+
0.250000*np.tanh(((((data[:,7])/ 2.0)) / 2.0)) +
0.250000*np.tanh(((((((((((((((( 1.0)) +(((((((data[:,2])+(((((((1.0)) *(data[:,2])))+(data[:,14])) /2.0)))/2.0)) +(( 1.0)))/2.0)))) +(((( 1.0)) -(((data[:,2])*(data[:,14])))))) /2.0)) -(data[:,2])))* 2.0)) +(data[:,14])) /2.0)) +(data[:,14])))+
0.250000*np.tanh(((np.tanh(( np.tanh(((((((data[:,19])*(( 0.0)))) +(( 0.0)))/2.0)))))) / 2.0)) +
0.250000*np.tanh(((((((( 0.0)) / 2.0)) / 2.0)) *(((((((((data[:,15])/ 2.0)) *(( 0.0)))) / 2.0)) *(((( -1.0*(((0.0)))))/ 2.0)))))) +
0.250000*np.tanh(((((data[:,15])*(((((((((((((np.tanh(((((0.09032609313726425)) / 2.0)))) / 2.0)) / 2.0)) / 2.0)) / 2.0)) / 2.0)) / 2.0)))) / 2.0)))
 def GP_class_7(self,data):
return(0.250000*np.tanh(( 10.27210903167724609)) +
0.250000*np.tanh(((((((((( 10.0)) +(((((((((8.26972770690917969)) +(( 11.06334972381591797)))/2.0)) * 2.0)) / 2.0)))) +(((((( 5.0)) +(((( 5.0)) +(( 7.92727756500244141)))))) * 2.0)))) *(( 7.92728137969970703)))) +(( 10.0)))) +
0.250000*np.tanh(( 8.42519950866699219)) +
0.250000*np.tanh(((((((data[:,14])+(data[:,14])))+(((((( 1.59392631053924561)) +(data[:,14])))+(data[:,14])))))+(np.tanh(((((( data[:,14])+(((((((3.0)) +(((data[:,14])* 2.0)))/2.0)) +(( 1.59391915798187256)))))) +(( 1.59392631053924561)))))))) +
0.250000*np.tanh(((( data[:,7])+(((data[:,0])+(((((((data[:,7])+(data[:,4])) /2.0)) +(((data[:,7])* 2.0)))/2.0)))))/2.0)) +
0.250000*np.tanh(((((((((((((( data[:,9])-(((data[:,0])-(data[:,0])))))-(((data[:,0])/ 2.0)))) / 2.0)) -(((data[:,21])-(data[:,7])))))+(data[:,21])) /2.0)) -(data[:,0])))+
0.250000*np.tanh(((((((((( 2.0)) +(((((( data[:,21])+(((( data[:,13])+(((((((((((data[:,13])* 2.0)) +(data[:,21])) /2.0)) +(data[:,13])) /2.0)) * 2.0)))/2.0)))/2.0)) -(np.tanh(((((0.0)) -(data[:,21])))))))))+(( 1.0)))/2.0)) +(data[:,13])) /2.0)) +
0.250000*np.tanh(((((data[:,14])/ 2.0)) / 2.0)) +
0.250000*np.tanh(((((((((((((((( -1.0*(((((((data[:,21])/ 2.0)) +(data[:,8])) /2.0)))))/ 2.0)) / 2.0)) / 2.0)) +(data[:,9])) /2.0)) / 2.0)) +(((((((((((( data[:,7])/ 2.0)) / 2.0)) / 2.0)) / 2.0)) +(data[:,7])) /2.0)))/2.0)) +
0.250000*np.tanh(((((((np.tanh(((1.0)))) / 2.0)) / 2.0)) / 2.0)))
 def GP_class_8(self,data):
return(0.250000*np.tanh(((((((data[:,0])+(((((6.71804094314575195)) +(data[:,15])) /2.0)))) +(((((( 11.56385326385498047)) * 2.0)) *(((( 10.48986148834228516)) +(( 11.56385326385498047)))))))) / 2.0)) +
0.250000*np.tanh(((((((((( data[:,14])/ 2.0)) +(( 2.83755254745483398)))/2.0)) +(((((( data[:,12])+(data[:,14])) /2.0)) +(data[:,14])))))+(((( data[:,9])+(((data[:,12])+(data[:,14])))) /2.0)))) +
0.250000*np.tanh(((((((((data[:,6])+(((((((3.50821948051452637)) +(((( data[:,21])+(( 11.92932796478271484)))/2.0)))) +(( 1.0)))/2.0)))) +(data[:,10])) /2.0)) +(data[:,21])) /2.0)) +
0.250000*np.tanh(((data[:,14])+(np.tanh(( np.tanh(((-1.0*(((( data[:,22])-(data[:,13])))))))))))) +
0.250000*np.tanh(((((1.0)) +(((( data[:,7])+(data[:,7])) /2.0)))/2.0)) +
0.250000*np.tanh(((((((((data[:,21])/ 2.0)) / 2.0)) *(((((((np.tanh(((( np.tanh(( data[:,13])))/ 2.0)))) / 2.0)) +(((((((np.tanh(((((data[:,21])+(data[:,21])) /2.0)))) / 2.0)) -(data[:,12])))/ 2.0)))) / 2.0)))) -(data[:,12])))+
0.250000*np.tanh(((( data[:,7])+(np.tanh(((((data[:,12])+(((data[:,7])*(((( data[:,13])+(data[:,13])) /2.0)))))/2.0)))))/2.0)) +
0.250000*np.tanh(((((((data[:,13])/ 2.0)) / 2.0)) / 2.0)) +
0.250000*np.tanh(((((((((( np.tanh(( data[:,9])))+(data[:,13])) /2.0)) +(((((((( data[:,21])/ 2.0)) * 2.0)) +(((( 3.94983267784118652)) / 2.0)))/2.0)))/2.0)) +(((( np.tanh(((3.94983267784118652)))) +(data[:,9])) /2.0)))/2.0)) +
0.250000*np.tanh(((((((((((((((data[:,14])*(((((((((data[:,19])/ 2.0)) *(np.tanh(((( data[:,2])/ 2.0)))))) / 2.0)) / 2.0)))) / 2.0)) / 2.0)) / 2.0)) / 2.0)) / 2.0)) *(((((data[:,11])/ 2.0)) / 2.0)))))
 def GP_class_9(self,data):
return(0.250000*np.tanh(((((((data[:,14])* 2.0)) / 2.0)) +(((((data[:,14])+(np.tanh(((( data[:,14])* 2.0)))))) +(data[:,14])))))+
0.250000*np.tanh(((data[:,9])-(((((-1.0*(( data[:,11])))) +(data[:,9])) /2.0)))) +
0.250000*np.tanh(((data[:,21])* 2.0)) +
0.250000*np.tanh(((((( data[:,14])+(data[:,14])) /2.0)) +(((( data[:,13])+(((( np.tanh(((( data[:,9])+(( 6.0)))))) +(data[:,9])) /2.0)))/2.0)))) +
0.250000*np.tanh(np.tanh(((1.0)))) +
0.250000*np.tanh(((np.tanh(( np.tanh(((((np.tanh(((( data[:,20])*(((((((np.tanh(((( data[:,20])/ 2.0)))) +(data[:,12])) /2.0)) +(((( data[:,15])+(((( data[:,17])+(data[:,9])) /2.0)))/2.0)))/2.0)))))) +(data[:,9])) /2.0)))))) / 2.0)) +
0.250000*np.tanh(((((data[:,2])-(data[:,11])))/ 2.0)) +
0.250000*np.tanh(((((((( data[:,13])/ 2.0)) +(((data[:,7])+(data[:,7])))) /2.0)) -(((((data[:,22])+(((((data[:,14])*(((((data[:,7])*(((data[:,13])-(((( data[:,7])+(((((data[:,13])/ 2.0)) +(data[:,7])))) /2.0)))))) / 2.0)))) * 2.0)))) / 2.0)))) +
0.250000*np.tanh(((((((((((((((data[:,1])/ 2.0)) +(( 1.0)))/2.0)) +(( 1.0)))/2.0)) +(((((((((( 1.0)) / 2.0)) +(np.tanh(((1.0)))))/2.0)) +(np.tanh(((((( 1.0)) +(( 1.0)))/2.0)))))/2.0)))/2.0)) +(((( data[:,20])+(( 1.0)))/2.0)))/2.0)) +
0.250000*np.tanh(((data[:,1])*(((( data[:,14])+(np.tanh(((((0.0)) / 2.0)))))/2.0)))))
 def GP_class_10(self,data):
return(0.250000*np.tanh(((((((((( data[:,2])+(((data[:,9])*(np.tanh(( data[:,14])))))) /2.0)) +(((((( data[:,14])+(data[:,20])) /2.0)) +(data[:,0])))) /2.0)) +(data[:,14])) /2.0)) +
0.250000*np.tanh(((((( data[:,9])+(( -1.0*(((((((( 2.04309988021850586)) +(((data[:,11])+(((np.tanh(( data[:,0])))/ 2.0)))))/2.0)) * 2.0)))))) /2.0)) +(data[:,2])))+
0.250000*np.tanh(data[:,21])+
0.250000*np.tanh(((((((( data[:,14])+(np.tanh(((( data[:,6])/ 2.0)))))/2.0)) +(data[:,14])))+(((((data[:,14])* 2.0)) +(((( data[:,13])+(data[:,14])) /2.0)))))) +
0.250000*np.tanh(data[:,9])+
0.250000*np.tanh(((((((data[:,15])* 2.0)) / 2.0)) / 2.0)) +
0.250000*np.tanh(((((((( 2.72836518287658691)) *(((( 1.0)) / 2.0)))) / 2.0)) / 2.0)) +
0.250000*np.tanh(((((np.tanh(((( data[:,7])+(np.tanh(((((((((((0.0)) / 2.0)) / 2.0)) / 2.0)) / 2.0)))))))) / 2.0)) / 2.0)) +
0.250000*np.tanh(np.tanh(((( np.tanh(((11.43236827850341797)))) / 2.0)))) +
0.250000*np.tanh(np.tanh(((( data[:,7])/ 2.0)))))
 def GP_class_11(self,data):
return(0.250000*np.tanh(( -1.0*(((((((((((((( data[:,5])-(((data[:,9])-(((( -1.0*(((11.40053558349609375)))))/ 2.0)))))) +(((( 11.40053558349609375)) +(((( 11.40053558349609375)) * 2.0)))))) / 2.0)) -(data[:,7])))-(( -1.0*(((11.40053939819335938)))))))* 2.0)))))+
0.250000*np.tanh(((((data[:,14])* 2.0)) +(data[:,14])))+
0.250000*np.tanh(((data[:,2])+(((((data[:,5])+(data[:,3])))+(((( data[:,2])+(((data[:,3])* 2.0)))/2.0)))))) +
0.250000*np.tanh(((((((((((data[:,21])+(data[:,21])))+(( -1.0*(((((np.tanh(( np.tanh(((( data[:,14])/ 2.0)))))) +(data[:,21])) /2.0)))))) /2.0)) * 2.0)) +(((( data[:,14])+(data[:,3])) /2.0)))/2.0)) +
0.250000*np.tanh(((((((data[:,0])+(((( data[:,9])+(((( data[:,9])+(((((((((((((((data[:,9])/ 2.0)) -(data[:,10])))+(data[:,5])) /2.0)) -(data[:,9])))+(data[:,9])) /2.0)) / 2.0)))/2.0)))/2.0)))/2.0)) +(data[:,9])) /2.0)) +
0.250000*np.tanh(((((((( data[:,13])+(((( data[:,13])+(data[:,13])) /2.0)))) +(data[:,1])) /2.0)) / 2.0)) +
0.250000*np.tanh(data[:,14])+
0.250000*np.tanh(((((data[:,2])/ 2.0)) / 2.0)) +
0.250000*np.tanh(((( data[:,9])+(data[:,9])) /2.0)) +
0.250000*np.tanh(data[:,2]))
def GP_class_12(self,data):
return(0.250000*np.tanh(((((((( -1.0*(( data[:,18])))) -(np.tanh(( data[:,9])))))+(( 8.0)))) -(( 14.74865913391113281)))) +
0.250000*np.tanh(((((( data[:,21])+(np.tanh(( data[:,9])))))+(((((((( data[:,5])/ 2.0)) * 2.0)) +(data[:,5])) /2.0)))/2.0)) +
0.250000*np.tanh(((((data[:,14])+(data[:,14])))+(((data[:,14])* 2.0)))) +
0.250000*np.tanh(((data[:,2])+(((((((data[:,14])+(((( np.tanh(( data[:,10])))+(data[:,17])) /2.0)))/2.0)) +(data[:,21])) /2.0)))) +
0.250000*np.tanh(((( data[:,9])+(((((((((((( data[:,9])+(((((( data[:,9])/ 2.0)) +(((data[:,9])* 2.0)))/2.0)))/2.0)) +(( -1.0*(( data[:,21])))))/2.0)) *(data[:,9])))+(((((np.tanh(((( data[:,21])/ 2.0)))) / 2.0)) / 2.0)))/2.0)))/2.0)) +
0.250000*np.tanh(((((0.0)) +(data[:,13])) /2.0)) +
0.250000*np.tanh(((((((( data[:,2])/ 2.0)) * 2.0)) +(data[:,7])) /2.0)) +
0.250000*np.tanh(((((( data[:,14])* 2.0)) +(np.tanh(( data[:,14])))) /2.0)) +
0.250000*np.tanh(np.tanh(((((((((( -1.0*(((( np.tanh(( data[:,9])))/ 2.0)))))/ 2.0)) / 2.0)) +(((data[:,3])*(data[:,13])))) /2.0)))) +
0.250000*np.tanh(( -1.0*(((((((( -1.0*(((((((-1.0*(( data[:,18])))) -(((( 0.0)) / 2.0)))) / 2.0)))))+(np.tanh(((((-1.0*(((-1.0*(( data[:,22])))))))/ 2.0)))))/2.0)) / 2.0))))))
def GP_class_13(self,data):
return(0.250000*np.tanh(((((np.tanh(( np.tanh(( data[:,2])))))-(( 10.0)))) -(np.tanh(((((( data[:,7])-(((((( 6.0)) -(( 4.87243366241455078)))) -(( 9.0)))))) -(( 14.80352973937988281)))))))) +
0.250000*np.tanh(((np.tanh(((((( 3.0)) +(data[:,1])) /2.0)))) -(( 7.0)))) +
0.250000*np.tanh(((((np.tanh(( np.tanh(( np.tanh(( data[:,6])))))))* 2.0)) -(( 6.10337877273559570)))) +
0.250000*np.tanh(((((((data[:,9])+(data[:,14])))+(data[:,14])))+(data[:,14])))+
0.250000*np.tanh(((((((np.tanh(((((-1.0*(((((((data[:,2])+(( 10.0)))/2.0)) / 2.0)))))-(( 13.28130435943603516)))))) +(( 10.0)))) -(( 13.28130435943603516)))) +(( -1.0*(( data[:,5])))))) +
0.250000*np.tanh(((((((((((data[:,20])+(((((((((data[:,20])* 2.0)) * 2.0)) * 2.0)) +(data[:,13])))) /2.0)) +(((data[:,9])+(((data[:,9])+(((data[:,6])+(data[:,9])))))))) /2.0)) +(data[:,20])))+(data[:,15])))+
0.250000*np.tanh(((((((((data[:,14])/ 2.0)) +(((( data[:,9])+(((data[:,15])+(((data[:,5])+(((((( data[:,9])+(((data[:,5])+(data[:,14])))))+(data[:,9])) /2.0)))))))/2.0)))) * 2.0)) +(data[:,14])))+
0.250000*np.tanh(((( data[:,13])+(data[:,7])) /2.0)) +
0.250000*np.tanh(((data[:,9])+(((( data[:,3])+(((( data[:,21])+(data[:,3])) /2.0)))/2.0)))) +
0.250000*np.tanh(((( data[:,2])+(((((((((((((((data[:,20])+(data[:,1])))+(((data[:,2])+(data[:,14])))))+(data[:,2])))+(np.tanh(( data[:,2])))) /2.0)) +(((data[:,14])+(data[:,2])))))+(data[:,14])) /2.0)))/2.0)))
 def GP_class_14(self,data):
return(0.250000*np.tanh(((((((((((( 5.54024744033813477)) -(((((( 9.0)) * 2.0)) * 2.0)))) -(data[:,0])))-(((( 7.0)) +(( 4.74105215072631836)))))) -(((((7.0)) +(((data[:,5])* 2.0)))/2.0)))) -(( 9.0)))) +
0.250000*np.tanh(((((((((9.0)) -(( 14.27298927307128906)))) -(data[:,0])))+(np.tanh(((((12.77708148956298828)) -(( 14.80560111999511719)))))))/2.0)) +
0.250000*np.tanh(((((((0.0)) +(( -1.0*(((( data[:,22])+(((((((((13.30077362060546875)) -(np.tanh(( data[:,4])))))+(((data[:,22])/ 2.0)))/2.0)) / 2.0)))))))) /2.0)) -(((np.tanh(((( data[:,7])-(data[:,7])))))/ 2.0)))) +
0.250000*np.tanh(((((((data[:,6])+(data[:,14])) /2.0)) +(((np.tanh(((((( data[:,14])+(data[:,14])))+(((data[:,6])-(((data[:,5])+(((np.tanh(( data[:,21])))+(((( data[:,14])+(((( data[:,14])+(data[:,14])) /2.0)))/2.0)))))))))))) +(data[:,5])))) /2.0)) +
0.250000*np.tanh(((((((((((((((((( data[:,2])+(data[:,16])))+(((((( data[:,2])/ 2.0)) +(data[:,9])) /2.0)))/2.0)) +(np.tanh(( data[:,10])))) /2.0)) +(data[:,9])))+(data[:,9])) /2.0)) +(data[:,21])))+(data[:,3])))+
0.250000*np.tanh(((( data[:,13])+(((((((((((data[:,3])/ 2.0)) / 2.0)) / 2.0)) *(data[:,3])))/ 2.0)))/2.0)) +
0.250000*np.tanh(((data[:,14])+(((((((data[:,14])/ 2.0)) +(data[:,14])))* 2.0)))) +
0.250000*np.tanh(data[:,9])+
0.250000*np.tanh(((data[:,1])/ 2.0)) +
0.250000*np.tanh(((((( data[:,2])+(((((( data[:,13])+(data[:,14])))+(data[:,13])) /2.0)))) +(np.tanh(( data[:,2])))) /2.0)))
 def GP_class_15(self,data):
return(0.250000*np.tanh(((((((( 4.0)) +(((( 8.0)) / 2.0)))) -(( 9.56193733215332031)))) -(((((np.tanh(((13.93556308746337891)))) -(data[:,18])))+(( 13.93556308746337891)))))) +
0.250000*np.tanh(((data[:,4])-(((( 12.76094818115234375)) -(data[:,8])))))+
0.250000*np.tanh(((( -1.0*(((12.35446166992187500)))))-(((((12.35446166992187500)) +(((((( 12.35446166992187500)) -(( -1.0*(((0.0)))))))-(data[:,0])))) /2.0)))) +
0.250000*np.tanh(((data[:,21])-(( 14.46367263793945312)))) +
0.250000*np.tanh(((((data[:,2])+(((( data[:,9])+(( -1.0*(((-1.0*(((-1.0*(((( data[:,7])*(((data[:,21])* 2.0)))))))))))))) /2.0)))) +(data[:,9])))+
0.250000*np.tanh(((((((((((data[:,7])+(data[:,3])) /2.0)) +(data[:,20])) /2.0)) -(((( 2.33354020118713379)) / 2.0)))) -(((( 2.0)) +(( 8.78930377960205078)))))) +
0.250000*np.tanh(((((((data[:,14])+(((((((data[:,14])+(((data[:,15])+(data[:,14])))))+(((data[:,15])+(data[:,14])))))+(((data[:,14])/ 2.0)))))) +(data[:,14])))+(data[:,14])))+
0.250000*np.tanh(((((((((data[:,13])+(data[:,13])))+(((data[:,13])+(data[:,12])))))+(data[:,9])))+(((((( data[:,9])+(((data[:,13])+(((( data[:,9])+(((((data[:,13])* 2.0)) / 2.0)))/2.0)))))/2.0)) * 2.0)))) +
0.250000*np.tanh(((( data[:,9])+(((((( data[:,9])+(data[:,9])) /2.0)) / 2.0)))/2.0)) +
0.250000*np.tanh(((((( data[:,14])+(data[:,8])))+(data[:,14])) /2.0)))
 def GP_class_16(self,data):
return(0.250000*np.tanh(((((((((((((9.37592792510986328)) -(( 13.36316204071044922)))) +(( 11.89122962951660156)))/2.0)) -(((( 9.0)) -(((((((data[:,13])/ 2.0)) / 2.0)) +(((( -1.0*(((( data[:,4])/ 2.0)))))* 2.0)))))))) -(( 12.24639320373535156)))) -(( 11.89122581481933594)))) +
0.250000*np.tanh(((((np.tanh(((4.51821422576904297)))) -(( 13.23712635040283203)))) -(((((( 13.23712635040283203)) +(((data[:,22])-(((( 11.40539550781250000)) -(((((9.0)) +(((((((( data[:,7])+(((data[:,17])/ 2.0)))/2.0)) * 2.0)) / 2.0)))/2.0)))))))) -(data[:,5])))))+
0.250000*np.tanh(((data[:,14])-(((( 4.0)) +(((((13.41770648956298828)) +(( 12.42538261413574219)))/2.0)))))) +
0.250000*np.tanh(((( 5.0)) -(( 9.27778816223144531)))) +
0.250000*np.tanh(((((data[:,16])-(((((((data[:,1])-(((np.tanh(((((((( 9.29507255554199219)) -(((((((14.34461498260498047)) * 2.0)) +(((((7.0)) +(( 9.10683441162109375)))/2.0)))/2.0)))) +(( 4.21145153045654297)))/2.0)))) * 2.0)))) -(( 9.10683441162109375)))) * 2.0)))) -(((( 14.34461498260498047)) * 2.0)))) +
0.250000*np.tanh(((((((((( data[:,17])/ 2.0)) +(((data[:,13])+(data[:,9])))) /2.0)) +(((data[:,17])+(data[:,9])))))+(data[:,0])))+
0.250000*np.tanh(((data[:,13])+(((data[:,14])-(data[:,21])))))+
0.250000*np.tanh(((((( data[:,14])+(data[:,5])) /2.0)) +(((((((data[:,9])/ 2.0)) +(data[:,14])))/ 2.0)))) +
0.250000*np.tanh(((((( data[:,17])+(data[:,9])))+(((((data[:,17])/ 2.0)) +(((((((((( data[:,9])+(data[:,9])))-(( 3.0)))) +(data[:,7])))+(data[:,9])) /2.0)))))/2.0)) +
0.250000*np.tanh(np.tanh(((((((((((((((data[:,2])+(((((((((((data[:,22])+(data[:,21])) /2.0)) +(data[:,2])) /2.0)) * 2.0)) +(((((( data[:,21])* 2.0)) +(data[:,21])) /2.0)))))) +(data[:,2])) /2.0)) +(data[:,17])) /2.0)) +(np.tanh(( data[:,8])))) /2.0)) +(data[:,2]))))))
def GP_class_17(self,data):
return(0.250000*np.tanh(((((data[:,14])-(((( data[:,5])+(((((14.43326377868652344)) +(( 6.0)))/2.0)))/2.0)))) -(((((((10.0)) +(( 14.84462165832519531)))/2.0)) -(((( 7.0)) +(data[:,13])))))))+
0.250000*np.tanh(((((((((( data[:,14])+(((((((((data[:,11])-(( 9.71331787109375000)))) / 2.0)) +(( 9.0)))) -(( 3.0)))))/2.0)) -(( 10.0)))) -(((( 10.0)) +(((( 9.0)) -(((((( 10.0)) -(( 9.0)))) / 2.0)))))))) -(( 10.0)))) +
0.250000*np.tanh(((((((((( 8.0)) -(( 12.78277492523193359)))) -(data[:,10])))-(np.tanh(((((((7.0)) -(( 14.95321178436279297)))) -(( 8.0)))))))) -(( 14.95321178436279297)))) +
0.250000*np.tanh(((( 7.45682907104492188)) -(( 14.98023796081542969)))) +
0.250000*np.tanh(((((((((((7.0)) +(((((np.tanh(((((((( 8.0)) *(data[:,8])))+(data[:,11])) /2.0)))) / 2.0)) -(( 8.0)))))/2.0)) -(data[:,20])))-(((( 8.0)) * 2.0)))) +(( 8.0)))) +
0.250000*np.tanh(((data[:,8])+(((data[:,4])+(((np.tanh(( data[:,4])))+(((data[:,13])+(data[:,13])))))))))+
0.250000*np.tanh(data[:,14])+
0.250000*np.tanh(((((((((((data[:,14])+(np.tanh(((( data[:,3])*(data[:,13])))))))+(data[:,14])))+(data[:,0])))+(data[:,8])))/ 2.0)) +
0.250000*np.tanh(((((( data[:,9])+(np.tanh(((((((data[:,19])*(((((((data[:,1])+(((((((data[:,21])+(data[:,9])) /2.0)) +(data[:,6])) /2.0)))/2.0)) +(data[:,17])) /2.0)))) +(((data[:,15])/ 2.0)))/2.0)))))/2.0)) * 2.0)) +
0.250000*np.tanh(((data[:,1])+(((((data[:,3])+(data[:,15])))+(np.tanh(((((data[:,20])+(((data[:,1])* 2.0)))/2.0)))))))))
 def GP_class_18(self,data):
return(0.250000*np.tanh(((((((((( 12.59485149383544922)) -(( 12.59485149383544922)))) -(( 12.59485149383544922)))) -(((( 11.47756862640380859)) / 2.0)))) -(( 12.59485149383544922)))) +
0.250000*np.tanh(((((( -1.0*(((11.26121807098388672)))))-(((((((((11.33140659332275391)) -(( -1.0*(((9.76293182373046875)))))))-(((((11.33140659332275391)) +(( 8.0)))/2.0)))) +(( 9.76293182373046875)))/2.0)))) -(data[:,11])))+
0.250000*np.tanh(((((((((((3.40250444412231445)) -(np.tanh(((14.86789989471435547)))))) -(( 14.86789989471435547)))) +(((((( data[:,5])+(( -1.0*(((((14.86789989471435547)) * 2.0)))))) /2.0)) -(( 14.86789989471435547)))))/2.0)) -(((((14.86789989471435547)) +(((((7.0)) +(( -1.0*(( data[:,16])))))/2.0)))/2.0)))) +
0.250000*np.tanh(((data[:,18])-(( 11.84332561492919922)))) +
0.250000*np.tanh(((((np.tanh(((((8.96548557281494141)) *(data[:,12])))))-(( -1.0*(((( data[:,2])*(((((data[:,4])-(( -1.0*(( data[:,9])))))) -(( 9.0)))))))))))-(( 8.96548557281494141)))) +
0.250000*np.tanh(((((((10.0)) -(data[:,12])))+(((((((((data[:,13])-(( 12.43707370758056641)))) -(((( 12.43707370758056641)) -(((data[:,12])/ 2.0)))))) -(((( 12.43707370758056641)) -(((( data[:,13])+(( 12.43707370758056641)))/2.0)))))) -(( 12.43707370758056641)))))/2.0)) +
0.250000*np.tanh(((((((np.tanh(((( np.tanh(( data[:,14])))+(data[:,13])))))* 2.0)) +(data[:,14])))+(data[:,13])))+
0.250000*np.tanh(((np.tanh(( data[:,14])))+(data[:,14])))+
0.250000*np.tanh(((((data[:,9])+(((((data[:,13])+(data[:,4])))+(data[:,13])))))/ 2.0)) +
0.250000*np.tanh(((data[:,15])-(((( data[:,3])+(( 5.0)))/2.0)))))
 def GP_class_19(self,data):
return(0.250000*np.tanh(((((( data[:,13])+(data[:,13])) /2.0)) +(((((( data[:,8])+(((( data[:,14])+(data[:,14])) /2.0)))/2.0)) * 2.0)))) +
0.250000*np.tanh(((( data[:,3])+(((data[:,8])+(np.tanh(((((((-1.0*(((((( 9.05535793304443359)) +(((( data[:,14])+(((((((data[:,1])-(((data[:,12])* 2.0)))) *(( -1.0*(( data[:,17])))))) / 2.0)))/2.0)))/2.0)))))+(data[:,2])))* 2.0)))))))/2.0)) +
0.250000*np.tanh(((((((((data[:,3])+(((((data[:,14])+(data[:,14])))* 2.0)))) +(((( data[:,14])+(np.tanh(((( data[:,14])+(np.tanh(( data[:,14])))))))) /2.0)))) * 2.0)) +(((( data[:,14])+(data[:,2])) /2.0)))) +
0.250000*np.tanh(((((data[:,8])+(((data[:,4])+(((data[:,13])+(data[:,10])))))))+(((((data[:,13])+(((((data[:,13])/ 2.0)) +(data[:,9])))))+(np.tanh(((((data[:,8])+(data[:,8])) /2.0)))))))) +
0.250000*np.tanh(((((( data[:,19])+(((((data[:,10])+(((( data[:,11])+(data[:,19])) /2.0)))) +(data[:,10])))) /2.0)) +(data[:,2])))+
0.250000*np.tanh(((((( data[:,0])+(((((((((data[:,0])+(((((data[:,0])-(data[:,11])))/ 2.0)))/2.0)) * 2.0)) +(((((( np.tanh(( data[:,13])))+(((data[:,0])/ 2.0)))/2.0)) / 2.0)))/2.0)))/2.0)) * 2.0)) +
0.250000*np.tanh(((((-1.0*(( data[:,15])))) +(((data[:,14])+(data[:,14])))) /2.0)) +
0.250000*np.tanh(((((((((data[:,0])+(data[:,15])) /2.0)) +(((data[:,15])*(data[:,15])))) /2.0)) -(data[:,11])))+
0.250000*np.tanh(data[:,13])+
0.250000*np.tanh(((((((((data[:,18])+(((( data[:,4])+(data[:,18])) /2.0)))) / 2.0)) +(((( data[:,18])+(data[:,4])) /2.0)))) *(data[:,4]))))<set_options>
train_data.drop(train_data[(train_data['OverallQual']<5)&(train_data['SalePrice']>200000)].index, inplace=True)
 train_data.drop(train_data[(train_data['GrLivArea']>4500)&(train_data['SalePrice']<300000)].index, inplace=True)
 train_data.reset_index(drop=True, inplace=True )
pd.set_option('display.max_columns', 50)
 pd.set_option('display.max_rows', 150 )<import_modules>
train=train_data.copy()
from keras.layers import Dense
from keras.models import Sequential
from keras.callbacks import Callback, EarlyStopping
from keras.layers import Dropout<load_from_csv>
train['SalePrice']=np.log(train['SalePrice'] )
train = pd.read_csv('/kaggle/input/nfl-big-data-bowl-2020/train.csv', usecols=['GameId', 'PlayId', 'Team', 'X', 'Y', 'S', 'A', 'Dis',
'Orientation', 'Dir', 'NflId', 'DisplayName', 'YardLine',
'Quarter', 'GameClock', 'PossessionTeam', 'Down', 'Distance',
'FieldPosition', 'NflIdRusher', 'OffenseFormation',
'OffensePersonnel', 'DefendersInTheBox', 'DefensePersonnel',
'PlayDirection', 'TimeHandoff', 'TimeSnap', 'Yards'] )<remove_duplicates>
ntrain = train.shape[0]
ntest = test.shape[0]
y_train = train.SalePrice.values
df = pd.concat(( train, test)).reset_index(drop=True )
outcomes = train[['GameId','PlayId','Yards']].drop_duplicates()<prepare_x_and_y>
y=df['SalePrice'].copy()
def create_features(df, deploy=False):
def new_X(x_coordinate, play_direction):
if play_direction == 'left':
return 120.0 - x_coordinate
else:
return x_coordinate
def new_line(rush_team, field_position, yardline):
if rush_team == field_position:
return 10.0 + yardline
else:
return 60.0 +(50 - yardline)
 def new_orientation(angle, play_direction):
if play_direction == 'left':
new_angle = 360.0 - angle
if new_angle == 360.0:
new_angle = 0.0
return new_angle
else:
return angle
def euclidean_distance(x1,y1,x2,y2):
x_diff =(x1-x2)**2
y_diff =(y1-y2)**2
return np.sqrt(x_diff + y_diff)
 def back_direction(orientation):
if orientation > 180.0:
return 1
else:
return 0
def update_yardline(df):
new_yardline = df[df['NflId'] == df['NflIdRusher']]
new_yardline['YardLine'] = new_yardline[['PossessionTeam','FieldPosition','YardLine']].apply(lambda x: new_line(x[0],x[1],x[2]), axis=1)
 new_yardline = new_yardline[['GameId','PlayId','YardLine']]
return new_yardline
def update_orientation(df, yardline):
df['X'] = df[['X','PlayDirection']].apply(lambda x: new_X(x[0],x[1]), axis=1)
 df['Orientation'] = df[['Orientation','PlayDirection']].apply(lambda x: new_orientation(x[0],x[1]), axis=1)
 df['Dir'] = df[['Dir','PlayDirection']].apply(lambda x: new_orientation(x[0],x[1]), axis=1)
 df = df.drop('YardLine', axis=1)
 df = pd.merge(df, yardline, on=['GameId','PlayId'], how='inner')
 return df
def back_features(df):
carriers = df[df['NflId'] == df['NflIdRusher']][['GameId','PlayId','NflIdRusher','X','Y','Orientation','Dir','YardLine']]
carriers['back_from_scrimmage'] = carriers['YardLine'] - carriers['X']
carriers['back_oriented_down_field'] = carriers['Orientation'].apply(lambda x: back_direction(x))
carriers['back_moving_down_field'] = carriers['Dir'].apply(lambda x: back_direction(x))
carriers = carriers.rename(columns={'X':'back_X',
'Y':'back_Y'})
 carriers = carriers[['GameId','PlayId','NflIdRusher','back_X','back_Y','back_from_scrimmage','back_oriented_down_field','back_moving_down_field']]
return carriers
def features_relative_to_back(df, carriers):
player_distance = df[['GameId','PlayId','NflId','X','Y']]
player_distance = pd.merge(player_distance, carriers, on=['GameId','PlayId'], how='inner')
 player_distance = player_distance[player_distance['NflId'] != player_distance['NflIdRusher']]
player_distance['dist_to_back'] = player_distance[['X','Y','back_X','back_Y']].apply(lambda x: euclidean_distance(x[0],x[1],x[2],x[3]), axis=1)
 player_distance = player_distance.groupby(['GameId','PlayId','back_from_scrimmage','back_oriented_down_field','back_moving_down_field'])\ 
.agg({'dist_to_back':['min','max','mean','std']})\ 
.reset_index()
player_distance.columns = ['GameId','PlayId','back_from_scrimmage','back_oriented_down_field','back_moving_down_field',
'min_dist','max_dist','mean_dist','std_dist']
return player_distance
def defense_features(df):
rusher = df[df['NflId'] == df['NflIdRusher']][['GameId','PlayId','Team','X','Y']]
rusher.columns = ['GameId','PlayId','RusherTeam','RusherX','RusherY']
defense = pd.merge(df,rusher,on=['GameId','PlayId'],how='inner')
 defense = defense[defense['Team'] != defense['RusherTeam']][['GameId','PlayId','X','Y','RusherX','RusherY']]
defense['def_dist_to_back'] = defense[['X','Y','RusherX','RusherY']].apply(lambda x: euclidean_distance(x[0],x[1],x[2],x[3]), axis=1)
 defense = defense.groupby(['GameId','PlayId'])\ 
.agg({'def_dist_to_back':['min','max','mean','std']})\ 
.reset_index()
defense.columns = ['GameId','PlayId','def_min_dist','def_max_dist','def_mean_dist','def_std_dist']
return defense
def static_features(df):
static_features = df[df['NflId'] == df['NflIdRusher']][['GameId','PlayId','X','Y','S','A','Dis','Orientation','Dir',
'YardLine','Quarter','Down','Distance','DefendersInTheBox']].drop_duplicates()
static_features['DefendersInTheBox'] = static_features['DefendersInTheBox'].fillna(np.mean(static_features['DefendersInTheBox']))
return static_features
def combine_features(relative_to_back, defense, static, deploy=deploy):
df = pd.merge(relative_to_back,defense,on=['GameId','PlayId'],how='inner')
 df = pd.merge(df,static,on=['GameId','PlayId'],how='inner')
 if not deploy:
df = pd.merge(df, outcomes, on=['GameId','PlayId'], how='inner')
 return df
yardline = update_yardline(df)
 df = update_orientation(df, yardline)
 back_feats = back_features(df)
 rel_back = features_relative_to_back(df, back_feats)
 def_feats = defense_features(df)
 static_feats = static_features(df)
 basetable = combine_features(rel_back, def_feats, static_feats, deploy=deploy)
 return basetable<feature_engineering>
df1 =(df.isnull().sum() / len(df)) * 100
df1 = df1.drop(df1[df1 == 0].index ).sort_values(ascending=False)[:30]
missing_data = pd.DataFrame({'Missing Ratio' :df1})
 missing_data.head(20 )
%time train_basetable = create_features(train, False )<prepare_x_and_y>
data=df.copy()
X = train_basetable.copy()
yards = X.Yards
y = np.zeros(( yards.shape[0], 199))
for idx, target in enumerate(list(yards)) :
y[idx][99 + target] = 1
X.drop(['GameId','PlayId','Yards'], axis=1, inplace=True )<normalization>
test_data=test.copy()
scaler = StandardScaler()
X = scaler.fit_transform(X )<split>
data = data.drop(['Alley', 'PoolQC', 'Fence', 'MiscFeature'], axis=1)
 data.head()
X_train, X_val, y_train, y_val = train_test_split(X, y, test_size=0.15, random_state=12345 )<train_model>
class Metric(Callback):
def __init__(self, model, callbacks, data):
super().__init__()
self.model = model
self.callbacks = callbacks
self.data = data
def on_train_begin(self, logs=None):
for callback in self.callbacks:
callback.on_train_begin(logs)
 def on_train_end(self, logs=None):
for callback in self.callbacks:
callback.on_train_end(logs)
 def on_epoch_end(self, batch, logs=None):
X_train, y_train = self.data[0][0], self.data[0][1]
y_pred = self.model.predict(X_train)
 y_true = np.clip(np.cumsum(y_train, axis=1), 0, 1)
 y_pred = np.clip(np.cumsum(y_pred, axis=1), 0, 1)
 tr_s =(( y_true - y_pred)** 2 ).sum(axis=1 ).sum(axis=0)/(199 * X_train.shape[0])
 tr_s = np.round(tr_s, 6)
 logs['tr_CRPS'] = tr_s
X_valid, y_valid = self.data[1][0], self.data[1][1]
y_pred = self.model.predict(X_valid)
 y_true = np.clip(np.cumsum(y_valid, axis=1), 0, 1)
 y_pred = np.clip(np.cumsum(y_pred, axis=1), 0, 1)
 val_s =(( y_true - y_pred)** 2 ).sum(axis=1 ).sum(axis=0)/(199 * X_valid.shape[0])
 val_s = np.round(val_s, 6)
 logs['val_CRPS'] = val_s
print('tr CRPS', tr_s, 'val CRPS', val_s)
 for callback in self.callbacks:
callback.on_epoch_end(batch, logs )<choose_model_class>
train_labels = y.apply(lambda x: np.log(1+x))
model = Sequential()
model.add(Dense(512, input_dim=X.shape[1], activation='relu'))
model.add(Dropout(0.4))
model.add(Dense(256, activation='relu'))
model.add(Dropout(0.2))
model.add(Dense(199, activation='softmax'))<choose_model_class>
data['MSSubClass'] = data['MSSubClass'].apply(str)
 data['YrSold'] = data['YrSold'].astype(str)
 data['MoSold'] = data['MoSold'].astype(str)
 data['Functional'] = data['Functional'].fillna('Typ')
 data['Electrical'] = data['Electrical'].fillna("SBrkr")
 data['KitchenQual'] = data['KitchenQual'].fillna("TA")
 data['Exterior1st'] = data['Exterior1st'].fillna(data['Exterior1st'].mode() [0])
 data['Exterior2nd'] = data['Exterior2nd'].fillna(data['Exterior2nd'].mode() [0])
 data['SaleType'] = data['SaleType'].fillna(data['SaleType'].mode() [0])
 data['MSZoning'] = data.groupby('MSSubClass')['MSZoning'].transform(lambda x: x.fillna(x.mode() [0]))
for col in('GarageYrBlt', 'GarageArea', 'GarageCars'):
data[col] = data[col].fillna(0)
 for col in ['GarageType', 'GarageFinish', 'GarageQual', 'GarageCond']:
data[col] = data[col].fillna('None')
 for col in('BsmtQual', 'BsmtCond', 'BsmtExposure', 'BsmtFinType1', 'BsmtFinType2'):
data[col] = data[col].fillna('None')
 data['LotFrontage'] = data.groupby('Neighborhood')['LotFrontage'].transform(lambda x: x.fillna(x.median()))
model.compile(optimizer='Adam', loss='categorical_crossentropy', metrics=[] )<choose_model_class>
objects = []
for i in data.columns:
if data[i].dtype == object:
objects.append(i)
 data.update(data[objects].fillna('None'))
numeric_dtypes = ['int16', 'int32', 'int64', 'float16', 'float32', 'float64']
numeric = []
for i in data.columns:
if data[i].dtype in numeric_dtypes:
numeric.append(i)
 data.update(data[numeric].fillna(0))
es = EarlyStopping(monitor='val_CRPS',
mode='min',
restore_best_weights=True,
verbose=1,
patience=5)
 es.set_model(model )<create_dataframe>
data.isna().sum()
metric = Metric(model, [es], [(X_train,y_train),(X_val,y_val)] )<train_model>
df1=data.copy()
%%time
model.fit(X_train, y_train, callbacks=[metric], epochs=250, batch_size=1024 )<import_modules>
all_data_na =(df1.isnull().sum() / len(df1)) * 100
df2 = all_data_na.drop(all_data_na[all_data_na == 0].index ).sort_values(ascending=False)
 missing_data = pd.DataFrame({'Missing Ratio' :df2})
 missing_data.head()
class GP:
def __init__(self):
self.classes = 20
self.class_names = [ 'class_0',
'class_1',
'class_2',
'class_3',
'class_4',
'class_5',
'class_6',
'class_7',
'class_8',
'class_9',
'class_10',
'class_11',
'class_12',
'class_13',
'class_14',
'class_15',
'class_16',
'class_17',
'class_18',
'class_19',
]
def GrabPredictions(self, data):
oof_preds = np.zeros(( len(data), len(self.class_names)))
 oof_preds[:,0] = self.GP_class_0(data)
 oof_preds[:,1] = self.GP_class_1(data)
 oof_preds[:,2] = self.GP_class_2(data)
 oof_preds[:,3] = self.GP_class_3(data)
 oof_preds[:,4] = self.GP_class_4(data)
 oof_preds[:,5] = self.GP_class_5(data)
 oof_preds[:,6] = self.GP_class_6(data)
 oof_preds[:,7] = self.GP_class_7(data)
 oof_preds[:,8] = self.GP_class_8(data)
 oof_preds[:,9] = self.GP_class_9(data)
 oof_preds[:,10] = self.GP_class_10(data)
 oof_preds[:,11] = self.GP_class_11(data)
 oof_preds[:,12] = self.GP_class_12(data)
 oof_preds[:,13] = self.GP_class_13(data)
 oof_preds[:,14] = self.GP_class_14(data)
 oof_preds[:,15] = self.GP_class_15(data)
 oof_preds[:,16] = self.GP_class_16(data)
 oof_preds[:,17] = self.GP_class_17(data)
 oof_preds[:,18] = self.GP_class_18(data)
 oof_preds[:,19] = self.GP_class_19(data)
 oof_df = pd.DataFrame(np.exp(oof_preds), columns=self.class_names)
 oof_df =oof_df.div(oof_df.sum(axis=1), axis=0)
 return oof_df.values
def GP_class_0(self,data):
return(0.250000*np.tanh(((((((data[:,0])-(((data[:,0])+(data[:,0])))))+(data[:,0])))+(((((data[:,0])* 2.0)) * 2.0)))) +
0.250000*np.tanh(((((((((((((data[:,2])-(data[:,7])))* 2.0)) +(data[:,7])))* 2.0)) +(data[:,0])))+(((((data[:,2])+(data[:,0])))-(data[:,7])))))+
0.250000*np.tanh(((((((((((((((((((data[:,3])-(data[:,7])))-(((data[:,0])/ 2.0)))) +(data[:,0])))-(data[:,7])))+(data[:,2])))+(((data[:,7])+(data[:,2])))))+(data[:,7])))-(data[:,7])))+(data[:,0])))+
0.250000*np.tanh(((((((((data[:,0])-(data[:,7])))-(data[:,14])))+(((data[:,17])-(data[:,14])))))+(((((((data[:,0])-(( 1.0)))) -(data[:,0])))+(data[:,20])))))+
0.250000*np.tanh(((((data[:,18])+(((((((data[:,0])-(data[:,7])))+(data[:,2])))+(data[:,0])))))-(((data[:,7])+(data[:,2])))))+
0.250000*np.tanh(((((((( data[:,8])+(((((((( data[:,13])+(data[:,3])))+(data[:,0])) /2.0)) +(((((((( data[:,0])+(((((data[:,0])-(data[:,0])))/ 2.0)))) +(data[:,17])) /2.0)) +(data[:,11])))))) /2.0)) +(data[:,0])))-(data[:,13])))+
0.250000*np.tanh(((((data[:,0])* 2.0)) +(((((((((data[:,2])+(data[:,2])))* 2.0)) -(((data[:,14])-(((np.tanh(( data[:,2])))* 2.0)))))) -(data[:,7])))))+
0.250000*np.tanh(((((((((((((data[:,17])-(((data[:,17])*(((((data[:,17])*(data[:,17])))* 2.0)))))) +(((((((data[:,17])* 2.0)) * 2.0)) * 2.0)))/2.0)) / 2.0)) +(((data[:,17])-(( 7.76236486434936523)))))/2.0)) +(((((((data[:,17])*(data[:,17])))* 2.0)) * 2.0)))) +
0.250000*np.tanh(((((((((((data[:,17])+(data[:,17])) /2.0)) +(((( data[:,17])+(((( data[:,17])+(data[:,17])) /2.0)))/2.0)))/2.0)) *(data[:,17])))-(data[:,13])))+
0.250000*np.tanh(((((( data[:,19])+(((((((((data[:,19])* 2.0)) +(data[:,19])))-(( 1.07645297050476074)))) +(((data[:,22])+(data[:,22])))))) /2.0)) +(((data[:,22])+(data[:,4]))))))
def GP_class_1(self,data):
return(0.250000*np.tanh(((((((((((((data[:,3])+(((np.tanh(( data[:,2])))-(data[:,14])))))-(( 10.0)))) -(( 4.88989353179931641)))) -(( 13.92175483703613281)))) / 2.0)) -(data[:,6])))+
0.250000*np.tanh(data[:,3])+
0.250000*np.tanh(((data[:,2])+(((((np.tanh(((( data[:,14])* 2.0)))) -(((((((data[:,7])* 2.0)) -(((((data[:,0])-(data[:,14])))-(data[:,7])))))-(data[:,0])))))+(data[:,0])))))+
0.250000*np.tanh(((((((data[:,0])-(( -1.0*(( data[:,14])))))) +(((((((((( data[:,0])-(data[:,7])))-(((( data[:,14])+(data[:,14])) /2.0)))) +(((data[:,2])-(((data[:,0])*(data[:,14])))))) /2.0)) -(data[:,14])))))-(data[:,7])))+
0.250000*np.tanh(((((data[:,0])/ 2.0)) +(data[:,0])))+
0.250000*np.tanh(((((data[:,19])-(data[:,19])))/ 2.0)) +
0.250000*np.tanh(((((np.tanh(((( np.tanh(( data[:,5])))-(((( 1.69341480731964111)) +(((((( np.tanh(( data[:,14])))-(data[:,14])))+(data[:,14])) /2.0)))))))) -(data[:,2])))-(((data[:,14])* 2.0)))) +
0.250000*np.tanh(((((( data[:,22])+(((data[:,0])+(((((((( data[:,22])/ 2.0)) +(( -1.0*(( data[:,13])))))/2.0)) +(data[:,19])))))) /2.0)) -(data[:,13])))+
0.250000*np.tanh(((((((data[:,17])/ 2.0)) *(data[:,17])))*(((data[:,17])+(((data[:,17])*(((((((((data[:,17])+(data[:,17])))*(data[:,17])))*(data[:,17])))+(((np.tanh(( data[:,17])))/ 2.0)))))))))) +
0.250000*np.tanh(((((( data[:,14])*(((data[:,13])+(data[:,3])))))+(((data[:,14])*(((data[:,14])-(( -1.0*(( data[:,3])))))))))/2.0)))
 def GP_class_2(self,data):
return(0.250000*np.tanh(((data[:,0])+(np.tanh(((((((((( data[:,2])+(((data[:,2])/ 2.0)))/2.0)) +(data[:,0])) /2.0)) *(data[:,7])))))))+
0.250000*np.tanh(((( data[:,22])+(data[:,22])) /2.0)) +
0.250000*np.tanh(((((( data[:,14])+(( -1.0*(((((( 4.73206138610839844)) +(((((((((((np.tanh(( data[:,7])))+(data[:,1])) /2.0)) -(np.tanh(((((( data[:,0])-(data[:,20])))-(data[:,14])))))))*(( 7.0)))) +(data[:,14])) /2.0)))/2.0)))))) /2.0)) -(data[:,14])))+
0.250000*np.tanh(((((data[:,1])+(( 4.15603733062744141)))) / 2.0)) +
0.250000*np.tanh(((((((((((((data[:,0])-(data[:,7])))-(data[:,7])))+(((( data[:,0])+(data[:,0])) /2.0)))) * 2.0)) +(data[:,0])))* 2.0)) +
0.250000*np.tanh(((((data[:,11])/ 2.0)) / 2.0)) +
0.250000*np.tanh(((((((((((((((((((((((data[:,2])/ 2.0)) +(((data[:,2])/ 2.0)))/2.0)) / 2.0)) / 2.0)) / 2.0)) +(((( -1.0*(((( data[:,0])/ 2.0)))))*(((data[:,0])/ 2.0)))))/2.0)) +(data[:,0])) /2.0)) +(np.tanh(( data[:,0])))) /2.0)) / 2.0)) +
0.250000*np.tanh(((((data[:,0])+(((data[:,0])+(((((((data[:,14])*(data[:,14])))+(data[:,14])))-(data[:,0])))))))-(data[:,14])))+
0.250000*np.tanh(((((( np.tanh(( np.tanh(((0.0)))))) *(data[:,15])))+(data[:,20])) /2.0)) +
0.250000*np.tanh(((data[:,14])*(((( data[:,13])+(((( data[:,13])+(((( data[:,14])+(((((( data[:,14])+(((( data[:,14])+(((data[:,13])-(((( -1.0*(((((data[:,14])+(data[:,14])) /2.0)))))* 2.0)))))/2.0)))) +(data[:,14])) /2.0)))/2.0)))/2.0)))/2.0)))))
 def GP_class_3(self,data):
return(0.250000*np.tanh(((((((((8.0)) +(((((((5.33416414260864258)) +(( 9.0)))/2.0)) +(((( 8.0)) * 2.0)))))) * 2.0)) +(( 5.33416414260864258)))/2.0)) +
0.250000*np.tanh(((( 9.48088836669921875)) +(((((10.56953334808349609)) +(((( 4.48959350585937500)) +(np.tanh(((((3.0)) +(( 9.0)))))))))/2.0)))) +
0.250000*np.tanh(((((((((( data[:,22])/ 2.0)) +(data[:,22])) /2.0)) * 2.0)) / 2.0)) +
0.250000*np.tanh(( 10.44883441925048828)) +
0.250000*np.tanh(((((data[:,0])+(((data[:,0])+(( -1.0*(( data[:,9])))))))) +(((((data[:,0])-(data[:,7])))-(data[:,9])))))+
0.250000*np.tanh(((np.tanh(( data[:,6])))-(data[:,21])))+
0.250000*np.tanh(((data[:,0])-(((((data[:,14])+(((((data[:,14])+(((data[:,14])+(((data[:,14])-(data[:,0])))))))-(((((data[:,0])-(data[:,14])))+(data[:,14])))))))-(((((data[:,14])*(data[:,14])))+(data[:,18])))))))+
0.250000*np.tanh(((data[:,14])*(((( data[:,13])+(data[:,14])) /2.0)))) +
0.250000*np.tanh(((((( data[:,8])*(((data[:,8])/ 2.0)))) +(((((( data[:,9])*(data[:,8])))+(data[:,8])) /2.0)))/2.0)) +
0.250000*np.tanh(((( data[:,2])+(((((((data[:,2])+(data[:,20])) /2.0)) +(((((((( data[:,2])+(data[:,8])) /2.0)) / 2.0)) -(data[:,8])))) /2.0)))/2.0)))
 def GP_class_4(self,data):
return(0.250000*np.tanh(((( 12.98819637298583984)) / 2.0)) +
0.250000*np.tanh(((((4.75780344009399414)) +(((((((8.66014671325683594)) +(( 4.18107128143310547)))/2.0)) *(( 8.97841739654541016)))))/2.0)) +
0.250000*np.tanh(((( 9.0)) / 2.0)) +
0.250000*np.tanh(((((((((((10.0)) +(np.tanh(((((( 6.0)) +(((( 13.80149555206298828)) +(( 7.0)))))/2.0)))))) +(( 10.0)))) +(((((((data[:,0])+(( 8.0)))) / 2.0)) / 2.0)))/2.0)) +(((( -1.0*(((( data[:,2])*(data[:,9])))))) * 2.0)))) +
0.250000*np.tanh(((((data[:,0])+(((((((data[:,22])+(data[:,22])) /2.0)) +(data[:,22])) /2.0)))) +(((((( data[:,22])+(((((( data[:,22])* 2.0)) +(data[:,22])) /2.0)))) +(data[:,18])) /2.0)))) +
0.250000*np.tanh(((((((((((((np.tanh(( data[:,18])))+(((( data[:,1])+(data[:,18])) /2.0)))/2.0)) *(data[:,18])))*(data[:,18])))+(((data[:,18])*(data[:,18])))) /2.0)) -(((((((np.tanh(( data[:,18])))+(((data[:,18])*(data[:,18])))) /2.0)) +(data[:,17])) /2.0)))) +
0.250000*np.tanh(((np.tanh(((((((np.tanh(( data[:,6])))-(((np.tanh(( data[:,6])))-(data[:,6])))))+(np.tanh(( data[:,6])))) /2.0)))) -(((( data[:,10])+(((( data[:,2])+(((np.tanh(( data[:,6])))-(((np.tanh(( np.tanh(( data[:,6])))))-(data[:,10])))))) /2.0)))/2.0)))) +
0.250000*np.tanh(((((((((((( data[:,10])+(data[:,4])))+(((data[:,10])+(((data[:,0])*(data[:,10])))))) /2.0)) +(((data[:,4])*(((data[:,10])+(data[:,4])))))) /2.0)) +(data[:,7])) /2.0)) +
0.250000*np.tanh(((((( data[:,11])+(((((data[:,18])/ 2.0)) *(((data[:,11])*(data[:,18])))))) /2.0)) *(((data[:,18])*(((((((((data[:,18])*(((((((data[:,11])/ 2.0)) / 2.0)) *(data[:,18])))))/ 2.0)) / 2.0)) *(( -1.0*(( data[:,21])))))))))) +
0.250000*np.tanh(((( -1.0*(((((((((((( data[:,2])-(data[:,2])))*(np.tanh(( data[:,2])))))+(np.tanh(((( data[:,14])* 2.0)))))/2.0)) +(data[:,2])) /2.0)))))-(data[:,2]))))
def GP_class_5(self,data):
return(0.250000*np.tanh(((((((((((3.46574378013610840)) +(((( np.tanh(((3.46574378013610840)))) +(( 8.46705245971679688)))/2.0)))/2.0)) * 2.0)) +(((( 3.46574378013610840)) +(( 4.0)))))) +(((( 4.0)) * 2.0)))) +
0.250000*np.tanh(((( 10.55856513977050781)) / 2.0)) +
0.250000*np.tanh(((( 3.76695251464843750)) / 2.0)) +
0.250000*np.tanh(((((( 6.0)) / 2.0)) +(((( 8.57984828948974609)) * 2.0)))) +
0.250000*np.tanh(((((((((((( 3.42168045043945312)) +(data[:,7])))+(np.tanh(( data[:,7])))))+(np.tanh(( np.tanh(( np.tanh(((3.42168045043945312)))))))))/2.0)) +(data[:,7])) /2.0)) +
0.250000*np.tanh(((((((((((data[:,6])-(data[:,9])))+(data[:,7])) /2.0)) * 2.0)) +(((((( data[:,7])+(data[:,9])) /2.0)) -(data[:,9])))) /2.0)) +
0.250000*np.tanh(((((((((((data[:,22])+(data[:,22])))+(data[:,11])) /2.0)) +(data[:,22])) /2.0)) / 2.0)) +
0.250000*np.tanh(((((((((( 0.76044219732284546)) / 2.0)) +(( 0.76044219732284546)))/2.0)) +(np.tanh(( np.tanh(((((((( 0.76043862104415894)) / 2.0)) +(( 1.0)))/2.0)))))))/2.0)) +
0.250000*np.tanh(((((((data[:,12])+(np.tanh(( data[:,9])))) /2.0)) +(((((((((((data[:,12])+(((((0.0)) +(np.tanh(((((((( data[:,7])+(data[:,6])) /2.0)) +(data[:,7])) /2.0)))))/2.0)))/2.0)) / 2.0)) / 2.0)) +(data[:,7])) /2.0)))/2.0)) +
0.250000*np.tanh(((((((((data[:,20])/ 2.0)) / 2.0)) *(((np.tanh(( data[:,20])))*(((data[:,20])/ 2.0)))))) *(((((( data[:,20])/ 2.0)) +(((data[:,20])/ 2.0)))/2.0)))))
 def GP_class_6(self,data):
return(0.250000*np.tanh(((((((11.68076229095458984)) +(((((11.68075847625732422)) +(((( 11.47270107269287109)) +(((((11.47269725799560547)) +(( 11.68076229095458984)))/2.0)))))/2.0)))/2.0)) +(((( 4.0)) * 2.0)))) +
0.250000*np.tanh(((( 8.0)) +(((( 10.0)) +(( 6.59042119979858398)))))) +
0.250000*np.tanh(((((((((((13.33760547637939453)) +(((((3.86388397216796875)) +(((((((8.18321037292480469)) +(data[:,4])))+(((((((5.95386552810668945)) +(( 12.93883609771728516)))) +(((((10.73907089233398438)) +(( 4.0)))/2.0)))/2.0)))/2.0)))/2.0)))/2.0)) +(np.tanh(((3.0)))))) -(( 2.0)))) +(((((10.61559963226318359)) +(data[:,1])) /2.0)))) +
0.250000*np.tanh(((np.tanh(((((((((((7.13513946533203125)) +(( 12.48778533935546875)))/2.0)) +(((((((7.13513565063476562)) -(( 8.12031841278076172)))) +(((((((((7.13513565063476562)) +(((( 10.69830417633056641)) +(( 10.69830799102783203)))))) +(( 10.69830799102783203)))) +(( 7.83078956604003906)))/2.0)))/2.0)))/2.0)) * 2.0)))) +(( 3.0)))) +
0.250000*np.tanh(((((((((((data[:,7])-(data[:,0])))* 2.0)) -(data[:,7])))+(data[:,7])))+(data[:,0])))+
0.250000*np.tanh(((((data[:,7])/ 2.0)) / 2.0)) +
0.250000*np.tanh(((((((((((((((( 1.0)) +(((((((data[:,2])+(((((((1.0)) *(data[:,2])))+(data[:,14])) /2.0)))/2.0)) +(( 1.0)))/2.0)))) +(((( 1.0)) -(((data[:,2])*(data[:,14])))))) /2.0)) -(data[:,2])))* 2.0)) +(data[:,14])) /2.0)) +(data[:,14])))+
0.250000*np.tanh(((np.tanh(( np.tanh(((((((data[:,19])*(( 0.0)))) +(( 0.0)))/2.0)))))) / 2.0)) +
0.250000*np.tanh(((((((( 0.0)) / 2.0)) / 2.0)) *(((((((((data[:,15])/ 2.0)) *(( 0.0)))) / 2.0)) *(((( -1.0*(((0.0)))))/ 2.0)))))) +
0.250000*np.tanh(((((data[:,15])*(((((((((((((np.tanh(((((0.09032609313726425)) / 2.0)))) / 2.0)) / 2.0)) / 2.0)) / 2.0)) / 2.0)) / 2.0)))) / 2.0)))
 def GP_class_7(self,data):
return(0.250000*np.tanh(( 10.27210903167724609)) +
0.250000*np.tanh(((((((((( 10.0)) +(((((((((8.26972770690917969)) +(( 11.06334972381591797)))/2.0)) * 2.0)) / 2.0)))) +(((((( 5.0)) +(((( 5.0)) +(( 7.92727756500244141)))))) * 2.0)))) *(( 7.92728137969970703)))) +(( 10.0)))) +
0.250000*np.tanh(( 8.42519950866699219)) +
0.250000*np.tanh(((((((data[:,14])+(data[:,14])))+(((((( 1.59392631053924561)) +(data[:,14])))+(data[:,14])))))+(np.tanh(((((( data[:,14])+(((((((3.0)) +(((data[:,14])* 2.0)))/2.0)) +(( 1.59391915798187256)))))) +(( 1.59392631053924561)))))))) +
0.250000*np.tanh(((( data[:,7])+(((data[:,0])+(((((((data[:,7])+(data[:,4])) /2.0)) +(((data[:,7])* 2.0)))/2.0)))))/2.0)) +
0.250000*np.tanh(((((((((((((( data[:,9])-(((data[:,0])-(data[:,0])))))-(((data[:,0])/ 2.0)))) / 2.0)) -(((data[:,21])-(data[:,7])))))+(data[:,21])) /2.0)) -(data[:,0])))+
0.250000*np.tanh(((((((((( 2.0)) +(((((( data[:,21])+(((( data[:,13])+(((((((((((data[:,13])* 2.0)) +(data[:,21])) /2.0)) +(data[:,13])) /2.0)) * 2.0)))/2.0)))/2.0)) -(np.tanh(((((0.0)) -(data[:,21])))))))))+(( 1.0)))/2.0)) +(data[:,13])) /2.0)) +
0.250000*np.tanh(((((data[:,14])/ 2.0)) / 2.0)) +
0.250000*np.tanh(((((((((((((((( -1.0*(((((((data[:,21])/ 2.0)) +(data[:,8])) /2.0)))))/ 2.0)) / 2.0)) / 2.0)) +(data[:,9])) /2.0)) / 2.0)) +(((((((((((( data[:,7])/ 2.0)) / 2.0)) / 2.0)) / 2.0)) +(data[:,7])) /2.0)))/2.0)) +
0.250000*np.tanh(((((((np.tanh(((1.0)))) / 2.0)) / 2.0)) / 2.0)))
 def GP_class_8(self,data):
return(0.250000*np.tanh(((((((data[:,0])+(((((6.71804094314575195)) +(data[:,15])) /2.0)))) +(((((( 11.56385326385498047)) * 2.0)) *(((( 10.48986148834228516)) +(( 11.56385326385498047)))))))) / 2.0)) +
0.250000*np.tanh(((((((((( data[:,14])/ 2.0)) +(( 2.83755254745483398)))/2.0)) +(((((( data[:,12])+(data[:,14])) /2.0)) +(data[:,14])))))+(((( data[:,9])+(((data[:,12])+(data[:,14])))) /2.0)))) +
0.250000*np.tanh(((((((((data[:,6])+(((((((3.50821948051452637)) +(((( data[:,21])+(( 11.92932796478271484)))/2.0)))) +(( 1.0)))/2.0)))) +(data[:,10])) /2.0)) +(data[:,21])) /2.0)) +
0.250000*np.tanh(((data[:,14])+(np.tanh(( np.tanh(((-1.0*(((( data[:,22])-(data[:,13])))))))))))) +
0.250000*np.tanh(((((1.0)) +(((( data[:,7])+(data[:,7])) /2.0)))/2.0)) +
0.250000*np.tanh(((((((((data[:,21])/ 2.0)) / 2.0)) *(((((((np.tanh(((( np.tanh(( data[:,13])))/ 2.0)))) / 2.0)) +(((((((np.tanh(((((data[:,21])+(data[:,21])) /2.0)))) / 2.0)) -(data[:,12])))/ 2.0)))) / 2.0)))) -(data[:,12])))+
0.250000*np.tanh(((( data[:,7])+(np.tanh(((((data[:,12])+(((data[:,7])*(((( data[:,13])+(data[:,13])) /2.0)))))/2.0)))))/2.0)) +
0.250000*np.tanh(((((((data[:,13])/ 2.0)) / 2.0)) / 2.0)) +
0.250000*np.tanh(((((((((( np.tanh(( data[:,9])))+(data[:,13])) /2.0)) +(((((((( data[:,21])/ 2.0)) * 2.0)) +(((( 3.94983267784118652)) / 2.0)))/2.0)))/2.0)) +(((( np.tanh(((3.94983267784118652)))) +(data[:,9])) /2.0)))/2.0)) +
0.250000*np.tanh(((((((((((((((data[:,14])*(((((((((data[:,19])/ 2.0)) *(np.tanh(((( data[:,2])/ 2.0)))))) / 2.0)) / 2.0)))) / 2.0)) / 2.0)) / 2.0)) / 2.0)) / 2.0)) *(((((data[:,11])/ 2.0)) / 2.0)))))
 def GP_class_9(self,data):
return(0.250000*np.tanh(((((((data[:,14])* 2.0)) / 2.0)) +(((((data[:,14])+(np.tanh(((( data[:,14])* 2.0)))))) +(data[:,14])))))+
0.250000*np.tanh(((data[:,9])-(((((-1.0*(( data[:,11])))) +(data[:,9])) /2.0)))) +
0.250000*np.tanh(((data[:,21])* 2.0)) +
0.250000*np.tanh(((((( data[:,14])+(data[:,14])) /2.0)) +(((( data[:,13])+(((( np.tanh(((( data[:,9])+(( 6.0)))))) +(data[:,9])) /2.0)))/2.0)))) +
0.250000*np.tanh(np.tanh(((1.0)))) +
0.250000*np.tanh(((np.tanh(( np.tanh(((((np.tanh(((( data[:,20])*(((((((np.tanh(((( data[:,20])/ 2.0)))) +(data[:,12])) /2.0)) +(((( data[:,15])+(((( data[:,17])+(data[:,9])) /2.0)))/2.0)))/2.0)))))) +(data[:,9])) /2.0)))))) / 2.0)) +
0.250000*np.tanh(((((data[:,2])-(data[:,11])))/ 2.0)) +
0.250000*np.tanh(((((((( data[:,13])/ 2.0)) +(((data[:,7])+(data[:,7])))) /2.0)) -(((((data[:,22])+(((((data[:,14])*(((((data[:,7])*(((data[:,13])-(((( data[:,7])+(((((data[:,13])/ 2.0)) +(data[:,7])))) /2.0)))))) / 2.0)))) * 2.0)))) / 2.0)))) +
0.250000*np.tanh(((((((((((((((data[:,1])/ 2.0)) +(( 1.0)))/2.0)) +(( 1.0)))/2.0)) +(((((((((( 1.0)) / 2.0)) +(np.tanh(((1.0)))))/2.0)) +(np.tanh(((((( 1.0)) +(( 1.0)))/2.0)))))/2.0)))/2.0)) +(((( data[:,20])+(( 1.0)))/2.0)))/2.0)) +
0.250000*np.tanh(((data[:,1])*(((( data[:,14])+(np.tanh(((((0.0)) / 2.0)))))/2.0)))))
 def GP_class_10(self,data):
return(0.250000*np.tanh(((((((((( data[:,2])+(((data[:,9])*(np.tanh(( data[:,14])))))) /2.0)) +(((((( data[:,14])+(data[:,20])) /2.0)) +(data[:,0])))) /2.0)) +(data[:,14])) /2.0)) +
0.250000*np.tanh(((((( data[:,9])+(( -1.0*(((((((( 2.04309988021850586)) +(((data[:,11])+(((np.tanh(( data[:,0])))/ 2.0)))))/2.0)) * 2.0)))))) /2.0)) +(data[:,2])))+
0.250000*np.tanh(data[:,21])+
0.250000*np.tanh(((((((( data[:,14])+(np.tanh(((( data[:,6])/ 2.0)))))/2.0)) +(data[:,14])))+(((((data[:,14])* 2.0)) +(((( data[:,13])+(data[:,14])) /2.0)))))) +
0.250000*np.tanh(data[:,9])+
0.250000*np.tanh(((((((data[:,15])* 2.0)) / 2.0)) / 2.0)) +
0.250000*np.tanh(((((((( 2.72836518287658691)) *(((( 1.0)) / 2.0)))) / 2.0)) / 2.0)) +
0.250000*np.tanh(((((np.tanh(((( data[:,7])+(np.tanh(((((((((((0.0)) / 2.0)) / 2.0)) / 2.0)) / 2.0)))))))) / 2.0)) / 2.0)) +
0.250000*np.tanh(np.tanh(((( np.tanh(((11.43236827850341797)))) / 2.0)))) +
0.250000*np.tanh(np.tanh(((( data[:,7])/ 2.0)))))
 def GP_class_11(self,data):
return(0.250000*np.tanh(( -1.0*(((((((((((((( data[:,5])-(((data[:,9])-(((( -1.0*(((11.40053558349609375)))))/ 2.0)))))) +(((( 11.40053558349609375)) +(((( 11.40053558349609375)) * 2.0)))))) / 2.0)) -(data[:,7])))-(( -1.0*(((11.40053939819335938)))))))* 2.0)))))+
0.250000*np.tanh(((((data[:,14])* 2.0)) +(data[:,14])))+
0.250000*np.tanh(((data[:,2])+(((((data[:,5])+(data[:,3])))+(((( data[:,2])+(((data[:,3])* 2.0)))/2.0)))))) +
0.250000*np.tanh(((((((((((data[:,21])+(data[:,21])))+(( -1.0*(((((np.tanh(( np.tanh(((( data[:,14])/ 2.0)))))) +(data[:,21])) /2.0)))))) /2.0)) * 2.0)) +(((( data[:,14])+(data[:,3])) /2.0)))/2.0)) +
0.250000*np.tanh(((((((data[:,0])+(((( data[:,9])+(((( data[:,9])+(((((((((((((((data[:,9])/ 2.0)) -(data[:,10])))+(data[:,5])) /2.0)) -(data[:,9])))+(data[:,9])) /2.0)) / 2.0)))/2.0)))/2.0)))/2.0)) +(data[:,9])) /2.0)) +
0.250000*np.tanh(((((((( data[:,13])+(((( data[:,13])+(data[:,13])) /2.0)))) +(data[:,1])) /2.0)) / 2.0)) +
0.250000*np.tanh(data[:,14])+
0.250000*np.tanh(((((data[:,2])/ 2.0)) / 2.0)) +
0.250000*np.tanh(((( data[:,9])+(data[:,9])) /2.0)) +
0.250000*np.tanh(data[:,2]))
def GP_class_12(self,data):
return(0.250000*np.tanh(((((((( -1.0*(( data[:,18])))) -(np.tanh(( data[:,9])))))+(( 8.0)))) -(( 14.74865913391113281)))) +
0.250000*np.tanh(((((( data[:,21])+(np.tanh(( data[:,9])))))+(((((((( data[:,5])/ 2.0)) * 2.0)) +(data[:,5])) /2.0)))/2.0)) +
0.250000*np.tanh(((((data[:,14])+(data[:,14])))+(((data[:,14])* 2.0)))) +
0.250000*np.tanh(((data[:,2])+(((((((data[:,14])+(((( np.tanh(( data[:,10])))+(data[:,17])) /2.0)))/2.0)) +(data[:,21])) /2.0)))) +
0.250000*np.tanh(((( data[:,9])+(((((((((((( data[:,9])+(((((( data[:,9])/ 2.0)) +(((data[:,9])* 2.0)))/2.0)))/2.0)) +(( -1.0*(( data[:,21])))))/2.0)) *(data[:,9])))+(((((np.tanh(((( data[:,21])/ 2.0)))) / 2.0)) / 2.0)))/2.0)))/2.0)) +
0.250000*np.tanh(((((0.0)) +(data[:,13])) /2.0)) +
0.250000*np.tanh(((((((( data[:,2])/ 2.0)) * 2.0)) +(data[:,7])) /2.0)) +
0.250000*np.tanh(((((( data[:,14])* 2.0)) +(np.tanh(( data[:,14])))) /2.0)) +
0.250000*np.tanh(np.tanh(((((((((( -1.0*(((( np.tanh(( data[:,9])))/ 2.0)))))/ 2.0)) / 2.0)) +(((data[:,3])*(data[:,13])))) /2.0)))) +
0.250000*np.tanh(( -1.0*(((((((( -1.0*(((((((-1.0*(( data[:,18])))) -(((( 0.0)) / 2.0)))) / 2.0)))))+(np.tanh(((((-1.0*(((-1.0*(( data[:,22])))))))/ 2.0)))))/2.0)) / 2.0))))))
def GP_class_13(self,data):
return(0.250000*np.tanh(((((np.tanh(( np.tanh(( data[:,2])))))-(( 10.0)))) -(np.tanh(((((( data[:,7])-(((((( 6.0)) -(( 4.87243366241455078)))) -(( 9.0)))))) -(( 14.80352973937988281)))))))) +
0.250000*np.tanh(((np.tanh(((((( 3.0)) +(data[:,1])) /2.0)))) -(( 7.0)))) +
0.250000*np.tanh(((((np.tanh(( np.tanh(( np.tanh(( data[:,6])))))))* 2.0)) -(( 6.10337877273559570)))) +
0.250000*np.tanh(((((((data[:,9])+(data[:,14])))+(data[:,14])))+(data[:,14])))+
0.250000*np.tanh(((((((np.tanh(((((-1.0*(((((((data[:,2])+(( 10.0)))/2.0)) / 2.0)))))-(( 13.28130435943603516)))))) +(( 10.0)))) -(( 13.28130435943603516)))) +(( -1.0*(( data[:,5])))))) +
0.250000*np.tanh(((((((((((data[:,20])+(((((((((data[:,20])* 2.0)) * 2.0)) * 2.0)) +(data[:,13])))) /2.0)) +(((data[:,9])+(((data[:,9])+(((data[:,6])+(data[:,9])))))))) /2.0)) +(data[:,20])))+(data[:,15])))+
0.250000*np.tanh(((((((((data[:,14])/ 2.0)) +(((( data[:,9])+(((data[:,15])+(((data[:,5])+(((((( data[:,9])+(((data[:,5])+(data[:,14])))))+(data[:,9])) /2.0)))))))/2.0)))) * 2.0)) +(data[:,14])))+
0.250000*np.tanh(((( data[:,13])+(data[:,7])) /2.0)) +
0.250000*np.tanh(((data[:,9])+(((( data[:,3])+(((( data[:,21])+(data[:,3])) /2.0)))/2.0)))) +
0.250000*np.tanh(((( data[:,2])+(((((((((((((((data[:,20])+(data[:,1])))+(((data[:,2])+(data[:,14])))))+(data[:,2])))+(np.tanh(( data[:,2])))) /2.0)) +(((data[:,14])+(data[:,2])))))+(data[:,14])) /2.0)))/2.0)))
 def GP_class_14(self,data):
return(0.250000*np.tanh(((((((((((( 5.54024744033813477)) -(((((( 9.0)) * 2.0)) * 2.0)))) -(data[:,0])))-(((( 7.0)) +(( 4.74105215072631836)))))) -(((((7.0)) +(((data[:,5])* 2.0)))/2.0)))) -(( 9.0)))) +
0.250000*np.tanh(((((((((9.0)) -(( 14.27298927307128906)))) -(data[:,0])))+(np.tanh(((((12.77708148956298828)) -(( 14.80560111999511719)))))))/2.0)) +
0.250000*np.tanh(((((((0.0)) +(( -1.0*(((( data[:,22])+(((((((((13.30077362060546875)) -(np.tanh(( data[:,4])))))+(((data[:,22])/ 2.0)))/2.0)) / 2.0)))))))) /2.0)) -(((np.tanh(((( data[:,7])-(data[:,7])))))/ 2.0)))) +
0.250000*np.tanh(((((((data[:,6])+(data[:,14])) /2.0)) +(((np.tanh(((((( data[:,14])+(data[:,14])))+(((data[:,6])-(((data[:,5])+(((np.tanh(( data[:,21])))+(((( data[:,14])+(((( data[:,14])+(data[:,14])) /2.0)))/2.0)))))))))))) +(data[:,5])))) /2.0)) +
0.250000*np.tanh(((((((((((((((((( data[:,2])+(data[:,16])))+(((((( data[:,2])/ 2.0)) +(data[:,9])) /2.0)))/2.0)) +(np.tanh(( data[:,10])))) /2.0)) +(data[:,9])))+(data[:,9])) /2.0)) +(data[:,21])))+(data[:,3])))+
0.250000*np.tanh(((( data[:,13])+(((((((((((data[:,3])/ 2.0)) / 2.0)) / 2.0)) *(data[:,3])))/ 2.0)))/2.0)) +
0.250000*np.tanh(((data[:,14])+(((((((data[:,14])/ 2.0)) +(data[:,14])))* 2.0)))) +
0.250000*np.tanh(data[:,9])+
0.250000*np.tanh(((data[:,1])/ 2.0)) +
0.250000*np.tanh(((((( data[:,2])+(((((( data[:,13])+(data[:,14])))+(data[:,13])) /2.0)))) +(np.tanh(( data[:,2])))) /2.0)))
 def GP_class_15(self,data):
return(0.250000*np.tanh(((((((( 4.0)) +(((( 8.0)) / 2.0)))) -(( 9.56193733215332031)))) -(((((np.tanh(((13.93556308746337891)))) -(data[:,18])))+(( 13.93556308746337891)))))) +
0.250000*np.tanh(((data[:,4])-(((( 12.76094818115234375)) -(data[:,8])))))+
0.250000*np.tanh(((( -1.0*(((12.35446166992187500)))))-(((((12.35446166992187500)) +(((((( 12.35446166992187500)) -(( -1.0*(((0.0)))))))-(data[:,0])))) /2.0)))) +
0.250000*np.tanh(((data[:,21])-(( 14.46367263793945312)))) +
0.250000*np.tanh(((((data[:,2])+(((( data[:,9])+(( -1.0*(((-1.0*(((-1.0*(((( data[:,7])*(((data[:,21])* 2.0)))))))))))))) /2.0)))) +(data[:,9])))+
0.250000*np.tanh(((((((((((data[:,7])+(data[:,3])) /2.0)) +(data[:,20])) /2.0)) -(((( 2.33354020118713379)) / 2.0)))) -(((( 2.0)) +(( 8.78930377960205078)))))) +
0.250000*np.tanh(((((((data[:,14])+(((((((data[:,14])+(((data[:,15])+(data[:,14])))))+(((data[:,15])+(data[:,14])))))+(((data[:,14])/ 2.0)))))) +(data[:,14])))+(data[:,14])))+
0.250000*np.tanh(((((((((data[:,13])+(data[:,13])))+(((data[:,13])+(data[:,12])))))+(data[:,9])))+(((((( data[:,9])+(((data[:,13])+(((( data[:,9])+(((((data[:,13])* 2.0)) / 2.0)))/2.0)))))/2.0)) * 2.0)))) +
0.250000*np.tanh(((( data[:,9])+(((((( data[:,9])+(data[:,9])) /2.0)) / 2.0)))/2.0)) +
0.250000*np.tanh(((((( data[:,14])+(data[:,8])))+(data[:,14])) /2.0)))
 def GP_class_16(self,data):
return(0.250000*np.tanh(((((((((((((9.37592792510986328)) -(( 13.36316204071044922)))) +(( 11.89122962951660156)))/2.0)) -(((( 9.0)) -(((((((data[:,13])/ 2.0)) / 2.0)) +(((( -1.0*(((( data[:,4])/ 2.0)))))* 2.0)))))))) -(( 12.24639320373535156)))) -(( 11.89122581481933594)))) +
0.250000*np.tanh(((((np.tanh(((4.51821422576904297)))) -(( 13.23712635040283203)))) -(((((( 13.23712635040283203)) +(((data[:,22])-(((( 11.40539550781250000)) -(((((9.0)) +(((((((( data[:,7])+(((data[:,17])/ 2.0)))/2.0)) * 2.0)) / 2.0)))/2.0)))))))) -(data[:,5])))))+
0.250000*np.tanh(((data[:,14])-(((( 4.0)) +(((((13.41770648956298828)) +(( 12.42538261413574219)))/2.0)))))) +
0.250000*np.tanh(((( 5.0)) -(( 9.27778816223144531)))) +
0.250000*np.tanh(((((data[:,16])-(((((((data[:,1])-(((np.tanh(((((((( 9.29507255554199219)) -(((((((14.34461498260498047)) * 2.0)) +(((((7.0)) +(( 9.10683441162109375)))/2.0)))/2.0)))) +(( 4.21145153045654297)))/2.0)))) * 2.0)))) -(( 9.10683441162109375)))) * 2.0)))) -(((( 14.34461498260498047)) * 2.0)))) +
0.250000*np.tanh(((((((((( data[:,17])/ 2.0)) +(((data[:,13])+(data[:,9])))) /2.0)) +(((data[:,17])+(data[:,9])))))+(data[:,0])))+
0.250000*np.tanh(((data[:,13])+(((data[:,14])-(data[:,21])))))+
0.250000*np.tanh(((((( data[:,14])+(data[:,5])) /2.0)) +(((((((data[:,9])/ 2.0)) +(data[:,14])))/ 2.0)))) +
0.250000*np.tanh(((((( data[:,17])+(data[:,9])))+(((((data[:,17])/ 2.0)) +(((((((((( data[:,9])+(data[:,9])))-(( 3.0)))) +(data[:,7])))+(data[:,9])) /2.0)))))/2.0)) +
0.250000*np.tanh(np.tanh(((((((((((((((data[:,2])+(((((((((((data[:,22])+(data[:,21])) /2.0)) +(data[:,2])) /2.0)) * 2.0)) +(((((( data[:,21])* 2.0)) +(data[:,21])) /2.0)))))) +(data[:,2])) /2.0)) +(data[:,17])) /2.0)) +(np.tanh(( data[:,8])))) /2.0)) +(data[:,2]))))))
def GP_class_17(self,data):
return(0.250000*np.tanh(((((data[:,14])-(((( data[:,5])+(((((14.43326377868652344)) +(( 6.0)))/2.0)))/2.0)))) -(((((((10.0)) +(( 14.84462165832519531)))/2.0)) -(((( 7.0)) +(data[:,13])))))))+
0.250000*np.tanh(((((((((( data[:,14])+(((((((((data[:,11])-(( 9.71331787109375000)))) / 2.0)) +(( 9.0)))) -(( 3.0)))))/2.0)) -(( 10.0)))) -(((( 10.0)) +(((( 9.0)) -(((((( 10.0)) -(( 9.0)))) / 2.0)))))))) -(( 10.0)))) +
0.250000*np.tanh(((((((((( 8.0)) -(( 12.78277492523193359)))) -(data[:,10])))-(np.tanh(((((((7.0)) -(( 14.95321178436279297)))) -(( 8.0)))))))) -(( 14.95321178436279297)))) +
0.250000*np.tanh(((( 7.45682907104492188)) -(( 14.98023796081542969)))) +
0.250000*np.tanh(((((((((((7.0)) +(((((np.tanh(((((((( 8.0)) *(data[:,8])))+(data[:,11])) /2.0)))) / 2.0)) -(( 8.0)))))/2.0)) -(data[:,20])))-(((( 8.0)) * 2.0)))) +(( 8.0)))) +
0.250000*np.tanh(((data[:,8])+(((data[:,4])+(((np.tanh(( data[:,4])))+(((data[:,13])+(data[:,13])))))))))+
0.250000*np.tanh(data[:,14])+
0.250000*np.tanh(((((((((((data[:,14])+(np.tanh(((( data[:,3])*(data[:,13])))))))+(data[:,14])))+(data[:,0])))+(data[:,8])))/ 2.0)) +
0.250000*np.tanh(((((( data[:,9])+(np.tanh(((((((data[:,19])*(((((((data[:,1])+(((((((data[:,21])+(data[:,9])) /2.0)) +(data[:,6])) /2.0)))/2.0)) +(data[:,17])) /2.0)))) +(((data[:,15])/ 2.0)))/2.0)))))/2.0)) * 2.0)) +
0.250000*np.tanh(((data[:,1])+(((((data[:,3])+(data[:,15])))+(np.tanh(((((data[:,20])+(((data[:,1])* 2.0)))/2.0)))))))))
 def GP_class_18(self,data):
return(0.250000*np.tanh(((((((((( 12.59485149383544922)) -(( 12.59485149383544922)))) -(( 12.59485149383544922)))) -(((( 11.47756862640380859)) / 2.0)))) -(( 12.59485149383544922)))) +
0.250000*np.tanh(((((( -1.0*(((11.26121807098388672)))))-(((((((((11.33140659332275391)) -(( -1.0*(((9.76293182373046875)))))))-(((((11.33140659332275391)) +(( 8.0)))/2.0)))) +(( 9.76293182373046875)))/2.0)))) -(data[:,11])))+
0.250000*np.tanh(((((((((((3.40250444412231445)) -(np.tanh(((14.86789989471435547)))))) -(( 14.86789989471435547)))) +(((((( data[:,5])+(( -1.0*(((((14.86789989471435547)) * 2.0)))))) /2.0)) -(( 14.86789989471435547)))))/2.0)) -(((((14.86789989471435547)) +(((((7.0)) +(( -1.0*(( data[:,16])))))/2.0)))/2.0)))) +
0.250000*np.tanh(((data[:,18])-(( 11.84332561492919922)))) +
0.250000*np.tanh(((((np.tanh(((((8.96548557281494141)) *(data[:,12])))))-(( -1.0*(((( data[:,2])*(((((data[:,4])-(( -1.0*(( data[:,9])))))) -(( 9.0)))))))))))-(( 8.96548557281494141)))) +
0.250000*np.tanh(((((((10.0)) -(data[:,12])))+(((((((((data[:,13])-(( 12.43707370758056641)))) -(((( 12.43707370758056641)) -(((data[:,12])/ 2.0)))))) -(((( 12.43707370758056641)) -(((( data[:,13])+(( 12.43707370758056641)))/2.0)))))) -(( 12.43707370758056641)))))/2.0)) +
0.250000*np.tanh(((((((np.tanh(((( np.tanh(( data[:,14])))+(data[:,13])))))* 2.0)) +(data[:,14])))+(data[:,13])))+
0.250000*np.tanh(((np.tanh(( data[:,14])))+(data[:,14])))+
0.250000*np.tanh(((((data[:,9])+(((((data[:,13])+(data[:,4])))+(data[:,13])))))/ 2.0)) +
0.250000*np.tanh(((data[:,15])-(((( data[:,3])+(( 5.0)))/2.0)))))
 def GP_class_19(self,data):
return(0.250000*np.tanh(((((( data[:,13])+(data[:,13])) /2.0)) +(((((( data[:,8])+(((( data[:,14])+(data[:,14])) /2.0)))/2.0)) * 2.0)))) +
0.250000*np.tanh(((( data[:,3])+(((data[:,8])+(np.tanh(((((((-1.0*(((((( 9.05535793304443359)) +(((( data[:,14])+(((((((data[:,1])-(((data[:,12])* 2.0)))) *(( -1.0*(( data[:,17])))))) / 2.0)))/2.0)))/2.0)))))+(data[:,2])))* 2.0)))))))/2.0)) +
0.250000*np.tanh(((((((((data[:,3])+(((((data[:,14])+(data[:,14])))* 2.0)))) +(((( data[:,14])+(np.tanh(((( data[:,14])+(np.tanh(( data[:,14])))))))) /2.0)))) * 2.0)) +(((( data[:,14])+(data[:,2])) /2.0)))) +
0.250000*np.tanh(((((data[:,8])+(((data[:,4])+(((data[:,13])+(data[:,10])))))))+(((((data[:,13])+(((((data[:,13])/ 2.0)) +(data[:,9])))))+(np.tanh(((((data[:,8])+(data[:,8])) /2.0)))))))) +
0.250000*np.tanh(((((( data[:,19])+(((((data[:,10])+(((( data[:,11])+(data[:,19])) /2.0)))) +(data[:,10])))) /2.0)) +(data[:,2])))+
0.250000*np.tanh(((((( data[:,0])+(((((((((data[:,0])+(((((data[:,0])-(data[:,11])))/ 2.0)))/2.0)) * 2.0)) +(((((( np.tanh(( data[:,13])))+(((data[:,0])/ 2.0)))/2.0)) / 2.0)))/2.0)))/2.0)) * 2.0)) +
0.250000*np.tanh(((((-1.0*(( data[:,15])))) +(((data[:,14])+(data[:,14])))) /2.0)) +
0.250000*np.tanh(((((((((data[:,0])+(data[:,15])) /2.0)) +(((data[:,15])*(data[:,15])))) /2.0)) -(data[:,11])))+
0.250000*np.tanh(data[:,13])+
0.250000*np.tanh(((((((((data[:,18])+(((( data[:,4])+(data[:,18])) /2.0)))) / 2.0)) +(((( data[:,18])+(data[:,4])) /2.0)))) *(data[:,4]))))<predict_on_test>
df=data.copy()
warnings.filterwarnings("ignore")
 env = nflrush.make_env()
iter_test = env.iter_test()
gp = GP()
for(test_df, sample_prediction_df)in iter_test:
basetable = create_features(test_df, deploy=True)
 basetable.drop(['GameId','PlayId'], axis=1, inplace=True)
 scaled_basetable = scaler.transform(basetable)
 y_pred_nn = model.predict(scaled_basetable)
 y_pred_gp = np.zeros(( test_df.shape[0],199))
ans = gp.GrabPredictions(scaled_basetable)
 y_pred_gp[:,96:96+20] = ans
y_pred = (.6*y_pred_nn+.4*y_pred_gp)
 y_pred = np.clip(np.cumsum(y_pred, axis=1), 0, 1 ).tolist() [0]
preds_df = pd.DataFrame(data=[y_pred], columns=sample_prediction_df.columns)
 env.predict(preds_df)
 env.write_submission_file()<set_options>
cols = ['MSZoning', 'Street', 'LotShape',
'LandContour', 'Utilities', 'LotConfig', 'LandSlope',
'Neighborhood', 'Condition1', 'Condition2', 'BldgType', 'HouseStyle',
'RoofStyle', 'RoofMatl', 'Exterior1st', 'Exterior2nd', 'MasVnrType', 'ExterQual',
'ExterCond', 'Foundation', 'BsmtQual', 'BsmtCond', 'BsmtExposure', 'BsmtFinType1',
'BsmtFinType2', 'Heating', 'HeatingQC', 'CentralAir', 'Electrical', 'KitchenQual',
'Functional', 'FireplaceQu', 'GarageType', 'GarageFinish', 'GarageQual',
'GarageCond', 'PavedDrive', 'SaleType', 'SaleCondition']
tqdm.pandas(tqdm_notebook)
 warnings.filterwarnings("ignore")
 pd.set_option('display.max_columns', None)
 pd.set_option('display.max_rows', None)
 IS_LOCAL = False
if(IS_LOCAL):
PATH=".. /input/santander-value-prediction-challenge/"
else:
PATH=".. /input/"
print(os.listdir(PATH))<load_from_csv>
for c in cols:
lbl = LabelEncoder()
lbl.fit(list(df[c].values))
df[c] = lbl.transform(list(df[c].values))
print('Shape all_data: {}'.format(df.shape))
train = pd.read_csv(PATH+"train.csv")
 test = pd.read_csv(PATH+"test.csv" )<define_variables>
df['TotalSF'] = df['TotalBsmtSF'] +df['1stFlrSF'] + df['2ndFlrSF']
NLAGS = 29<prepare_x_and_y>
from scipy import stats
from scipy.stats import norm, skew
all_cols = [f for f in train.columns if f not in ["ID", "target"]]
y = np.log1p(train["target"] ).values
cols = ['f190486d6', '58e2e02e6', 'eeb9cd3aa', '9fd594eec', '6eef030c1',
'15ace8c9f', 'fb0f5dbfe', '58e056e12', '20aa07010', '024c577b9',
'd6bb78916', 'b43a7cfd5', '58232a6fb', '1702b5bf0', '324921c7b',
'62e59a501', '2ec5b290f', '241f0f867', 'fb49e4212', '66ace2992',
'f74e8f13d', '5c6487af1', '963a49cdc', '26fc93eb7', '1931ccfdd',
'703885424', '70feb1494', '491b9ee45', '23310aa6f', 'e176a204a',
'6619d81fc', '1db387535', 'fc99f9426', '91f701ba2', '0572565c2',
'190db8488', 'adb64ff71', 'c47340d97', 'c5a231d81', '0ff32eb98']<categorify>
df = df.iloc[:, ~df.columns.duplicated() ]
def _get_leak(df, cols, lag=0):

 series_str = df[cols[lag+2:]].apply(lambda x: "_".join(x.round(2 ).astype(str)) , axis=1)
 series_shifted_str = df[cols].shift(lag+2, axis=1)[cols[lag+2:]].apply(lambda x: "_".join(x.round(2 ).astype(str)) , axis=1)
 target_rows = series_shifted_str.progress_apply(lambda x: np.where(x == series_str)[0])
 target_vals = target_rows.apply(lambda x: df.loc[x[0], cols[lag]] if len(x)==1 else 0)
 return target_vals
def get_all_leak(df, cols=None, nlags=15):

 df = df.copy()
for i in range(nlags):
print("Processing lag {}".format(i))
df["leaked_target_"+str(i)] = _get_leak(df, cols, i)
 return df<feature_engineering>
y_train = train.SalePrice.values
test["target"] = train["target"].mean()<concatenate>
from scipy import stats
from scipy.stats import norm, skew
all_df = pd.concat([train[["ID", "target"] + cols], test[["ID", "target"]+ cols]] ).reset_index(drop=True)
 all_df.head()<categorify>
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:
df[feat] = boxcox1p(df[feat], lam )
all_df = get_all_leak(all_df, cols=cols, nlags=NLAGS )<merge>
df = pd.get_dummies(df)
 print(df.shape )
leaky_cols = ["leaked_target_"+str(i)for i in range(NLAGS)]
train = train.join(all_df.set_index("ID")[leaky_cols], on="ID", how="left")
 test = test.join(all_df.set_index("ID")[leaky_cols], on="ID", how="left")
 train[["target"]+leaky_cols].head(10 )<feature_engineering>
import pandas_profiling
train["nz_mean"] = train[all_cols].apply(lambda x: np.expm1(np.log1p(x[x!=0] ).mean()), axis=1)
 test["nz_mean"] = test[all_cols].apply(lambda x: np.expm1(np.log1p(x[x!=0] ).mean()), axis=1 )<feature_engineering>
df.apply(lambda x: sum(x.isnull()),axis=0 )
train["compiled_leak"] = 0
test["compiled_leak"] = 0
for i in range(NLAGS):
train.loc[train["compiled_leak"] == 0, "compiled_leak"] = train.loc[train["compiled_leak"] == 0, "leaked_target_"+str(i)]
test.loc[test["compiled_leak"] == 0, "compiled_leak"] = test.loc[test["compiled_leak"] == 0, "leaked_target_"+str(i)]
print("Leak values found in train and test ", sum(train["compiled_leak"] > 0), sum(test["compiled_leak"] > 0))
print("% of correct leaks values in train ", sum(train["compiled_leak"] == train["target"])/sum(train["compiled_leak"] > 0))<feature_engineering>
import plotly.express as px
train.loc[train["compiled_leak"] == 0, "compiled_leak"] = train.loc[train["compiled_leak"] == 0, "nz_mean"]
test.loc[test["compiled_leak"] == 0, "compiled_leak"] = test.loc[test["compiled_leak"] == 0, "nz_mean"]
np.sqrt(mean_squared_error(y, np.log1p(train["compiled_leak"] ).fillna(14.49)))
<prepare_output>
warnings.filterwarnings("ignore", category=DeprecationWarning )
sub1 = test[["ID"]]
sub1["target"] = test["compiled_leak"]<define_variables>
train = df[:ntrain]
test = df[ntrain:]
NUMBER_KFOLDS = 5
NFOLDS = 5
MAX_ROUNDS = 3000
EARLY_STOP = 100
VERBOSE_EVAL = 200<load_from_csv>
from sklearn.base import BaseEstimator, TransformerMixin, RegressorMixin, clone
train = pd.read_csv(PATH+"train.csv")
 test = pd.read_csv(PATH+"test.csv")
 all_cols = [c for c in train.columns if c not in ['ID', 'target']]
leak_col = []
for c in all_cols:
leak1 = np.sum(( train[c]==train['target'] ).astype(int))
leak2 = np.sum(((( train[c] - train['target'])/ train['target'])< 0.05 ).astype(int))
if leak1 > 30 and leak2 > 3500:
leak_col.append(c )<define_variables>
from sklearn.linear_model import Ridge
from sklearn.linear_model import Lasso
from sklearn.ensemble import RandomForestRegressor, GradientBoostingRegressor, ExtraTreesRegressor
from sklearn.svm import SVR, LinearSVR
from sklearn.linear_model import ElasticNet, SGDRegressor, BayesianRidge
from sklearn.kernel_ridge import KernelRidge
from xgboost import XGBRegressor
import xgboost as xgb
import lightgbm as lgb
from sklearn.metrics import mean_squared_error
col = list(leak_col)
 train_lk = train[col + ['ID', 'target']]
test_lk = test[col + ['ID']]<feature_engineering>
n_folds = 10
def rmsle_cv(model):
kf = KFold(n_folds, shuffle=True, random_state=2020 ).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 )
for df in [train_lk, test_lk]:
df["nz_mean"] = df[col].apply(lambda x: x[x!=0].mean() , axis=1)
 df["nz_max"] = df[col].apply(lambda x: x[x!=0].max() , axis=1)
 df["nz_min"] = df[col].apply(lambda x: x[x!=0].min() , axis=1)
 df["ez"] = df[col].apply(lambda x: len(x[x==0]), axis=1)
 df["mean"] = df[col].apply(lambda x: x.mean() , axis=1)
 df["max"] = df[col].apply(lambda x: x.max() , axis=1)
 df["min"] = df[col].apply(lambda x: x.min() , axis=1)
 df["kurtosis"] = df[col].apply(lambda x: x.kurtosis() , axis=1)
 col += ['nz_mean', 'nz_max', 'nz_min', 'ez', 'mean', 'max', 'min', 'kurtosis']<data_type_conversions>
lasso = make_pipeline(RobustScaler() , Lasso(alpha =0.0005, random_state=42))
for i in range(2, 100):
train_lk['index'+str(i)] =(( train_lk.index + 2)% i == 0 ).astype(int)
 test_lk['index'+str(i)] =(( test_lk.index + 2)% i == 0 ).astype(int)
 col.append('index'+str(i))<merge>
model_xgb = xgb.XGBRegressor(colsample_bytree=0.4603, gamma=0.0468,
learning_rate=0.05, max_depth=9,
min_child_weight=1.7817, n_estimators=2000,
reg_alpha=0.4640, reg_lambda=0.8571,
subsample=0.5213, silent=1,
random_state =7, nthread = -1 )
test_lk = pd.merge(test_lk, sub1, how='left', on='ID', )<concatenate>
score = rmsle_cv(model_xgb)
 print("Xgboost score: {:.4f}({:.4f})
 ".format(score.mean() , score.std()))
train_lk = train_lk.replace(0, np.nan)
 test_lk = test_lk.replace(0, np.nan)
 train_lk = pd.concat(( train_lk, test_lk), axis=0, ignore_index=True )<split>
model_lgb = lgb.LGBMRegressor(objective='regression',num_leaves=5,
learning_rate=0.03, n_estimators=1500,
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 )
test_lk['target'] = 0.0
folds = NFOLDS
for fold in range(folds):
x1, x2, y1, y2 = model_selection.train_test_split(train_lk[col],
np.log1p(train_lk.target.values),
test_size=0.20,
random_state=fold)
 params = {'learning_rate': 0.02,
'max_depth': 7,
'boosting': 'gbdt',
'objective': 'regression',
'metric': 'rmse',
'is_training_metric': True,
'feature_fraction': 0.9,
'bagging_fraction': 0.8,
'bagging_freq': 5,
'seed':fold}
model = lgb.train(params,
lgb.Dataset(x1, label=y1),
MAX_ROUNDS,
lgb.Dataset(x2, label=y2),
verbose_eval=VERBOSE_EVAL,
early_stopping_rounds=EARLY_STOP)
 test_lk['target'] += np.expm1(model.predict(test_lk[col],
num_iteration=model.best_iteration))
test_lk['target'] /= folds
sub1 = test_lk[['ID', 'target']]<save_to_csv>
score = rmsle_cv(model_lgb)
 print("LGBM score: {:.4f}({:.4f})
 ".format(score.mean() , score.std()))
test_lk[['ID', 'target']].to_csv('submission.csv', index=False )<set_options>
Rd=Ridge()
%matplotlib inline
warnings.filterwarnings('ignore' )<load_from_csv>
score = rmsle_cv(Rd)
 print("Rd score: {:.4f}({:.4f})
 ".format(score.mean() , score.std()))
train_df = pd.read_csv('.. /input/train.csv')
 test_df = pd.read_csv('.. /input/test.csv' )<count_missing_values>
Rf= RandomForestRegressor()
print("Total Train Features with NaN Values = " + str(train_df.columns[train_df.isnull().sum() != 0].size))
if(train_df.columns[train_df.isnull().sum() != 0].size):
print("Features with NaN => {}".format(list(train_df.columns[train_df.isnull().sum() != 0])))
 train_df[train_df.columns[train_df.isnull().sum() != 0]].isnull().sum().sort_values(ascending = False )<count_missing_values>
score = rmsle_cv(Rf)
 print("Rf score: {:.4f}({:.4f})
 ".format(score.mean() , score.std()))
print("Total Test Features with NaN Values = " + str(test_df.columns[test_df.isnull().sum() != 0].size))
if(test_df.columns[test_df.isnull().sum() != 0].size):
print("Features with NaN => {}".format(list(test_df.columns[test_df.isnull().sum() != 0])))
 test_df[test_df.columns[test_df.isnull().sum() != 0]].isnull().sum().sort_values(ascending = False )<drop_column>
GBR= GradientBoostingRegressor()
colsToRemove = []
for col in train_df.columns:
if col != 'ID' and col != 'target':
if train_df[col].std() == 0:
colsToRemove.append(col)
 train_df.drop(colsToRemove, axis=1, inplace=True)
 test_df.drop(colsToRemove, axis=1, inplace=True)
 print("Removed `{}` Constant Columns
".format(len(colsToRemove)))
 print(colsToRemove )<count_unique_values>
score = rmsle_cv(GBR)
 print("GBR score: {:.4f}({:.4f})
 ".format(score.mean() , score.std()))
%%time
def duplicate_columns(frame):
groups = frame.columns.to_series().groupby(frame.dtypes ).groups
dups = []
for t, v in groups.items() :
cs = frame[v].columns
vs = frame[v]
lcs = len(cs)
 for i in range(lcs):
ia = vs.iloc[:,i].values
for j in range(i+1, lcs):
ja = vs.iloc[:,j].values
if np.array_equal(ia, ja):
dups.append(cs[i])
 break
return dups
colsToRemove = duplicate_columns(train_df)
 print(colsToRemove )<drop_column>
Ext= ExtraTreesRegressor()
train_df.drop(colsToRemove, axis=1, inplace=True)
 test_df.drop(colsToRemove, axis=1, inplace=True)
 print("Removed `{}` Duplicate Columns
".format(len(colsToRemove)))
 print(colsToRemove )<drop_column>
score = rmsle_cv(Ext)
 print("Ext score: {:.4f}({:.4f})
 ".format(score.mean() , score.std()))
def drop_sparse(train, test):
flist = [x for x in train.columns if not x in ['ID','target']]
for f in flist:
if len(np.unique(train[f])) <2:
train.drop(f, axis=1, inplace=True)
 test.drop(f, axis=1, inplace=True)
 return train, test<drop_column>
Svmr=LinearSVR()
%%time
train_df, test_df = drop_sparse(train_df, test_df )<feature_engineering>
score = rmsle_cv(Svmr)
 print("Svmr score: {:.4f}({:.4f})
 ".format(score.mean() , score.std()))
X_train = train_df.drop(["ID", "target"], axis=1)
 print("rounding...")
 for i in X_train.columns:
X_train[i] = np.round(np.log1p(X_train[i]), decimals=3)
 gc.collect()
y_train = np.log1p(train_df["target"].values)
 X_test = test_df.drop(["ID"], axis=1)
 print("rounding...")
 for i in X_test.columns:
X_test[i] = np.round(np.log1p(X_test[i]), decimals=3 )<split>
BR=BayesianRidge()
dev_X, val_X, dev_y, val_y = train_test_split(X_train, y_train, test_size = 0.2, random_state = 42 )<create_dataframe>
score = rmsle_cv(BR)
 print("BR score: {:.4f}({:.4f})
 ".format(score.mean() , score.std()))
def run_lgb(train_X, train_y, val_X, val_y, test_X):
params = {
"objective" : "regression",
"metric" : "rmse",
"num_leaves" : 40,
"learning_rate" : 0.005,
"bagging_fraction" : 0.6,
"feature_fraction" : 0.6,
"bagging_frequency" : 6,
"bagging_seed" : 42,
"verbosity" : -1,
"seed": 42
}
lgtrain = lgb.Dataset(train_X, label=train_y)
 lgval = lgb.Dataset(val_X, label=val_y)
 evals_result = {}
model = lgb.train(params, lgtrain, 5000,
valid_sets=[lgtrain, lgval],
early_stopping_rounds=100,
verbose_eval=150,
evals_result=evals_result)
 pred_test_y = np.expm1(model.predict(test_X, num_iteration=model.best_iteration))
return pred_test_y, model, evals_result<train_model>
score = rmsle_cv(lasso)
 print("lasso score: {:.4f}({:.4f})
 ".format(score.mean() , score.std()))
pred_test, model, evals_result = run_lgb(dev_X, dev_y, val_X, val_y, X_test)
 print("LightGBM Training Completed..." )<load_from_csv>
class StackingAveragedModels(BaseEstimator, RegressorMixin, TransformerMixin):
def __init__(self, base_models, meta_model, n_folds=5):
self.base_models = base_models
self.meta_model = meta_model
self.n_folds = n_folds
def fit(self, X, y):
self.base_models_ = [list() for x in self.base_models]
self.meta_model_ = clone(self.meta_model)
 kfold = KFold(n_splits=self.n_folds, shuffle=True, random_state=2020)
 out_of_fold_predictions = np.zeros(( X.shape[0], len(self.base_models)))
 for i, model in enumerate(self.base_models):
for train_index, holdout_index in kfold.split(X, y):
instance = clone(model)
 self.base_models_[i].append(instance)
 instance.fit(X[train_index], y[train_index])
 y_pred = instance.predict(X[holdout_index])
 out_of_fold_predictions[holdout_index, i] = y_pred
self.meta_model_.fit(out_of_fold_predictions, y)
 return self
def predict(self, X):
meta_features = np.column_stack([
np.column_stack([model.predict(X)for model in base_models] ).mean(axis=1)
 for base_models in self.base_models_ ])
 return self.meta_model_.predict(meta_features )
sub = pd.read_csv('.. /input/sample_submission.csv')
 sub_lgb = pd.DataFrame()
sub_lgb["target"] = pred_test
sub["target"] =(sub_lgb["target"] )<save_to_csv>
stacked_averaged_models = StackingAveragedModels(base_models =(model_lgb,model_xgb),
meta_model = model_xgb )
print(sub.head())
 sub.to_csv('sub_lgb.csv', index=False )<load_from_csv>
score = rmsle_cv(stacked_averaged_models)
 print("Stacking Averaged models score: {:.4f}({:.4f})".format(score.mean() , score.std()))
train = pd.read_csv(".. /input/train.csv")
 test = pd.read_csv(".. /input/test.csv")
 transact_cols = [f for f in train.columns if f not in ["ID", "target"]]
y = np.log1p(train["target"] ).values<define_variables>
def rmsle(y, y_pred):
return np.sqrt(mean_squared_error(y, y_pred))
cols = ['f190486d6', '58e2e02e6', 'eeb9cd3aa', '9fd594eec', '6eef030c1',
'15ace8c9f', 'fb0f5dbfe', '58e056e12', '20aa07010', '024c577b9',
'd6bb78916', 'b43a7cfd5', '58232a6fb', '1702b5bf0', '324921c7b',
'62e59a501', '2ec5b290f', '241f0f867', 'fb49e4212', '66ace2992',
'f74e8f13d', '5c6487af1', '963a49cdc', '26fc93eb7', '1931ccfdd',
'703885424', '70feb1494', '491b9ee45', '23310aa6f', 'e176a204a',
'6619d81fc', '1db387535', 'fc99f9426', '91f701ba2', '0572565c2',
'190db8488', 'adb64ff71', 'c47340d97', 'c5a231d81', '0ff32eb98'] 
<categorify>
stacked_averaged_models.fit(train.values, y_train)
 stacked_train_pred = stacked_averaged_models.predict(train.values)
 stacked_pred = np.expm1(stacked_averaged_models.predict(test.values))
print(rmsle(y_train, stacked_train_pred))
CPU_CORES = 1
def _get_leak(df, cols, lag=0):

 series_str = df[cols[lag+2:]].apply(lambda x: "_".join(x.round(2 ).astype(str)) , axis=1)
 series_shifted_str = df[cols].shift(lag+2, axis=1)[cols[lag+2:]].apply(lambda x: "_".join(x.round(2 ).astype(str)) , axis=1)
 target_rows = series_shifted_str.progress_apply(lambda x: np.where(x == series_str)[0])
 target_vals = target_rows.apply(lambda x: df.loc[x[0], cols[lag]] if len(x)==1 else 0)
 return target_vals
def get_all_leak(df, cols=None, nlags=15):

 df = df.copy()
for i in range(nlags):
print("Processing lag {}".format(i))
df["leaked_target_"+str(i)] = _get_leak(df, cols, i)
 return df 
<feature_engineering>
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))
test["target"] = train["target"].mean()
all_df = pd.concat([train[["ID", "target"] + cols], test[["ID", "target"]+ cols]] ).reset_index(drop=True)
 all_df.head()<categorify>
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))
NLAGS = 25
all_df = get_all_leak(all_df, cols=cols, nlags=NLAGS )<merge>

 print('RMSLE score on train data:')
 print(rmsle(y_train,stacked_train_pred*0.10 +
xgb_train_pred*0.10 + lgb_train_pred*0.80))
leaky_cols = ["leaked_target_"+str(i)for i in range(NLAGS)]
train = train.join(all_df.set_index("ID")[leaky_cols], on="ID", how="left")
 test = test.join(all_df.set_index("ID")[leaky_cols], on="ID", how="left" )<feature_engineering>
ensemble = stacked_pred*0.1 + xgb_pred*0.1 + lgb_pred*0.8
train["nonzero_mean"] = train[transact_cols].apply(lambda x: np.expm1(np.log1p(x[x!=0] ).mean()), axis=1)
 test["nonzero_mean"] = test[transact_cols].apply(lambda x: np.expm1(np.log1p(x[x!=0] ).mean()), axis=1 )<feature_engineering>
sub = pd.DataFrame()
sub['Id'] = test_ID
sub['SalePrice'] = ensemble
sub.to_csv('submission.csv',index=False )