Kaggle competition: Predict Future Sales
<SOS> metric: rmse Kaggle data source: predict-future-sales<choose_model_class>
%matplotlib inline
data_path = '/kaggle/input/competitive-data-science-predict-future-sales/'
def model_1(inp):
x = tf.keras.layers.BatchNormalization()(inp)
 x = tf.keras.layers.Dropout(0.1 )(x)
 x = tf.keras.layers.Dense(64 )(x)
 x = tf.keras.layers.BatchNormalization()(x)
 x = tf.keras.layers.Activation(tf.keras.activations.swish )(x)
 x = tf.keras.layers.Dropout(0.1 )(x)
 x = tf.keras.layers.Dense(64 )(x)
 x = tf.keras.layers.BatchNormalization()(x)
 x = tf.keras.layers.Activation(tf.keras.activations.swish )(x)
 out = tf.keras.layers.Dropout(0.1 )(x)
 return out
def model_2(inp):
x = tf.keras.layers.BatchNormalization()(inp)
 x = tf.keras.layers.Dropout(0.1 )(x)
 x = tf.keras.layers.Dense(32 )(x)
 x = tf.keras.layers.BatchNormalization()(x)
 x = tf.keras.layers.Activation(tf.keras.activations.swish )(x)
 x = tf.keras.layers.Dropout(0.1 )(x)
 x = tf.keras.layers.Dense(32 )(x)
 x = tf.keras.layers.BatchNormalization()(x)
 x = tf.keras.layers.Activation(tf.keras.activations.swish )(x)
 out = tf.keras.layers.Dropout(0.1 )(x)
 return out
def model_3(inp):
x = tf.keras.layers.BatchNormalization()(inp)
 x = tf.keras.layers.Dropout(0.1 )(x)
 x = tf.keras.layers.Dense(32 )(x)
 x = tf.keras.layers.BatchNormalization()(x)
 x = tf.keras.layers.Activation(tf.keras.activations.swish )(x)
 x = tf.keras.layers.Dropout(0.1 )(x)
 x = tf.keras.layers.Dense(32 )(x)
 x = tf.keras.layers.BatchNormalization()(x)
 x = tf.keras.layers.Activation(tf.keras.activations.swish )(x)
 out = tf.keras.layers.Dropout(0.1 )(x)
 return out
def model_4(inp):
x = tf.keras.layers.BatchNormalization()(inp)
 x = tf.keras.layers.Dropout(0.1 )(x)
 x = tf.keras.layers.Dense(32 )(x)
 x = tf.keras.layers.BatchNormalization()(x)
 x = tf.keras.layers.Activation(tf.keras.activations.swish )(x)
 x = tf.keras.layers.Dropout(0.1 )(x)
 x = tf.keras.layers.Dense(32 )(x)
 x = tf.keras.layers.BatchNormalization()(x)
 x = tf.keras.layers.Activation(tf.keras.activations.swish )(x)
 out = tf.keras.layers.Dropout(0.1 )(x)
 return out
def create_mlp(f_shape, num_labels, hidden_units, dropout_rates, label_smoothing, learning_rate):
inp1 = tf.keras.layers.Input(shape =(f_shape[0],))
inp2 = tf.keras.layers.Input(shape =(f_shape[1],))
inp3 = tf.keras.layers.Input(shape =(f_shape[2],))
inp4 = tf.keras.layers.Input(shape =(f_shape[3],))
mlp1 = model_1(inp1)
 mlp2 = model_2(inp2)
 mlp3 = model_3(inp3)
 mlp4 = model_4(inp4)
 combined = tf.keras.layers.Concatenate()([mlp1, mlp2, mlp3, mlp4])
 out = tf.keras.layers.Dense(num_labels, activation="sigmoid" )(combined)
 model = tf.keras.models.Model(inputs =[inp1, inp2, inp3, inp4], outputs = out)
 model.compile(optimizer = tf.keras.optimizers.Adam(learning_rate = learning_rate),
loss = tf.keras.losses.BinaryCrossentropy(label_smoothing = label_smoothing),
metrics = tf.keras.metrics.AUC(name = 'AUC'))
return model<split>
def downcast_dtypes(df):
start_size = df.memory_usage(deep = True ).sum() / 1024**2
print('Memory usage: {:.2f} MB'.format(start_size))
float_cols = [c for c in df if df[c].dtype == "float64"]
int_cols = [c for c in df if df[c].dtype in ["int64", "int32"]]
df[float_cols] = df[float_cols].astype(np.float32)
 df[int_cols] = df[int_cols].astype(np.int32)
 end_size = df.memory_usage(deep = True ).sum() / 1024**2
print('New Memory usage: {:.2f} MB'.format(end_size))
return df
def create_record_for_features(df, attrs, target, time_col, aggfunc = np.sum, fill = 0):
target_for_attrs = df.pivot_table(index = attrs,
values = target,
columns = time_col,
aggfunc = aggfunc,
fill_value = fill,
).reset_index()
target_for_attrs.columns = target_for_attrs.columns.map(str)
 target_for_attrs = target_for_attrs.reset_index(drop = True ).rename_axis(None, axis = 1)
 return target_for_attrs
def display_df_info(df, name):
print('-----------Shape of '+ name + '-------------')
 print(df.shape)
 print('-----------Missing values---------')
 print(df.isnull().sum())
 print('-----------Null values------------')
 print(df.isna().sum())
 print('-----------Data types-------------')
 print(df.dtypes)
 print('-----------Memory usage(MB)------')
 print(np.round(df.memory_usage(deep = True ).sum() / 1024**2, 2))
name = "mlp"
batch_size = 4096*16
hidden_units = [64, 32, 64, 130, 256, 256, 128]
dropout_rates = [0.1, 0.2, 0.2, 0.2, 0.25, 0.25, 0.25, 0.25]
label_smoothing = 1e-2
learning_rate = 1e-3
scores_list = []
gtss = GroupTimeSeriesSplit(n_splits = 5)
<load_pretrained>
sales = pd.read_csv(data_path + 'sales_train.csv')
 sales = downcast_dtypes(sales )
models_idx = [0,1,2,3,4]
models = []
for i in models_idx:
clf = create_mlp(f_shape, 5, hidden_units, dropout_rates, label_smoothing, learning_rate)
 path = f'.. /input/stacknnmodels/JSModel_{i}.hdf5'
print(path)
 clf.load_weights(path)
 models.append(clf )<split>
items = pd.read_csv(data_path + 'items.csv')
 items = downcast_dtypes(items )
env = janestreet.make_env()
env_iter = env.iter_test()<define_search_space>
item_categories = pd.read_csv(data_path + 'item_categories.csv')
 item_categories = downcast_dtypes(item_categories )
opt_th = 0.5
w = np.asarray([0.05,0.05,0.1,0.5,0.3])
 for(test_df, pred_df)in tqdm(env_iter):
if test_df['weight'].item() > 0:
x_tt = test_df.loc[:, features].values
if np.isnan(x_tt[:, 1:].sum()):
x_tt[:, 1:] = np.nan_to_num(x_tt[:, 1:])+ np.isnan(x_tt[:, 1:])* f_mean
x_tt_1 = x_tt[:, c_1_]
x_tt_2 = x_tt[:, c_2_]
x_tt_3 = x_tt[:, c_3_]
x_tt_4 = x_tt[:, c_4_]
x_tt_ = [x_tt_1, x_tt_2, x_tt_3, x_tt_4]
pred = np.mean(models[-2](x_tt_, training = False ).numpy().squeeze())
 pred_df.action = np.where(pred >= opt_th, 1, 0 ).astype(int)
 else:
pred_df.action = 0
env.predict(pred_df )<install_modules>
shops = pd.read_csv(data_path + 'shops.csv')
 shops = downcast_dtypes(shops )
!pip install.. /input/python-datatable/datatable-0.11.0-cp37-cp37m-manylinux2010_x86_64.whl > /dev/null 2>&1<set_options>
test = pd.read_csv(data_path + 'test.csv')
 test = downcast_dtypes(test )
plt.style.use('fivethirtyeight')
 y_ = Fore.YELLOW
r_ = Fore.RED
g_ = Fore.GREEN
b_ = Fore.BLUE
m_ = Fore.MAGENTA
c_ = Fore.CYAN
sr_ = Style.RESET_ALL
warnings.filterwarnings('ignore')
 output_notebook() 
<load_from_csv>
del sales_sampled
gc.collect()
%%time
folder_path = '.. /input/jane-street-market-prediction/'
train_data = dt.fread(folder_path + 'train.csv' ).to_pandas()
features = dt.fread(folder_path + 'features.csv' ).to_pandas()
sample = dt.fread(folder_path + 'example_sample_submission.csv' ).to_pandas()
test_data = dt.fread(folder_path + 'example_test.csv' ).to_pandas()<count_missing_values>
sales.loc[:, 'item_price'] = sales.loc[:, 'item_price'].clip(-1, 10**5)
 sale_with_negative_price = sales[sales['item_price'] < 0]
sale_with_negative_price
print("Number of features with null values:",np.sum(train_data.isna().sum() >0))<count_missing_values>
sale = sales[(sales.shop_id == 32)&(sales.item_id == 2973)&(sales.date_block_num == 4)&(sales.item_price > 0)]
median = sale.item_price.median()
sales.loc[sales.item_price < 0, 'item_price'] = median
train_data.fillna(train_data.mean() ,inplace=True)
 print("Number of features with null values:",np.sum(train_data.isna().sum() >0))<count_values>
del sale
del median
del sale_with_negative_price
gc.collect()
print("Number of rows with weight zero:",np.sum(train_data.weight==0))
print("Percentage of rows with weight zero",np.sum(train_data.weight==0)/len(train_data))<count_values>
sales_temp = sales[sales['item_cnt_day'] > 500]
print('Sold item outliers')
 items[items['item_id'].isin(sales_temp['item_id'].values)].merge(sales_temp[['item_id', 'item_cnt_day', 'date_block_num']], on = 'item_id' )
print("Number of rows with resp zero:",np.sum(train_data.resp==0))
print("Percentage of rows with resp zero",np.sum(train_data.resp==0)/len(train_data))<feature_engineering>
del sales_temp
gc.collect()
def utility_score(df,score=0.5,testing=False,true_percentage=0.8):
if testing:
df['action'] = 0
false_percentage = 1 - true_percentage
mask1 = df['resp'] >= 0
mask2 = df['resp'] < 0
df.loc[mask1,'action'] = score
change_idx = df[mask1].sample(frac=false_percentage ).index
df.loc[change_idx,'action'] = 0
change_idx = df[mask2].sample(frac=false_percentage ).index
df.loc[change_idx,'action'] = score
df['pj'] = df['action'] * df['resp'] * df['weight']
pi = df[['date','pj']].groupby('date' ).agg({'pj':['sum']})
 pi.columns = ['pi']
pi['pi_sq'] = pi['pi']**2
t = np.sum(pi['pi'])/np.sqrt(np.sum(pi['pi_sq'])) * np.sqrt(250/len(pi['pi']))
u = min(max(t,0),6)* np.sum(pi['pi'])
 return u
else:
df['pj'] = df['action'] * df['resp'] * df['weight']
pi = df[['date','pj']].groupby('date' ).agg({'pj':['sum']})
 pi.columns = ['pi']
pi['pi_sq'] = pi['pi']**2
t = np.sum(pi['pi'])/np.sqrt(np.sum(pi['pi_sq'])) * np.sqrt(250/len(pi['pi']))
u = min(max(t,0),6)* np.sum(pi['pi'])
 return u<feature_engineering>
print('Number of duplicates:', len(sales[sales.duplicated() ]))
train_data['action'] =0
train_data.loc[train_data['resp']>0.0,'action'] = 1
features = [f"feature_{x}" for x in range(130)]<groupby>
sales = sales.drop_duplicates(keep = 'first')
 print('Number of duplicates:', len(sales[sales.duplicated() ]))
temp = train_data.groupby('action')[[f"feature_{x}" for x in range(130)]].mean()
diff_mean =(temp.iloc[1] - temp.loc[0] ).abs()
highest_diff_in_mean = diff_mean.sort_values(ascending=False)[:10].index.tolist()<import_modules>
start = time.time()
sales.date = sales.date.apply(lambda x: datetime.datetime.strptime(x, '%d.%m.%Y'))
print('First sale took place: ', sales.date.min())
 print('Last sale took place: ', sales.date.max())
 print('It tooks: ', round(time.time() - start), 'seconds' )
class PurgedGroupTimeSeriesSplit(_BaseKFold):

 @_deprecate_positional_args
def __init__(self,
n_splits=5,
*,
max_train_group_size=np.inf,
max_test_group_size=np.inf,
group_gap=None,
verbose=False 
):
super().__init__(n_splits, shuffle=False, random_state=None)
 self.max_train_group_size = max_train_group_size
self.group_gap = group_gap
self.max_test_group_size = max_test_group_size
self.verbose = verbose
def split(self, X, y=None, groups=None):

 if groups is None:
raise ValueError(
 "The 'groups' parameter should not be None")
 X, y, groups = indexable(X, y, groups)
 n_samples = _num_samples(X)
 n_splits = self.n_splits
group_gap = self.group_gap
max_test_group_size = self.max_test_group_size
max_train_group_size = self.max_train_group_size
n_folds = n_splits + 1
group_dict = {}
u, ind = np.unique(groups, return_index=True)
 unique_groups = u[np.argsort(ind)]
n_samples = _num_samples(X)
 n_groups = _num_samples(unique_groups)
 for idx in np.arange(n_samples):
if(groups[idx] in group_dict):
group_dict[groups[idx]].append(idx)
 else:
group_dict[groups[idx]] = [idx]
if n_folds > n_groups:
raise ValueError(
("Cannot have number of folds={0} greater than"
" the number of groups={1}" ).format(n_folds,
n_groups))
group_test_size = min(n_groups // n_folds, max_test_group_size)
 group_test_starts = range(n_groups - n_splits * group_test_size,
n_groups, group_test_size)
 for group_test_start in group_test_starts:
train_array = []
test_array = []
group_st = max(0, group_test_start - group_gap - max_train_group_size)
 for train_group_idx in unique_groups[group_st:(group_test_start - group_gap)]:
train_array_tmp = group_dict[train_group_idx]
train_array = np.sort(np.unique(
 np.concatenate(( train_array,
train_array_tmp)) ,
axis=None), axis=None)
 train_end = train_array.size
for test_group_idx in unique_groups[group_test_start:
group_test_start +
group_test_size]:
test_array_tmp = group_dict[test_group_idx]
test_array = np.sort(np.unique(
 np.concatenate(( test_array,
test_array_tmp)) ,
axis=None), axis=None)
 test_array = test_array[group_gap:]
if self.verbose > 0:
pass
yield [int(i)for i in train_array], [int(i)for i in test_array]<data_type_conversions>
start = time.time()
pairs_trans = create_record_for_features(sales, ['shop_id', 'item_id'], 'item_cnt_day', 'date_block_num', aggfunc = np.count_nonzero, fill = 0)
 print('It tooks: ', round(time.time() - start), 'seconds' )
features = [f'feature_{x}' for x in range(130)]
target_feature = 'action'
train_mean = train_data.mean()
train_data.fillna(train_mean,inplace=True)
 train_data['action'] = 0
train_data.loc[train_data['resp']>0.0,'action'] = 1
dates = train_data['date'].to_numpy()
target = train_data[target_feature].to_numpy()
train_data = train_data[features].to_numpy()<init_hyperparams>
for month in range(1, 12):
pairs_temp = pairs_trans[['shop_id', 'item_id']][pairs_trans.loc[:,'0': str(month)].sum(axis = 1)== 0]
print('From month: 0 until ', month,', ', np.round(100 * len(pairs_temp)/ len(pairs_trans), 2), '% of the item/shop pairs have made no sales' )
params = {
'objective': 'binary',
'metrics':['auc'],
}
nfolds=3
group_gap = 31<train_model>
for month in range(21, 33):
pairs_temp = pairs_trans[['shop_id', 'item_id']][pairs_trans.loc[:,str(month): '33'].sum(axis = 1)== 0]
print('From month: ', month, ' until month: 33, ', np.round(100 * len(pairs_temp)/ len(pairs_trans), 2), '% of the item/shop pairs have made no sales' )
kfold = PurgedGroupTimeSeriesSplit(n_splits=nfolds,group_gap=group_gap)
 lgb_models = list()
for k ,(train_idx,valid_idx)in enumerate(kfold.split(train_data,target.ravel() ,dates.ravel())) :
lgb_train = lgb.Dataset(train_data[train_idx],target[train_idx].ravel())
 lgb_valid = lgb.Dataset(train_data[valid_idx],target[valid_idx].ravel())
 model = lgb.train(
 params,
lgb_train,
valid_sets = [lgb_train,lgb_valid],
num_boost_round = 10000,
verbose_eval = 50,
early_stopping_rounds = 10, 
)
 lgb_models.append(model )<predict_on_test>
del pairs_trans
del pairs_temp
gc.collect()
predictions = np.zeros(test_data.shape[0])
 for model in lgb_models:
predictions += model.predict(test_data[features])
 predictions /= len(lgb_models)
 sns.distplot(predictions);<set_options>
start = time.time()
items_trans = create_record_for_features(sales, ['item_id'], 'item_cnt_day', 'date_block_num', aggfunc = np.count_nonzero, fill = 0)
 print('It tooks: ', round(time.time() - start), 'seconds' )
del train_data, target
gc.collect()<define_variables>
for month in range(1, 12):
items_temp = items_trans['item_id'][items_trans.loc[:,'0': str(month)].sum(axis = 1)== 0]
print('From month: 0 until ', month,', ', np.round(100 * len(items_temp)/ len(items_trans), 2), '% of the items have made no sales' )
env = janestreet.make_env()
iter_test = env.iter_test()<predict_on_test>
for month in range(21, 33):
items_temp = items_trans['item_id'][items_trans.loc[:,str(month): '33'].sum(axis = 1)== 0]
print('From month: ', month, ' until month: 33, ', np.round(100 * len(items_temp)/ len(items_trans), 2), '% of the items have made no sales' )
%%time
for(test_df, sample_prediction_df)in iter_test:
prediction = 0
for model in lgb_models:
prediction += model.predict(test_df[features])[0]
prediction /= len(lgb_models)
 prediction = prediction > 0.5
sample_prediction_df.action = prediction.astype(int)
 env.predict(sample_prediction_df )<load_from_csv>
del items_trans
del items_temp
gc.collect()
submission = pd.read_csv('./submission.csv')
 submission.head()<load_from_csv>
start = time.time()
shops_trans = create_record_for_features(sales, ['shop_id'], 'item_cnt_day', 'date_block_num', aggfunc = np.count_nonzero, fill = 0)
 print('It tooks: ', round(time.time() - start), 'seconds' )
warnings.filterwarnings("ignore")
 %matplotlib inline
tf.random.set_seed(42)
 train = dd.read_csv('/kaggle/input/jane-street-market-prediction/train.csv' ).compute().sort_values('ts_id')
 features = [c for c in train.columns if "feature" in c]
def create_mlp(
 num_columns, num_labels, hidden_units, dropout_rates, label_smoothing, learning_rate 
):
inp = tf.keras.layers.Input(shape=(num_columns,))
x = tf.keras.layers.BatchNormalization()(inp)
 x = tf.keras.layers.Dropout(dropout_rates[0] )(x)
 for i in range(len(hidden_units)) :
x = tf.keras.layers.Dense(hidden_units[i] )(x)
 x = tf.keras.layers.BatchNormalization()(x)
 x = tf.keras.layers.Activation(tf.keras.activations.swish )(x)
 x = tf.keras.layers.Dropout(dropout_rates[i + 1] )(x)
 x = tf.keras.layers.Dense(num_labels )(x)
 out = tf.keras.layers.Activation("sigmoid" )(x)
 model = tf.keras.models.Model(inputs=inp, outputs=out)
 model.compile(
 optimizer=tf.keras.optimizers.Adam(learning_rate=learning_rate),
loss=tf.keras.losses.BinaryCrossentropy(label_smoothing=label_smoothing),
metrics=tf.keras.metrics.AUC(name="AUC"), 
)
 return model
batch_size = 4096
hidden_units = [384, 896, 896, 394]
dropout_rates = [
0.10143786981358652,
0.19720339053599725,
0.2703017847244654,
0.23148340929571917,
0.2357768967777311,
]
label_smoothing = 1e-2
learning_rate = 1e-3
num_models = 2
models = []
for i in range(num_models):
clf = create_mlp(
 len(features), 1, hidden_units, dropout_rates, label_smoothing, learning_rate 
)
 clf.load_weights(f".. /input/js-nn-models/JSModel_{i}.hdf5")
 models.append(clf)
 f_mean = np.load('.. /input/js-nn-models/f_mean.npy')
<define_variables>
for month in range(1, 12):
shops_temp = shops_trans['shop_id'][shops_trans.loc[:,'0': str(month)].sum(axis = 1)== 0]
print('From month: 0 until ', month,', ', np.round(100 * len(shops_temp)/ len(shops_trans), 2), '% of the shops have made no sales' )
opt_th = 0.503<categorify>
for month in range(21, 33):
shops_temp = shops_trans['shop_id'][shops_trans.loc[:, str(month): '33'].sum(axis = 1)== 0]
print('From month: ', month, ' until month: 33, ', np.round(100 * len(shops_temp)/ len(shops_trans), 2), '% of the shops have made no sales' )
env = janestreet.make_env()
env_iter = env.iter_test()
for test_df, pred_df in env_iter:
if test_df["weight"].item() > 0:
x_tt = test_df.loc[:, features].values
if np.isnan(x_tt[:, 1:].sum()):
x_tt[:, 1:] = np.nan_to_num(x_tt[:, 1:])+ np.isnan(x_tt[:, 1:])* f_mean
pred = 0.0
for clf in models:
pred += clf(x_tt, training=False ).numpy().item() / num_models
pred_df.action = np.where(pred >= opt_th, 1, 0 ).astype(int)
 else:
pred_df.action = 0
env.predict(pred_df)
<set_options>
del shops_trans
del shops_temp
gc.collect()
tf.random.set_seed(42)
<categorify>
print('test shape: ', test.shape)
 print('number of items in test set: ', test['item_id'].nunique())
 print('number of shops in test set: ', test['shop_id'].nunique())
def reduce_mem_usage(df, verbose=True):
numerics = ['int16', 'int32', 'int64', 'float16', 'float32', 'float64']
start_mem = df.memory_usage().sum() / 1024**2
for col in df.columns:
col_type = df[col].dtypes
if col_type in numerics:
c_min = df[col].min()
c_max = df[col].max()
if str(col_type)[:3] == 'int':
if c_min > np.iinfo(np.int8 ).min and c_max < np.iinfo(np.int8 ).max: df[col] = df[col].astype(np.int8)
 elif c_min > np.iinfo(np.int16 ).min and c_max < np.iinfo(np.int16 ).max: df[col] = df[col].astype(np.int16)
 elif c_min > np.iinfo(np.int32 ).min and c_max < np.iinfo(np.int32 ).max: df[col] = df[col].astype(np.int32)
 elif c_min > np.iinfo(np.int64 ).min and c_max < np.iinfo(np.int64 ).max: df[col] = df[col].astype(np.int64)
 else:
if c_min > np.finfo(np.float16 ).min and c_max < np.finfo(np.float16 ).max: df[col] = df[col].astype(np.float16)
 elif c_min > np.finfo(np.float32 ).min and c_max < np.finfo(np.float32 ).max: df[col] = df[col].astype(np.float32)
 else: df[col] = df[col].astype(np.float64)
 end_mem = df.memory_usage().sum() / 1024**2
return df<load_from_csv>
test['item_id'].nunique() * test['shop_id'].nunique() == len(test )
train = pd.read_csv('/kaggle/input/jane-street-market-prediction/train.csv')
 train = reduce_mem_usage(train)
 features = [c for c in train.columns if 'feature' in c]<data_type_conversions>
item_shop_test = set(test.item_id.astype(str)+ '_' + test.shop_id.astype(str))
item_shop_sales = set(sales.item_id.astype(str)+ '_' + sales.shop_id.astype(str))
pairs_with_history = len(item_shop_test.intersection(item_shop_sales))
pairs_with_no_history = len(shops_in_test_and_sales)* len(item_in_test_not_sales)
 just_item_with_history = test.shape[0] -(pairs_with_history + pairs_with_no_history)
 print('There is sales history for:', np.round(100 * pairs_with_history / len(test), 2), '% items in the same shops')
 print('There is No sales history for:', np.round(100 * pairs_with_no_history / len(test), 2), '% shop/item pairs')
 print('There is sales history for:', np.round(100 * just_item_with_history / len(test), 2), '% items but in different shops' )
train = train.astype({c: np.float32 for c in train.select_dtypes(include='float16' ).columns})
 train = train.fillna(train.mean())
 f_mean = np.mean(train[features[1:]].values,axis=0)
 train = train.query('date > 85' ).reset_index(drop = True)
 train = train[train.weight != 0]
n_folds = 5
seed = 2020
skf = StratifiedKFold(n_splits=n_folds, shuffle=False)
 resp_cols = ['resp', 'resp_1', 'resp_2', 'resp_3', 'resp_4']
X_train = train[train['date'] < 400][features]
X_test = train[train['date'] >= 400][features]
y_train = np.stack([(train[train['date'] < 400][c] > 0.000001 ).astype('int')for c in resp_cols] ).T
y_test = np.stack([(train[train['date'] >= 400][c] > 0.000001 ).astype('int')for c in resp_cols] ).T<choose_model_class>
del items_test
del items_sales
del item_in_test_and_sales
del item_in_test_not_sales
del shops_test
del shops_sales
del shops_in_test_and_sales
del shops_in_test_not_sales
del item_shop_test
del item_shop_sales
del pairs_with_history
del pairs_with_no_history
del just_item_with_history
gc.collect()
<choose_model_class>
shops['shop_name'] = shops['shop_name'].apply(lambda x: x.lower() ).str.replace('[^\w\s]', '' ).str.replace('\d+','' ).str.strip()
shops['shop_city'], shops['shop_name'] = shops['shop_name'].str.split(' ', 1 ).str
shops['shop_type'] = shops['shop_name'].apply(lambda x: 'мтрц' if 'мтрц' in x else 'трц' if 'трц' in x else 'трк' if 'трк' in x else 'тц' if 'тц' in x else 'тк' if 'тк' in x else 'unkown')
 shops.head()
TUNING_IND = False
def create_model(hp,input_dim,output_dim):
inputs = tf.keras.layers.Input(input_dim)
 x = tf.keras.layers.BatchNormalization()(inputs)
 x = tf.keras.layers.GaussianNoise(hp.Choice('noise',[0.0,0.03,0.05]))(x)
 x = tf.keras.layers.Dropout(hp.Choice('init_dropout',[0.0,0.3,0.5]))(x)
 x = tf.keras.layers.Dense(hp.Int('num_units_1', 128, 2048, 64), activation=hp.Choice('activation_1', ['tanh','relu','swish']))(x)
 x = tf.keras.layers.Dropout(hp.Choice(f'dropout_1',[0.0,0.3,0.5]))(x)
 x = tf.keras.layers.Dense(hp.Int('num_units_2', 128, 1024, 32), activation=hp.Choice('activation_2', ['tanh','relu','swish']))(x)
 x = tf.keras.layers.Dropout(hp.Choice(f'dropout_2',[0.0,0.3,0.5]))(x)
 x = tf.keras.layers.Dense(output_dim, activation='sigmoid' )(x)
 model = tf.keras.models.Model(inputs=inputs,outputs=x)
 model.compile(optimizer=tf.keras.optimizers.Adam(hp.Choice('lr',[1e-2, 1e-3, 1e-5])) ,loss=tf.keras.losses.BinaryCrossentropy(label_smoothing=hp.Choice('label_smoothing',[0.0, 0.01, 0.1])) ,metrics=[tf.keras.metrics.AUC(name = 'auc')])
 return model
model = tf.keras.Sequential([
tf.keras.Input(shape = len(features)) ,
tf.keras.layers.BatchNormalization() ,
tf.keras.layers.GaussianNoise(0.05),
tf.keras.layers.Dropout(0.00),
tf.keras.layers.Dense(2048, activation='tanh'),
tf.keras.layers.Dropout(0.5),
tf.keras.layers.Dense(1024, activation='swish'),
tf.keras.layers.Dropout(0.5),
tf.keras.layers.Dense(2048, activation='swish'),
tf.keras.layers.Dropout(0.5),
tf.keras.layers.Dense(128, activation='swish'),
tf.keras.layers.Dense(5, activation = 'sigmoid')
 ])
 EPOCHS = 500
BATCH_SIZE = 1024
if TUNING_IND:
EPOCHS = 50
MAX_TRIAL = 20
model_fn = lambda hp: create_model(hp, X_train.shape[-1], y_train.shape[-1])
 tuner = kt.tuners.BayesianOptimization(model_fn, kt.Objective('val_auc', direction='max'), MAX_TRIAL, seed = 2020)
 tuner.search(X_train, y_train, epochs=EPOCHS, validation_data=(X_test, y_test),callbacks=[tf.keras.callbacks.EarlyStopping(monitor='val_loss', patience = 10, restore_best_weights=True)])
 model = tuner.get_best_models() [0]
else:
callback = tf.keras.callbacks.EarlyStopping(monitor='val_loss', patience=20, restore_best_weights=True)
 optimizer = tf.keras.optimizers.SGD(learning_rate=1e-5)
 optimizer = tf.keras.optimizers.Adam(learning_rate=1e-5)
 loss=tf.keras.losses.BinaryCrossentropy(label_smoothing=0.00)
 model.compile(loss = loss, optimizer=optimizer, metrics=[tf.keras.metrics.AUC() ])
 history = model.fit(X, y, batch_size=BATCH_SIZE, epochs=EPOCHS, callbacks=[callback], validation_data=(X_test, y_test))<init_hyperparams>
print('Shops number:', shops['shop_id'].nunique())
 print('Shop names number:', shops['shop_name'].nunique())
 print('Shop cities number:', shops['shop_city'].nunique())
 print('Shop types number:', shops['shop_type'].nunique() )
<load_pretrained>
sales.loc[sales['shop_id'] == 11, 'shop_id'] = 10
shops.loc[shops['shop_id'] == 11, 'shop_id'] = 10
sales.loc[sales['shop_id'] == 23, 'shop_id'] = 24
shops.loc[shops['shop_id'] == 23, 'shop_id'] = 24
sales.loc[sales['shop_id'] == 0, 'shop_id'] = 57
shops.loc[shops['shop_id'] == 0, 'shop_id'] = 57
sales.loc[sales['shop_id'] == 1, 'shop_id'] = 58
shops.loc[shops['shop_id'] == 1, 'shop_id'] = 58
sales.loc[sales['shop_id'] == 40, 'shop_id'] = 39
shops.loc[shops['shop_id'] == 40, 'shop_id'] = 39
shops = shops.drop_duplicates(subset = 'shop_id' )
<load_from_csv>
print('Shops number:', shops['shop_id'].nunique())
 print('Shop names number:', shops['shop_name'].nunique())
 print('Shop cities number:', shops['shop_city'].nunique())
 print('Shop types number:', shops['shop_type'].nunique() )
<feature_engineering>
def clean_names(df, cols):
for col in cols:
df[col] = df[col].str.replace('[^A-Za-z0-9А-Яа-я]+', ' ' ).str.lower()
df[col] = df[col].str.strip()
df.loc[df[col] == '', col] = 'unknown'
janestreet.competition.make_env.__called__ = False
env = janestreet.make_env()
iter_test = env.iter_test()
for(test_df, sample_prediction_df)in tqdm(iter_test):
if test_df['weight'].item() > 0:
x_tt = test_df.loc[:, features].values
if np.isnan(x_tt[:, 1:].sum()):
x_tt[:, 1:] = np.nan_to_num(x_tt[:, 1:])+ np.isnan(x_tt[:, 1:])* f_mean
action = np.mean(model(x_tt, training = False ).numpy() [0])
 if(action > 0.502):
sample_prediction_df.action = 1
else:
sample_prediction_df.action = 0
else:
sample_prediction_df.action = 0
env.predict(sample_prediction_df )<import_modules>
items['item_name'], items['item_type'] = items['item_name'].str.split('[', 1 ).str
items['item_name'], items['item_subtype'] = items['item_name'].str.split('(', 1 ).str
clean_names(items, ['item_name', 'item_type', 'item_subtype'])
 items = items.fillna('unkown')
 items.head()
warnings.simplefilter(action='ignore', category=FutureWarning)
 for dirname, _, filenames in os.walk('/kaggle/input'):
for filename in filenames:
print(os.path.join(dirname, filename))
@contextmanager
def timer(title):
t0 = time.time()
yield
print("{} - done in {:.0f}s".format(title, time.time() - t0))
def one_hot_encoder(df, nan_as_category = True):
original_columns = list(df.columns)
 categorical_columns = [col for col in df.columns if df[col].dtype == 'object']
df = pd.get_dummies(df, columns= categorical_columns, dummy_na= nan_as_category)
 new_columns = [c for c in df.columns if c not in original_columns]
return df, new_columns
def application_train_test(num_rows = None, nan_as_category = False):
df = pd.read_csv('/kaggle/input/home-credit-default-risk/application_train.csv', nrows= num_rows)
 test_df = pd.read_csv('/kaggle/input/home-credit-default-risk/application_test.csv', nrows= num_rows)
 print("Train samples: {}, test samples: {}".format(len(df), len(test_df)))
 df = df.append(test_df ).reset_index()
df = df[df['CODE_GENDER'] != 'XNA']
df['New_Family_Status']=df['NAME_FAMILY_STATUS'].apply(lambda x:0 if x in ['Married','Widow'] else 1)
 df['CH_FA']=df['CNT_CHILDREN']*df['New_Family_Status']
for bin_feature in ['CODE_GENDER', 'FLAG_OWN_CAR', 'FLAG_OWN_REALTY']:
df[bin_feature], uniques = pd.factorize(df[bin_feature])
 df, cat_cols = one_hot_encoder(df, nan_as_category)
 df['DAYS_EMPLOYED_ANOM']=(df['DAYS_EMPLOYED']==365243)
 df['DAYS_EMPLOYED'].replace({365243:np.nan},inplace=True)
 df['DAYS_BIRTH'] = df['DAYS_BIRTH'].abs() / 365
df['DAYS_EMPLOYED'] = df['DAYS_EMPLOYED'].abs() / 365
df.rename(columns={'DAYS_BIRTH': 'YEARS_BIRTH', 'DAYS_EMPLOYED': 'YEARS_EMPLOYED'}, inplace=True)
 df['YEARS_EMPLOYED_PREC']=df['YEARS_EMPLOYED']/df['YEARS_BIRTH']
df['YEARS_EMPLOYED_DIF']=df['YEARS_BIRTH']-df['YEARS_EMPLOYED']
df['INCOME_CREDIT_PERC']=df['AMT_INCOME_TOTAL']/df['AMT_CREDIT']
df['INCOME_PER_PERSON']=df['AMT_INCOME_TOTAL']/df['CNT_FAM_MEMBERS']
df['ANNUITY_INCOME_PERC'] = df['AMT_ANNUITY'] / df['AMT_INCOME_TOTAL']
df['AVG_CREDIT_TERM'] = df['AMT_CREDIT'] / df['AMT_ANNUITY']
del test_df
gc.collect()
return df
def bureau_and_balance(num_rows = None, nan_as_category = True):
bureau = pd.read_csv('/kaggle/input/home-credit-default-risk/bureau.csv', nrows = num_rows)
 bb = pd.read_csv('/kaggle/input/home-credit-default-risk/bureau_balance.csv', nrows = num_rows)
 bb, bb_cat = one_hot_encoder(bb, nan_as_category)
 bureau, bureau_cat = one_hot_encoder(bureau, nan_as_category)
 bb_aggregations = {'MONTHS_BALANCE': ['min', 'max', 'size']}
for col in bb_cat:
bb_aggregations[col] = ['mean']
bb_agg = bb.groupby('SK_ID_BUREAU' ).agg(bb_aggregations)
 bb_agg.columns = pd.Index([e[0] + "_" + e[1].upper() for e in bb_agg.columns.tolist() ])
 bureau = bureau.join(bb_agg, how='left', on='SK_ID_BUREAU')
 bureau.drop(['SK_ID_BUREAU'], axis=1, inplace= True)
 del bb, bb_agg
gc.collect()
num_aggregations = {
'DAYS_CREDIT': ['min', 'max', 'mean', 'var'],
'DAYS_CREDIT_ENDDATE': ['min', 'max', 'mean'],
'DAYS_CREDIT_UPDATE': ['mean'],
'CREDIT_DAY_OVERDUE': ['max', 'mean'],
'AMT_CREDIT_MAX_OVERDUE': ['mean'],
'AMT_CREDIT_SUM': ['max', 'mean', 'sum'],
'AMT_CREDIT_SUM_DEBT': ['max', 'mean', 'sum'],
'AMT_CREDIT_SUM_OVERDUE': ['mean'],
'AMT_CREDIT_SUM_LIMIT': ['mean', 'sum'],
'AMT_ANNUITY': ['max', 'mean'],
'CNT_CREDIT_PROLONG': ['sum'],
'MONTHS_BALANCE_MIN': ['min'],
'MONTHS_BALANCE_MAX': ['max'],
'MONTHS_BALANCE_SIZE': ['mean', 'sum']
}
cat_aggregations = {}
for cat in bureau_cat: cat_aggregations[cat] = ['mean']
for cat in bb_cat: cat_aggregations[cat + "_MEAN"] = ['mean']
bureau_agg = bureau.groupby('SK_ID_CURR' ).agg({**num_aggregations, **cat_aggregations})
 bureau_agg.columns = pd.Index(['BURO_' + e[0] + "_" + e[1].upper() for e in bureau_agg.columns.tolist() ])
 active = bureau[bureau['CREDIT_ACTIVE_Active'] == 1]
active_agg = active.groupby('SK_ID_CURR' ).agg(num_aggregations)
 active_agg.columns = pd.Index(['ACTIVE_' + e[0] + "_" + e[1].upper() for e in active_agg.columns.tolist() ])
 bureau_agg = bureau_agg.join(active_agg, how='left', on='SK_ID_CURR')
 del active, active_agg
gc.collect()
closed = bureau[bureau['CREDIT_ACTIVE_Closed'] == 1]
closed_agg = closed.groupby('SK_ID_CURR' ).agg(num_aggregations)
 closed_agg.columns = pd.Index(['CLOSED_' + e[0] + "_" + e[1].upper() for e in closed_agg.columns.tolist() ])
 bureau_agg = bureau_agg.join(closed_agg, how='left', on='SK_ID_CURR')
 del closed, closed_agg, bureau
gc.collect()
return bureau_agg
def previous_applications(num_rows = None, nan_as_category = True):
prev = pd.read_csv('/kaggle/input/home-credit-default-risk/previous_application.csv', nrows = num_rows)
 prev, cat_cols = one_hot_encoder(prev, nan_as_category= True)
 prev['DAYS_FIRST_DRAWING'].replace(365243, np.nan, inplace= True)
 prev['DAYS_FIRST_DUE'].replace(365243, np.nan, inplace= True)
 prev['DAYS_LAST_DUE_1ST_VERSION'].replace(365243, np.nan, inplace= True)
 prev['DAYS_LAST_DUE'].replace(365243, np.nan, inplace= True)
 prev['DAYS_TERMINATION'].replace(365243, np.nan, inplace= True)
 prev['APP_CREDIT_PERC'] = prev['AMT_APPLICATION'] / prev['AMT_CREDIT']
num_aggregations = {
'AMT_ANNUITY': ['min', 'max', 'mean'],
'AMT_APPLICATION': ['min', 'max', 'mean'],
'AMT_CREDIT': ['min', 'max', 'mean'],
'APP_CREDIT_PERC': ['min', 'max', 'mean', 'var'],
'AMT_DOWN_PAYMENT': ['min', 'max', 'mean'],
'AMT_GOODS_PRICE': ['min', 'max', 'mean'],
'HOUR_APPR_PROCESS_START': ['min', 'max', 'mean'],
'RATE_DOWN_PAYMENT': ['min', 'max', 'mean'],
'DAYS_DECISION': ['min', 'max', 'mean'],
'CNT_PAYMENT': ['mean', 'sum'],
}
cat_aggregations = {}
for cat in cat_cols:
cat_aggregations[cat] = ['mean']
prev_agg = prev.groupby('SK_ID_CURR' ).agg({**num_aggregations, **cat_aggregations})
 prev_agg.columns = pd.Index(['PREV_' + e[0] + "_" + e[1].upper() for e in prev_agg.columns.tolist() ])
 approved = prev[prev['NAME_CONTRACT_STATUS_Approved'] == 1]
approved_agg = approved.groupby('SK_ID_CURR' ).agg(num_aggregations)
 approved_agg.columns = pd.Index(['APPROVED_' + e[0] + "_" + e[1].upper() for e in approved_agg.columns.tolist() ])
 prev_agg = prev_agg.join(approved_agg, how='left', on='SK_ID_CURR')
 refused = prev[prev['NAME_CONTRACT_STATUS_Refused'] == 1]
refused_agg = refused.groupby('SK_ID_CURR' ).agg(num_aggregations)
 refused_agg.columns = pd.Index(['REFUSED_' + e[0] + "_" + e[1].upper() for e in refused_agg.columns.tolist() ])
 prev_agg = prev_agg.join(refused_agg, how='left', on='SK_ID_CURR')
 del refused, refused_agg, approved, approved_agg, prev
gc.collect()
return prev_agg
def pos_cash(num_rows = None, nan_as_category = True):
pos = pd.read_csv('/kaggle/input/home-credit-default-risk/POS_CASH_balance.csv', nrows = num_rows)
 pos, cat_cols = one_hot_encoder(pos, nan_as_category= True)
 aggregations = {
'MONTHS_BALANCE': ['max', 'mean', 'size'],
'SK_DPD': ['max', 'mean'],
'SK_DPD_DEF': ['max', 'mean']
}
for cat in cat_cols:
aggregations[cat] = ['mean']
pos_agg = pos.groupby('SK_ID_CURR' ).agg(aggregations)
 pos_agg.columns = pd.Index(['POS_' + e[0] + "_" + e[1].upper() for e in pos_agg.columns.tolist() ])
 pos_agg['POS_COUNT'] = pos.groupby('SK_ID_CURR' ).size()
del pos
gc.collect()
return pos_agg
def installments_payments(num_rows = None, nan_as_category = True):
ins = pd.read_csv('/kaggle/input/home-credit-default-risk/installments_payments.csv', nrows = num_rows)
 ins, cat_cols = one_hot_encoder(ins, nan_as_category= True)
 ins['PAYMENT_PERC'] = ins['AMT_PAYMENT'] / ins['AMT_INSTALMENT']
ins['PAYMENT_DIFF'] = ins['AMT_INSTALMENT'] - ins['AMT_PAYMENT']
ins['DPD'] = ins['DAYS_ENTRY_PAYMENT'] - ins['DAYS_INSTALMENT']
ins['DBD'] = ins['DAYS_INSTALMENT'] - ins['DAYS_ENTRY_PAYMENT']
ins['DPD'] = ins['DPD'].apply(lambda x: x if x > 0 else 0)
 ins['DBD'] = ins['DBD'].apply(lambda x: x if x > 0 else 0)
 aggregations = {
'NUM_INSTALMENT_VERSION': ['nunique'],
'DPD': ['max', 'mean', 'sum'],
'DBD': ['max', 'mean', 'sum'],
'PAYMENT_PERC': ['max', 'mean', 'sum', 'var'],
'PAYMENT_DIFF': ['max', 'mean', 'sum', 'var'],
'AMT_INSTALMENT': ['max', 'mean', 'sum'],
'AMT_PAYMENT': ['min', 'max', 'mean', 'sum'],
'DAYS_ENTRY_PAYMENT': ['max', 'mean', 'sum']
}
for cat in cat_cols:
aggregations[cat] = ['mean']
ins_agg = ins.groupby('SK_ID_CURR' ).agg(aggregations)
 ins_agg.columns = pd.Index(['INSTAL_' + e[0] + "_" + e[1].upper() for e in ins_agg.columns.tolist() ])
 ins_agg['INSTAL_COUNT'] = ins.groupby('SK_ID_CURR' ).size()
del ins
gc.collect()
return ins_agg
def credit_card_balance(num_rows = None, nan_as_category = True):
cc = pd.read_csv('/kaggle/input/home-credit-default-risk/credit_card_balance.csv', nrows = num_rows)
 cc, cat_cols = one_hot_encoder(cc, nan_as_category= True)
 cc.drop(['SK_ID_PREV'], axis= 1, inplace = True)
 cc_agg = cc.groupby('SK_ID_CURR' ).agg(['min', 'max', 'mean', 'sum', 'var'])
 cc_agg.columns = pd.Index(['CC_' + e[0] + "_" + e[1].upper() for e in cc_agg.columns.tolist() ])
 cc_agg['CC_COUNT'] = cc.groupby('SK_ID_CURR' ).size()
del cc
gc.collect()
return cc_agg
def kfold_lightgbm(df, num_folds, stratified = False, debug= False):
train_df = df[df['TARGET'].notnull() ]
test_df = df[df['TARGET'].isnull() ]
print("Starting LightGBM.Train shape: {}, test shape: {}".format(train_df.shape, test_df.shape))
del df
gc.collect()
if stratified:
folds = StratifiedKFold(n_splits= num_folds, shuffle=True, random_state=1001)
 else:
folds = KFold(n_splits= num_folds, shuffle=True, random_state=1001)
 oof_preds = np.zeros(train_df.shape[0])
 sub_preds = np.zeros(test_df.shape[0])
 feature_importance_df = pd.DataFrame()
feats = [f for f in train_df.columns if f not in ['TARGET','SK_ID_CURR','SK_ID_BUREAU','SK_ID_PREV','index']]
for n_fold,(train_idx, valid_idx)in enumerate(folds.split(train_df[feats], train_df['TARGET'])) :
train_x, train_y = train_df[feats].iloc[train_idx], train_df['TARGET'].iloc[train_idx]
valid_x, valid_y = train_df[feats].iloc[valid_idx], train_df['TARGET'].iloc[valid_idx]
clf = LGBMClassifier(
 nthread=4,
n_estimators=10000,
learning_rate=0.02,
num_leaves=34,
colsample_bytree=0.9497036,
subsample=0.8715623,
max_depth=8,
reg_alpha=0.041545473,
reg_lambda=0.0735294,
min_split_gain=0.0222415,
min_child_weight=39.3259775,
random_state=100,
silent=-1,
verbose=-1,)
 clf.fit(train_x, train_y, eval_set=[(train_x, train_y),(valid_x, valid_y)],
eval_metric= 'auc', verbose= 100, early_stopping_rounds= 200)
 oof_preds[valid_idx] = clf.predict_proba(valid_x, num_iteration=clf.best_iteration_)[:, 1]
sub_preds += clf.predict_proba(test_df[feats], num_iteration=clf.best_iteration_)[:, 1] / folds.n_splits
fold_importance_df = pd.DataFrame()
fold_importance_df["feature"] = feats
fold_importance_df["importance"] = clf.feature_importances_
fold_importance_df["fold"] = n_fold + 1
feature_importance_df = pd.concat([feature_importance_df, fold_importance_df], axis=0)
 print('Fold %2d AUC : %.6f' %(n_fold + 1, roc_auc_score(valid_y, oof_preds[valid_idx])))
 del clf, train_x, train_y, valid_x, valid_y
gc.collect()
print('Full AUC score %.6f' % roc_auc_score(train_df['TARGET'], oof_preds))
if not debug:
test_df['TARGET'] = sub_preds
test_df[['SK_ID_CURR', 'TARGET']].to_csv(submission_file_name, index= False)
 display_importances(feature_importance_df)
 return feature_importance_df
def display_importances(feature_importance_df_):
cols = feature_importance_df_[["feature", "importance"]].groupby("feature" ).mean().sort_values(by="importance", ascending=False)[:40].index
best_features = feature_importance_df_.loc[feature_importance_df_.feature.isin(cols)]
plt.figure(figsize=(8, 10))
sns.barplot(x="importance", y="feature", data=best_features.sort_values(by="importance", ascending=False))
plt.title('LightGBM Features(avg over folds)')
 plt.tight_layout()
plt.savefig('lgbm_importances01.png')
 def main(debug = False):
num_rows = 10000 if debug else None
df = application_train_test(num_rows)
 with timer("Process bureau and bureau_balance"):
bureau = bureau_and_balance(num_rows)
 print("Bureau df shape:", bureau.shape)
 df = df.join(bureau, how='left', on='SK_ID_CURR')
 del bureau
gc.collect()
with timer("Process previous_applications"):
prev = previous_applications(num_rows)
 print("Previous applications df shape:", prev.shape)
 df = df.join(prev, how='left', on='SK_ID_CURR')
 del prev
gc.collect()
with timer("Process POS-CASH balance"):
pos = pos_cash(num_rows)
 print("Pos-cash balance df shape:", pos.shape)
 df = df.join(pos, how='left', on='SK_ID_CURR')
 del pos
gc.collect()
with timer("Process installments payments"):
ins = installments_payments(num_rows)
 print("Installments payments df shape:", ins.shape)
 df = df.join(ins, how='left', on='SK_ID_CURR')
 del ins
gc.collect()
with timer("Process credit card balance"):
cc = credit_card_balance(num_rows)
 print("Credit card balance df shape:", cc.shape)
 df = df.join(cc, how='left', on='SK_ID_CURR')
 del cc
gc.collect()
with timer("Run LightGBM with kfold"):
feat_importance = kfold_lightgbm(df, num_folds= 5, stratified= False, debug= debug)
 if __name__ == "__main__":
submission_file_name = "submission_kernel02.csv"
with timer("Full model run"):
main() 
<set_options>
print('Number of items:', items['item_id'].nunique())
 print('Number of item_name:', items['item_name'].nunique())
 print('Number of item_type:', items['item_type'].nunique())
 print('Number of item_subtype:', items['item_subtype'].nunique() )
warnings.simplefilter(action='ignore', category=FutureWarning )<load_from_csv>
sales = sales.merge(items[['item_id', 'item_category_id']], on = 'item_id', how = 'left' )
df = pd.read_csv(".. /input/dfcsv/df.csv" )<split>
time_shift = 14
df_model = df[df['TARGET'].notnull() ]
feats = [f for f in df_model.columns if f not in ['TARGET','SK_ID_CURR','SK_ID_BUREAU','SK_ID_PREV','index']]
train_x, test_x, train_y, test_y = train_test_split(df_model[feats], df_model['TARGET'], random_state=42)
 df_submission = df.loc[df['TARGET'].isnull() , feats]
main_id_submission =df.loc[df['TARGET'].isnull() , 'SK_ID_CURR']
del df<define_variables>
pairs_sales = create_record_for_features(sales, ['shop_id', 'item_id'], 'item_cnt_day', 'date_block_num', aggfunc = np.sum, fill = 0 )
DEBUG = False<train_on_grid>
shops_items_sales_temp = pairs_sales.sample(1000)
 pairs_acf = np.zeros(( shops_items_sales_temp.shape[0], time_shift + 1))
for i,(ind, shop_item_sales)in enumerate(shops_items_sales_temp.iterrows()):
pair = shop_item_sales.loc['0': ]
acf_12 = acf(pair, nlags = time_shift, fft = True)
 pairs_acf[i, :] = acf_12
ITER = 1
SCORES = []
MINUTES = time.time()
if DEBUG == True:
init_pt = 1
n_iter_pt = 2
PT_GRAPH = 3
else:
init_pt = 10
n_iter_pt = 100
PT_GRAPH = 10
def lgb_evaluate(
 numLeaves,
maxDepth,
minChildWeight,
subsample,
colsample_bytree,
learn_rate,
reg_alpha,
reg_lambda,
min_split_gain):
global ITER, SCORES, MINUTES
clf = LGBMClassifier(
 nthread=4,
n_estimators=100,
verbose =-1,
silent=-1,
num_leaves= int(numLeaves),
max_depth= int(maxDepth),
min_child_weight= minChildWeight,
colsample_bytree= colsample_bytree,
subsample= subsample,
learning_rate= learn_rate,
reg_alpha = reg_alpha,
reg_lambda= reg_lambda,
min_split_gain= min_split_gain 
)
 scores = cross_val_score(clf, train_x, train_y, cv=5, scoring='roc_auc')
 print("Mean cross validation score: {}".format(np.mean(scores)))
 SCORES.append(np.mean(scores))
if ITER % PT_GRAPH == 0:
plt.figure(figsize=(11,4))
plt.plot(range(len(SCORES)) , SCORES)
 plt.scatter(SCORES.index(max(SCORES)) , max(SCORES), color='red')
 plt.ylabel("Score")
 plt.xlabel("Attempt")
 plt.title("Real time evolution of the mean score")
 plt.show()
print("Minutes since beginning: {}".format(float(time.time() - MINUTES)/ 60))
ITER = ITER + 1
return np.mean(scores)
 lgbBO = BayesianOptimization(lgb_evaluate, {
'numLeaves':(5, 50),
'maxDepth':(2, 63),
'minChildWeight':(0.01, 70),
'subsample':(0.4, 1),
'colsample_bytree':(0.4, 1),
'learn_rate':(0.1, 1),
'reg_alpha':(0, 1),
'reg_lambda':(0, 1),
'min_split_gain':(0, 1)
 })
 lgbBO.maximize(init_points=init_pt, n_iter=n_iter_pt )<prepare_output>
pair_lags = [1, 2, 3, 4, 8, 10, 11, 12]
best = max([lgbBO.res[i]['target'] for i in range(len(lgbBO.res)) ])
 best<sort_values>
del shops_items_sales_temp
del pairs_sales
del shop_item_sales
del pair
del acf_12
del pairs_acf
gc.collect()
best_index = [lgbBO.res[i]['target'] for i in range(len(lgbBO.res)) ].index(best)
 best_index<train_model>
items_sales = create_record_for_features(sales, ['item_id'], 'item_cnt_day', 'date_block_num', aggfunc = np.sum, fill = 0 )
param_dict = lgbBO.res[best_index]["params"]
clf = LGBMClassifier(
 nthread=4,
n_estimators=100,
silent=-1,
verbose=-1,
num_leaves=34,
colsample_bytree=param_dict["colsample_bytree"],
subsample=param_dict["subsample"],
max_depth=int(param_dict["maxDepth"]),
min_child_weight=param_dict["minChildWeight"],
learning_rate=param_dict["learn_rate"],
reg_alpha=param_dict["reg_alpha"],
reg_lambda=param_dict["reg_lambda"],
min_split_gain=param_dict["min_split_gain"])
 clf.fit(train_x, train_y )<compute_test_metric>
items_acf = np.zeros(( items_sales.shape[0], time_shift + 1))
for i, item_sales in items_sales.iterrows() :
item_temp = item_sales.loc['0': ]
if np.sum(item_temp)!= 0:
acf_12 = acf(item_temp, nlags = time_shift, fft = True)
 items_acf[i, :] = acf_12
print(metrics.auc(fpr, tpr))<create_dataframe>
item_lags = [1, 2, 3, 4, 5, 10, 11, 12]
importance_df = pd.DataFrame()
importance_df["feature"] = feats
importance_df["importance"] = clf.feature_importances_
importance_df = importance_df.sort_values(by='importance', ascending=False)
 importance_df = importance_df.reset_index(drop=True )<compute_test_metric>
del items_sales
del item_sales
del items_acf
del item_temp
del acf_12
del avgs
gc.collect()
display_importances(importance_df )<find_best_params>
shops_sales = create_record_for_features(sales, ['shop_id'], 'item_cnt_day', 'date_block_num', aggfunc = np.sum, fill = 0)
 shops_acf = np.zeros(( shops_sales.shape[0], time_shift + 1))
for i, shop_sales in shops_sales.iterrows() :
shop_temp = shop_sales.loc['0': ]
acf_12 = acf(shop_temp, nlags = time_shift, fft = True)
 shops_acf[i, :] = acf_12
best_feature = importance_df.loc[0:30, "feature"].values<concatenate>
shop_lags = [1, 2, 3, 4, 7, 8, 10, 12]
values_x = pd.concat([train_x, test_x])
 values_y = pd.concat([train_y, test_y] )<train_model>
del shops_sales
del shop_sales
del shops_acf
del shop_temp
del acf_12
del avgs
gc.collect()
param_dict = lgbBO.res[best_index]["params"]
clf = LGBMClassifier(
 nthread=4,
n_estimators=100,
silent=-1,
verbose=-1,
num_leaves=34,
colsample_bytree=param_dict["colsample_bytree"],
subsample=param_dict["subsample"],
max_depth=int(param_dict["maxDepth"]),
min_child_weight=param_dict["minChildWeight"],
learning_rate=param_dict["learn_rate"],
reg_alpha=param_dict["reg_alpha"],
reg_lambda=param_dict["reg_lambda"],
min_split_gain=param_dict["min_split_gain"])
 clf.fit(values_x, values_y )<load_pretrained>
categories_sales = create_record_for_features(sales, ['item_category_id'], 'item_cnt_day', 'date_block_num', aggfunc = np.sum, fill = 0)
 categories_acf = np.zeros(( categories_sales.shape[0], time_shift + 1))
for i, category_sales in categories_sales.iterrows() :
category_temp = category_sales.loc['0': ]
acf_12 = acf(category_temp, nlags = time_shift, fft = True)
 categories_acf[i, :] = acf_12
filename = 'clf.sav'
pickle.dump(clf, open(filename, 'wb'))<predict_on_test>
category_lags = [1, 2, 3, 4, 5, 6, 12]
y_pred_proba = clf.predict_proba(df_submission)[:, 1]
df_results = pd.DataFrame(columns =['SK_ID_CURR', 'TARGET'])
 df_results['SK_ID_CURR'] = main_id_submission
df_results['TARGET'] = y_pred_proba<save_to_csv>
del categories_sales
del category_sales
del categories_acf
del category_temp
del acf_12
del avgs
gc.collect()
df_results.to_csv("submission.csv", index=False )<import_modules>
start = time.time()
grid = create_train_set(sales, index_cols)
 test['date_block_num'] = 34
grid = pd.concat([grid, test[['item_id', 'shop_id', 'date_block_num']]], ignore_index = True, sort = False, keys = index_cols)
 grid = grid.merge(items[['item_id', 'item_category_id']], on = 'item_id', how = 'left')
 print(round(time.time() - start), 'seconds' )
np.random.seed(1337)
<load_from_disk>
def lag_features(df, features, go_back_in_time):
for month_shift in go_back_in_time:
df_shift = df[index_cols + features].copy()
df_shift['date_block_num'] = df_shift['date_block_num'] + month_shift
lag_cols = lambda x: '{}_lag_{}'.format(x, month_shift)if x in features else x
df_shift = df_shift.rename(columns = lag_cols)
 df = pd.merge(df, df_shift, on = index_cols, how='left')
 return df
def fast_lag_features(df, features, go_back_in_time):
features_sales = create_record_for_features(sales, features, 'item_cnt_day', 'date_block_num', aggfunc = np.sum, fill = 0)
 for month in go_back_in_time:
max_month = df.date_block_num.max()
cols = [str(itr)for itr in np.arange(0, max_month)]
gb = features_sales.melt(id_vars = features,
var_name = 'date_block_num' ,
value_vars= cols,
value_name = 'target_' + '_'.join(features)+ '_lag_' + str(month)
)
 gb.date_block_num = gb.date_block_num.astype(np.int16)
 gb.date_block_num = gb.date_block_num + month
df = pd.merge(df, gb, on = features + ['date_block_num'], how='left')
 return df
df_train = pd.read_json('.. /input/train.json' )<normalization>
start = time.time()
grid = lag_features(grid, ['target'], pair_lags)
 print(round(time.time() - start), 'seconds' )
def get_scaled_imgs(df):
imgs = []
for i, row in df.iterrows() :
band_1 = np.array(row['band_1'] ).reshape(75, 75)
 band_2 = np.array(row['band_2'] ).reshape(75, 75)
 band_3 = band_1 + band_2
a =(band_1 - band_1.mean())/(band_1.max() - band_1.min())
 b =(band_2 - band_2.mean())/(band_2.max() - band_2.min())
 c =(band_3 - band_3.mean())/(band_3.max() - band_3.min())
 imgs.append(np.dstack(( a, b, c)))
 return np.array(imgs )<normalization>
start = time.time()
grid = fast_lag_features(grid, ['item_id'], item_lags)
 print(round(time.time() - start), 'seconds' )
Xtrain = get_scaled_imgs(df_train )<prepare_x_and_y>
start = time.time()
grid = fast_lag_features(grid, ['shop_id'], shop_lags)
 print(round(time.time() - start), 'seconds' )
Ytrain = np.array(df_train['is_iceberg'] )<define_variables>
start = time.time()
grid = fast_lag_features(grid, ['item_category_id'], category_lags)
 print(round(time.time() - start), 'seconds' )
df_train.inc_angle = df_train.inc_angle.replace('na',0)
 idx_tr = np.where(df_train.inc_angle>0 )<drop_column>
grid.isnull().sum()
Ytrain = Ytrain[idx_tr[0]]
Xtrain = Xtrain[idx_tr[0],...]<categorify>
grid = grid[grid['date_block_num'] > 11]
grid = grid.fillna(0 )
Xtr_more = get_more_images(Xtrain )<concatenate>
dates_train = sales.loc[:, ['date', 'date_block_num']].drop_duplicates()
dates_train = dates_train.reset_index(drop = True)
 dates_test = dates_train.loc[dates_train.loc[:, 'date_block_num'] == 34 - 12]
dates_test = dates_test.reset_index(drop=True)
 dates_test.loc[:,'date_block_num'] = 34
dates_test.loc[:, 'date'] = dates_test.loc[:, 'date'] + pd.DateOffset(years = 1)
 dates_all = pd.concat([dates_train, dates_test])
 dates_all.loc[:, 'dow'] = dates_all.loc[:, 'date'].dt.dayofweek
dates_all.loc[:, 'year'] = dates_all.loc[:, 'date'].dt.year
dates_all.loc[:, 'month'] = dates_all.loc[:, 'date'].dt.month
dates_all = pd.get_dummies(dates_all, columns = ['dow'])
 dow_col = ['dow_' + str(x)for x in range(7)]
date_features = dates_all.groupby(['year', 'month', 'date_block_num'])[dow_col].agg('sum' ).reset_index()
date_features.loc[:, 'days_of_month'] = date_features.loc[:, dow_col].sum(axis=1)
 date_features.loc[:, 'year'] = date_features.loc[:, 'year'] - 2013
date_features = date_features.loc[:, ['month', 'date_block_num']]
Ytr_more = np.concatenate(( Ytrain,Ytrain,Ytrain))<choose_model_class>
grid = grid.merge(date_features, on = 'date_block_num', how = 'left' )
def getModel() :
model=Sequential()
model.add(Conv2D(64, kernel_size=(3, 3),activation='relu', input_shape=(75, 75, 3)))
 model.add(MaxPooling2D(pool_size=(3, 3), strides=(2, 2)))
 model.add(Dropout(0.2))
model.add(Conv2D(128, kernel_size=(3, 3), activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2), strides=(2, 2)))
 model.add(Dropout(0.2))
model.add(Conv2D(128, kernel_size=(3, 3), activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2), strides=(2, 2)))
 model.add(Dropout(0.2))
model.add(Conv2D(64, kernel_size=(3, 3), activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2), strides=(2, 2)))
 model.add(Dropout(0.2))
model.add(Flatten())
 model.add(Dense(512, activation='relu'))
model.add(Dropout(0.2))
model.add(Dense(256, activation='relu'))
model.add(Dropout(0.2))
model.add(Dense(1, activation="sigmoid"))
optimizer = Adam(lr=0.001, decay=0.0)
 model.compile(loss='binary_crossentropy', optimizer=optimizer, metrics=['accuracy'])
 return model<choose_model_class>
del dates_train
del dates_test
del dates_all
del dow_col
del date_features
gc.collect()
model = getModel()
model.summary()
batch_size = 32
earlyStopping = EarlyStopping(monitor='val_loss', patience=10, verbose=0, mode='min')
 mcp_save = ModelCheckpoint('.mdl_wts.hdf5', save_best_only=True, monitor='val_loss', mode='min')
 reduce_lr_loss = ReduceLROnPlateau(monitor='val_loss', factor=0.1, patience=7, verbose=1, epsilon=1e-4, mode='min' )<train_model>
grid['category_shop_inter'] = grid['item_category_id'].astype(str)+ '_' + grid['shop_id'].astype(str)
 grid.loc[:, 'category_shop_inter'] = LabelEncoder().fit_transform(grid.loc[:, 'category_shop_inter'].values )
model.fit(Xtr_more, Ytr_more, batch_size=batch_size, epochs=50, verbose=1, callbacks=[earlyStopping, mcp_save, reduce_lr_loss], validation_split=0.25 )<train_model>
cols_to_drop = ['target', 'date_block_num']
def train_val_test_split(df):
dates = df['date_block_num']
last_block = dates.max()
print('Test `date_block_num` is %d' % last_block)
 print('Validation `date_block_num` is %d' %(last_block - 1))
print('Train `date_block_num` is < %d' %(last_block - 1))
print('------------------------------')
 X_train = df.loc[dates < last_block - 1].drop(cols_to_drop, axis = 1)
 X_val = df.loc[dates == last_block - 1].drop(cols_to_drop, axis = 1)
 X_test = df.loc[dates == last_block].drop(cols_to_drop, axis = 1)
 y_train = df.loc[dates < last_block - 1, 'target'].values
y_val = df.loc[dates == last_block - 1, 'target'].values
print('X_train shape: ', X_train.shape)
 print('y_train shape: ', y_train.shape)
 print('------------------------------')
 print('X_val shape: ', X_val.shape)
 print('y_val shape: ', y_val.shape)
 print('------------------------------')
 print('X_test shape: ', X_test.shape)
 print('------------------------------')
 return(X_train, y_train, X_val, y_val, X_test)
 def rmse(y, y_hat):
return np.sqrt(mean_squared_error(y, y_hat))
def create_lgbm_model(X_train, y_train, X_val, y_val, params, cat_feats):
n_estimators = 8000
d_train = lgb.Dataset(X_train, y_train)
 d_valid = lgb.Dataset(X_val, y_val)
 watchlist = [d_train, d_valid]
evals_result = {}
model = lgb.train(params,
d_train,
n_estimators,
valid_sets = watchlist,
evals_result = evals_result,
early_stopping_rounds = 50,
verbose_eval = 0,
categorical_feature = cat_feats, 
)
 lgb.plot_metric(evals_result)
 return model
def evaluate_model(model, X_train, y_train, X_val, y_val):
y_hat = model.predict(X_train)
 print('Training error;', rmse(y_train, y_hat))
y_val_hat = model.predict(X_val)
 print('Validation error:', rmse(y_val, y_val_hat))
model.load_weights(filepath = '.mdl_wts.hdf5')
 score = model.evaluate(Xtrain, Ytrain, verbose=1)
 print('Train score:', score[0])
 print('Train accuracy:', score[1] )<save_to_csv>
categorical_features = ['shop_id', 'item_category_id', 'month', 'category_shop_inter']
for col in categorical_features:
grid.loc[:, col] = grid[col].astype('category' )
df_test = pd.read_json('.. /input/test.json')
 df_test.inc_angle = df_test.inc_angle.replace('na',0)
 Xtest =(get_scaled_imgs(df_test))
pred_test = model.predict(Xtest)
 submission = pd.DataFrame({'id': df_test["id"], 'is_iceberg': pred_test.reshape(( pred_test.shape[0])) })
 print(submission.head(10))
submission.to_csv('submission.csv', index=False )<feature_engineering>
X_train, y_train, X_val, y_val, X_test = train_val_test_split(grid )
def Individual1(data):
p =(((np.cos(((data["Medical_History_40"] + data["Medical_Keyword_3"])/2.0)) +(( data["Medical_History_23"] >=(-(data["Medical_History_4"])) ).astype(float)))- np.maximum(( data["BMI"]),(np.tanh(( np.tanh(data["SumMedicalKeywords"])-(data["Product_Info_4"] - data["Medical_Keyword_3"])))))) + 
(np.tanh(((data["Medical_History_20"] +(( data["InsuredInfo_6"] +(((data["Medical_History_15"] -(data["InsuredInfo_7"] + data["Insurance_History_2"])) - data["Medical_History_30"])- data["Medical_History_5"])) /2.0)) /2.0)) -(( np.ceil(data["Product_Info_4"])< data["InsuredInfo_5"] ).astype(float)))+
np.tanh(((((data["Medical_History_11"] +(( data["Medical_History_27"] + np.maximum(( data["Medical_Keyword_41"]),(data["Family_Hist_4"])))/2.0)) /2.0)+(((( np.sin(np.ceil(data["Product_Info_2_N"])) + data["Insurance_History_5"])/2.0)+(((data["Medical_History_13"] - data["Medical_History_18"])+ data["Family_Hist_2"])/2.0)) /2.0)) /2.0)) + 
(( data["Medical_History_35"] * data["InsuredInfo_2"])+(-(((data["Medical_Keyword_38"] >=(-(((( data["Ins_Age"] * data["Medical_History_31"])+(( data["Medical_History_31"] <=(( data["Medical_History_7"] <= np.minimum(( data["Medical_History_28"]),(data["Employment_Info_3"])) ).astype(float)) ).astype(float)))/2.0)))).astype(float)))))+
np.minimum(( 0.318310),(np.maximum(((data["Medical_History_15"] *(( 0.138462 <(data["Medical_History_23"] + np.minimum(( data["Medical_History_15"]),(0.318310)))).astype(float)))) ,(np.maximum(( np.minimum(( data["Medical_History_4"]),(((data["Medical_History_24"] >= data["Medical_History_23"] ).astype(float))))),(data["Medical_History_15"])))))) + 
(((( data["Medical_History_38"] <= data["Medical_History_24"] ).astype(float)) + np.sin(np.minimum(((( np.maximum(( data["Medical_History_4"]),(data["Medical_History_23"])) +(data["Medical_History_4"] / 2.0)) /2.0)) ,(( np.minimum(( data["Medical_History_11"]),(( data["Product_Info_2_N"] + np.abs(data["Product_Info_2_C"])))) * 2.0)))))/2.0)+ 
(0.094340 *(np.maximum(( data["Medical_Keyword_25"]),(np.tanh(data["SumMedicalKeywords"])))-(((data["InsuredInfo_1"] -(( data["Medical_Keyword_22"] + data["Medical_Keyword_33"])/2.0)) - np.minimum(( data["Medical_History_17"]),(data["SumEmploymentInfo"])))-(( data["Medical_History_1"] + data["Medical_History_33"])/2.0)))) +
np.tanh(( data["Medical_History_5"] *(((-(( data["Medical_History_3"] +(( data["Medical_History_23"] > np.tanh(data["BMI"])).astype(float)))))+(((data["Medical_Keyword_9"] -(( data["Medical_History_4"] > data["BMI"] ).astype(float)))- data["Medical_Keyword_19"])- data["Medical_History_6"])) /2.0)))+ 
(((( 0.094340 *(np.minimum(( data["Medical_Keyword_3"]),(((data["BMI"] + data["SumMedicalKeywords"])/2.0)))* 2.0)) * np.abs(data["BMI"])) +(( np.round(( 1.0/(1.0 + np.exp(- np.sin(data["Medical_History_11"])))))<= np.minimum(( data["BMI"]),(data["Ins_Age"])) ).astype(float)))/2.0)+ 
(np.minimum(( np.tanh(data["Medical_History_31"])) ,(np.maximum(((data["Product_Info_4"] *(( data["BMI"] +(( data["Wt"] + 0.693147)/2.0)) /2.0))),(np.minimum(( data["Medical_History_1"]),(((data["Wt"] +(data["SumNAs"] / 2.0)) /2.0)))))))/ 2.0)+ 
(((data["Medical_History_15"] + data["Medical_History_4"])/2.0)*(((np.sin(( data["Medical_History_4"] *(( data["Medical_History_15"] > np.sinh(data["Employment_Info_5"])).astype(float)))) * data["Medical_History_15"])> data["Product_Info_3"] ).astype(float)))+ 
(0.367879 -(1.0/(1.0 + np.exp(-(((data["Medical_History_40"] +(( data["Ins_Age"] + data["Insurance_History_8"])/2.0)) /2.0)-(( data["Medical_History_4"] <=(( data["Medical_History_23"] <=(( data["BMI"] <=(1.0/(1.0 + np.exp(- data["Medical_History_40"])))).astype(float)) ).astype(float)) ).astype(float)))))))+
np.minimum(( np.minimum(( np.minimum(( 0.058823),(((( data["Employment_Info_1"] +(( data["Insurance_History_3"] < np.maximum(( data["Ins_Age"]),(data["SumMedicalKeywords"])) ).astype(float)))/2.0)/ 2.0)))) ,(np.round(np.round(np.maximum(( data["Medical_History_23"]),(data["SumMedicalKeywords"]))))))),(np.maximum(( data["Medical_History_39"]),(data["SumMedicalKeywords"])))) + 
(np.minimum(( np.tanh(((-(data["SumNAs"])) * np.minimum(( data["Medical_History_22"]),(data["Insurance_History_2"]))))),(data["Medical_Keyword_39"])) *(((((data["Medical_Keyword_2"] - data["Medical_History_19"])- data["Employment_Info_2"])- data["Employment_Info_2"])<= data["Medical_Keyword_37"] ).astype(float)))+ 
(0.138462 *(((((np.maximum(( data["Medical_History_21"]),(data["InsuredInfo_7"])) - data["InsuredInfo_2"])+ data["Medical_History_6"])/2.0)+ np.round(((( data["Product_Info_2_N"] <= data["SumMedicalKeywords"] ).astype(float)) *(((data["Family_Hist_3"] >= data["Ins_Age"] ).astype(float)) - data["Product_Info_4"])))) /2.0)) +
np.sin(np.sinh(np.minimum(( data["Medical_History_11"]),(np.sin(( data["Medical_History_5"] *(((( np.ceil(data["Medical_History_19"])+(( data["Medical_Keyword_9"] + data["Product_Info_1"])/2.0)) /2.0)>(data["SumMedicalHistory"] + np.sinh(0.720430)) ).astype(float)))))))) + 
(0.058823 *(((np.maximum(( np.maximum(( np.maximum(( data["Medical_Keyword_45"]),(np.maximum(( data["Medical_Keyword_34"]),(data["Medical_History_32"]))))),(data["Medical_Keyword_2"]))),(( data["Medical_Keyword_3"] * data["Medical_History_30"])))+ data["Product_Info_4"])+(data["Medical_Keyword_3"] * data["InsuredInfo_6"])) / 2.0)) +
np.minimum(((data["InsuredInfo_1"] * np.minimum(((data["Medical_History_20"] *(0.693147 -(1.0/(1.0 + np.exp(- np.cos(data["Insurance_History_5"]))))))),(( np.maximum(( data["Insurance_History_5"]),(( -(data["Insurance_History_3"])))) - data["Insurance_History_3"]))))),(( data["Insurance_History_5"] * data["Insurance_History_3"])))+
np.sin(( np.maximum(( data["Medical_History_28"]),(( data["Medical_History_24"] *(( data["Medical_Keyword_36"] + np.floor(( -(data["Medical_History_10"])))) /2.0)))) *(((( data["Medical_History_13"] >= data["Medical_History_10"] ).astype(float)) <= np.tanh(data["Medical_History_39"])).astype(float)))) +
np.tanh(((data["BMI"] *(((((data["InsuredInfo_7"] >= np.ceil(data["Product_Info_4"])).astype(float)) >= np.sin(np.maximum(((((( data["Ins_Age"] + data["InsuredInfo_2"])/2.0)< data["Medical_History_4"] ).astype(float))),(data["Medical_History_15"])))).astype(float)) / 2.0)) / 2.0)) +
np.minimum(( np.sin(( data["SumMedicalKeywords"] * np.tanh(((np.ceil(data["Product_Info_4"])<=(( data["Medical_History_30"] + data["Medical_History_18"])/2.0)).astype(float)))))) ,(( data["Product_Info_1"] *(( data["BMI"] >(( data["Medical_History_18"] < np.round(data["Medical_Keyword_9"])).astype(float)) ).astype(float)))))+
np.minimum(((0.138462 *(( data["Medical_History_1"] >= data["Medical_History_18"] ).astype(float)))) ,(np.tanh(((((((((data["Medical_History_1"] >= data["Medical_History_1"] ).astype(float)) <= data["Family_Hist_3"] ).astype(float)) +(( data["Medical_History_37"] <= np.floor(np.abs(data["Product_Info_2_N"])) ).astype(float)))/2.0)+ data["Medical_Keyword_27"])/2.0)))) +
np.minimum(( 0.094340),(( np.cos(data["Employment_Info_2"])* np.tanh(((data["Employment_Info_2"] >(( data["Medical_History_23"] <=(np.sin(( data["InsuredInfo_6"] - data["Medical_History_15"])) - data["Medical_History_39"])).astype(float)) ).astype(float)))))) +
np.minimum(((( data["Medical_History_15"] +(( data["Medical_Keyword_1"] >(( data["Medical_History_15"] +(( data["Medical_History_4"] >(( data["Medical_Keyword_10"] > data["Medical_Keyword_23"] ).astype(float)) ).astype(float)))/2.0)).astype(float)))/2.0)) ,(((((data["Medical_History_15"] > 8.0 ).astype(float)) >= np.maximum(( data["Medical_History_4"]),(data["Medical_History_15"])) ).astype(float)))) +
np.minimum(((np.sin(( data["Product_Info_5"] * np.ceil(((data["InsuredInfo_6"] * np.minimum(((data["Medical_History_4"] - data["Medical_Keyword_3"])) ,(data["Insurance_History_3"])))+ data["Medical_History_40"])))) / 2.0)) ,(((np.ceil(data["Medical_History_4"])< 0.094340 ).astype(float)))) +
np.sin(np.minimum(((( data["Insurance_History_2"] >= data["Medical_History_20"] ).astype(float))),(np.maximum(( data["Medical_Keyword_3"]),(( np.tanh(data["Medical_Keyword_24"])* np.minimum(((( data["Medical_History_4"] - data["Medical_Keyword_46"])+(data["Product_Info_3"] +(-(data["BMI"]))))),(data["Insurance_History_2"])))))))) +
np.minimum(((np.cos(np.maximum(((int(0.138462 >= 0.138462))),(np.minimum(( data["Ht"]),(2.212120)))))/ 2.0)) ,(((( data["SumMedicalKeywords"] + np.round(data["Ins_Age"])) /2.0)*(( data["Medical_History_5"] >=(( data["Medical_History_17"] + data["Medical_History_20"])/2.0)).astype(float)))))+ 
(np.minimum(((( data["Medical_History_38"] > data["Ins_Age"] ).astype(float))),(( 0.730769 -(1.0/(1.0 + np.exp(- np.maximum(( data["Employment_Info_1"]),(np.maximum(( np.maximum(( data["Medical_Keyword_47"]),(((data["Medical_History_38"] + data["Medical_History_12"])/2.0)))) ,(np.maximum(( data["Ins_Age"]),(np.cos(data["InsuredInfo_1"])))))))))))))/ 2.0)+ 
(np.ceil(data["Medical_History_4"])*(0.094340 * np.ceil(((((np.maximum(( data["Medical_Keyword_39"]),(( data["Product_Info_3"] * np.maximum(((data["Medical_History_23"] * 2.0)) ,(data["Medical_Keyword_21"])))))> data["Medical_History_23"] ).astype(float)) - np.ceil(data["InsuredInfo_2"])) / 2.0)))) + 
(np.round(np.minimum(((-(((data["Insurance_History_5"] >(( data["Insurance_History_7"] < np.tanh(((data["Insurance_History_5"] +(data["Medical_History_20"] * data["Medical_Keyword_31"])) /2.0)) ).astype(float)) ).astype(float))))),(((((2.409090 >= data["Ins_Age"] ).astype(float)) - data["InsuredInfo_6"])/ 2.0)))) * 2.0)+
np.maximum(( np.sinh(((np.cos(( data["Ht"] / 2.0)) < np.minimum(( data["Medical_Keyword_14"]),(data["Medical_Keyword_34"])) ).astype(float)))) ,(np.minimum(((( data["Medical_Keyword_32"] > np.minimum(((data["SumInsuredInfo"] + 1.584910)) ,(np.cos(data["Medical_Keyword_39"])))).astype(float))),(( data["Product_Info_2_C"] / 2.0)))))+ 
(( np.minimum(( data["Medical_History_10"]),(data["Medical_Keyword_14"])) >(-(((data["Medical_History_5"] *(data["Medical_History_5"] *(( data["InsuredInfo_6"] >= data["InsuredInfo_3"] ).astype(float)))) *(( data["InsuredInfo_3"] >=(data["SumEmploymentInfo"] +(data["Insurance_History_2"] + data["Medical_History_30"])) ).astype(float)))))).astype(float)) + 
(np.minimum(( np.maximum(((( data["InsuredInfo_2"] > np.maximum(( data["Medical_Keyword_25"]),(data["Medical_History_13"])) ).astype(float))),(data["Medical_Keyword_46"]))),(data["Medical_History_28"])) *(( data["InsuredInfo_2"] >= np.ceil(((( data["Medical_History_18"] *(-(data["InsuredInfo_1"])))+ data["Medical_History_22"])/2.0)) ).astype(float)))+
np.tanh(( data["Insurance_History_2"] *(( data["Medical_History_19"] -(data["Medical_Keyword_44"] - data["Medical_Keyword_31"])) *(((data["Medical_Keyword_17"] * data["Medical_History_20"])>(data["Medical_Keyword_17"] *(data["Medical_Keyword_30"] *(( data["Medical_Keyword_32"] > data["Medical_Keyword_39"] ).astype(float)))) ).astype(float)))))+ 
(-(np.minimum(((( data["Medical_History_27"] <= np.sin(( data["Medical_Keyword_21"] + data["Medical_History_10"])) ).astype(float))),(((data["Medical_Keyword_27"] >=(( -(np.round(np.minimum(( np.minimum(( data["Medical_History_15"]),(data["Medical_History_3"]))),(( data["Ins_Age"] / 2.0)))))) * 2.0)).astype(float)))))) +
np.maximum(( np.minimum(( data["InsuredInfo_5"]),(((data["Medical_Keyword_42"] > data["Medical_History_6"] ).astype(float))))),(( np.sin(np.maximum(( np.maximum(((( 2.212120 <=(data["SumNAs"] -(( data["Medical_Keyword_42"] > data["Employment_Info_2"] ).astype(float)))).astype(float))),(np.ceil(data["Medical_Keyword_26"])))) ,(data["Medical_Keyword_27"])))/ 2.0)))+ 
(((( data["Family_Hist_3"] >(( data["Medical_History_33"] +(5.428570 +(( data["Wt"] +(( data["Product_Info_3"] <= data["Product_Info_7"] ).astype(float)))/2.0)))/2.0)).astype(float)) +(( data["Family_Hist_2"] <(data["Ins_Age"] -(5.200000 + data["Family_Hist_1"])) ).astype(float)))/2.0)+ 
(np.maximum(( data["Medical_History_4"]),(( -(data["Medical_Keyword_5"])))) *(-(((np.tanh(((data["InsuredInfo_5"] + data["Medical_History_40"])/2.0)) > np.cos(((( np.minimum(( 9.869604),(data["Medical_Keyword_26"])) >= data["InsuredInfo_6"] ).astype(float)) / 2.0)) ).astype(float)))))+
np.floor(np.cos(((((data["SumFamilyHistory"] < data["InsuredInfo_6"] ).astype(float)) + np.minimum(( data["Product_Info_3"]),(((np.floor(( data["Medical_Keyword_14"] *(-(((data["Product_Info_1"] >= data["Medical_History_14"] ).astype(float)))))) / 2.0)-(data["Product_Info_3"] * data["Medical_History_11"])))))/2.0)))+ 
(( np.ceil(np.maximum(( np.maximum(( np.round(data["Insurance_History_9"])) ,(data["Medical_History_11"]))),(data["Employment_Info_6"])))==(((((((data["Medical_History_35"] < data["Medical_Keyword_3"] ).astype(float)) * data["Medical_History_39"])+ data["Medical_Keyword_3"])/2.0)>(( data["Medical_History_10"] < data["Medical_History_11"] ).astype(float)) ).astype(float)) ).astype(float)) +
np.sin(((((((( data["Product_Info_7"] + data["Medical_Keyword_31"])/2.0)> data["Medical_Keyword_28"] ).astype(float)) > np.cos(data["Medical_Keyword_40"])).astype(float)) * np.maximum(( data["Medical_Keyword_42"]),(( np.maximum(( data["Medical_Keyword_42"]),(data["Medical_History_40"])) / 2.0)))))+ 
(((( data["Medical_History_8"] + data["Medical_History_28"])< data["Medical_Keyword_15"] ).astype(float)) * np.sinh(( 0.058823 -(0.434294 *(((((( data["Medical_History_12"] - data["Medical_History_30"])- data["Medical_Keyword_3"])>= data["Medical_History_39"] ).astype(float)) >= data["Medical_History_40"] ).astype(float)))))) + 
(( np.cos(data["Medical_History_19"])< np.maximum(((((( np.minimum(( np.minimum(( data["Medical_History_21"]),(data["Medical_History_19"]))),(data["Medical_History_18"])) > np.cos(np.maximum(( data["Medical_History_9"]),(data["Medical_History_7"])))).astype(float)) > np.cos(data["Insurance_History_2"])).astype(float))),(np.minimum(( data["Insurance_History_2"]),(data["Medical_History_9"])))) ).astype(float)) +
np.minimum(((((((( data["SumInsuredInfo"] >= np.maximum(( data["Insurance_History_7"]),(data["BMI"])) ).astype(float)) * data["Medical_Keyword_34"])> 1.570796 ).astype(float)) / 2.0)) ,(( np.cos(data["Medical_History_29"])+(((data["Medical_Keyword_32"] < np.floor(data["Employment_Info_4"])).astype(float)) * 2.0)))) + 
(((data["Medical_History_29"] >(1.0/(1.0 + np.exp(- np.sinh(((((((data["Medical_History_29"] > data["Medical_Keyword_41"] ).astype(float)) -(( data["Medical_Keyword_29"] +(( data["Medical_History_35"] + data["Medical_Keyword_6"])/2.0)) /2.0)) > data["InsuredInfo_4"] ).astype(float)) -(data["Medical_Keyword_10"] * data["Medical_Keyword_1"])))))) ).astype(float)) / 2.0)+ 
(((( data["Medical_History_1"] > data["Product_Info_5"] ).astype(float)) < np.minimum(( np.maximum(( data["Medical_History_40"]),(data["BMI"]))),(( np.maximum(( data["Medical_Keyword_21"]),(data["Medical_Keyword_33"])) *(((( data["Product_Info_7"] > np.maximum(( data["Medical_Keyword_31"]),(data["Medical_Keyword_31"])) ).astype(float)) > data["Medical_History_40"] ).astype(float)))))).astype(float)) +
np.minimum(((( data["Medical_History_33"] * np.floor(np.abs(((data["Ins_Age"] + np.minimum(((( np.minimum(( data["Medical_Keyword_2"]),(data["Insurance_History_9"])) > data["Medical_Keyword_24"] ).astype(float))),(data["Medical_Keyword_41"])))/2.0)))) / 2.0)) ,(( data["Medical_Keyword_28"] *(( data["Medical_History_21"] > data["Medical_Keyword_38"] ).astype(float)))))+
np.sin(((data["Employment_Info_5"] *(((((data["Medical_History_19"] >(data["Medical_Keyword_6"] * data["Ins_Age"])).astype(float)) + data["Medical_History_32"])>(( data["Employment_Info_5"] > data["Medical_History_19"] ).astype(float)) ).astype(float)))*(( data["Medical_Keyword_6"] < data["Product_Info_4"] ).astype(float)))) +
np.maximum(( np.sin(np.minimum(( data["InsuredInfo_1"]),(((data["Medical_Keyword_8"] > data["Medical_History_40"] ).astype(float)))))) ,(( data["InsuredInfo_1"] * np.tanh(np.ceil(( -(( data["Medical_History_6"] *(( data["Medical_Keyword_48"] <= np.maximum(( data["Medical_History_5"]),(data["Product_Info_1"])) ).astype(float)))))))))) +
np.ceil(np.sin(np.round(np.maximum(( np.maximum(((data["Medical_Keyword_28"] * data["Medical_Keyword_20"])) ,(((data["Family_Hist_4"] * data["Medical_Keyword_43"])- data["Medical_Keyword_46"])))) ,(np.sinh(np.minimum(( data["Medical_Keyword_19"]),(((data["Medical_History_5"] >= np.cos(data["Medical_Keyword_26"])).astype(float)))))))))) +
np.tanh(( -(( data["Medical_Keyword_4"] *(( data["Medical_Keyword_23"] <=(data["InsuredInfo_7"] -(((data["Medical_Keyword_14"] * data["Medical_Keyword_15"])<(((data["Medical_History_37"] - data["Medical_Keyword_23"])<(( data["Medical_History_22"] > data["Medical_Keyword_12"] ).astype(float)) ).astype(float)) ).astype(float)))).astype(float)))))) +
np.minimum(( 0.138462),(((( np.abs(data["Ins_Age"])/ 2.0)>=(((( data["Ins_Age"] < np.round(((( data["Medical_History_12"] <= 0.730769 ).astype(float)) +(( data["InsuredInfo_3"] >= data["Medical_Keyword_10"] ).astype(float)))) ).astype(float)) != np.abs(np.floor(data["Product_Info_2_C"])) ).astype(float)) ).astype(float)))) +
np.sin(np.maximum(( data["Medical_Keyword_43"]),(( 0.094340 * np.minimum(((((data["Medical_Keyword_15"] < data["Medical_History_32"] ).astype(float)) +(data["Medical_History_26"] *(( data["Insurance_History_8"] <= data["Product_Info_2_C"] ).astype(float))))),(( data["BMI"] * np.tanh(data["Product_Info_4"])))))))) + 
(((((data["Medical_Keyword_41"] >= data["SumMedicalKeywords"] ).astype(float)) *(-(((((data["Medical_History_12"] >(data["Medical_Keyword_38"] * data["Medical_History_1"])).astype(float)) > np.sin(np.maximum(( np.cos(np.minimum(( data["Medical_History_13"]),(data["Medical_History_39"])))) ,(data["Medical_History_1"])))).astype(float)))))/ 2.0)/ 2.0)+
np.minimum(( np.maximum(( np.cos(data["Product_Info_2_N"])) ,(data["Medical_History_37"]))),(( 0.058823 *(((( data["Product_Info_2_N"] >= np.maximum(( 0.058823),(data["Medical_History_3"])) ).astype(float)) >= np.maximum(( np.maximum(( data["Product_Info_6"]),(data["SumInsuranceHistory"]))),(( data["Product_Info_2_N"] * data["Medical_History_4"])))).astype(float)))))+ 
(np.ceil(np.sin(((( np.minimum(( data["Medical_Keyword_38"]),(data["Medical_Keyword_13"])) >(1.0/(1.0 + np.exp(- data["Medical_History_7"])))).astype(float)) + np.minimum(( data["Medical_History_28"]),(((data["Medical_Keyword_38"] + data["Medical_Keyword_5"])*(1.0/(1.0 + np.exp(-(data["Medical_History_7"] + data["Product_Info_2_N"])))))))))) * 2.0)+ 
(data["BMI"] *(np.ceil(( data["Ins_Age"] -(( data["Insurance_History_3"] > data["InsuredInfo_1"] ).astype(float)))) * np.abs(((0.058823 + np.minimum(( 0.138462),(((data["Ins_Age"] >=(( data["InsuredInfo_1"] <= data["Ins_Age"] ).astype(float)) ).astype(float)))))/2.0)))) + 
(( np.tanh(data["Medical_Keyword_40"])*(( data["Medical_Keyword_38"] * np.maximum(( data["Product_Info_4"]),(((np.maximum(( data["Product_Info_4"]),(((data["Medical_History_29"] >= data["SumMedicalKeywords"] ).astype(float)))) >= data["SumMedicalKeywords"] ).astype(float)))))* np.abs(((data["Medical_History_3"] + data["Medical_History_12"])/2.0)))) / 2.0)+
np.minimum(((-(np.minimum(( data["Medical_Keyword_33"]),(((np.sin(data["Medical_Keyword_33"])>= np.cos(data["Medical_History_24"])).astype(float))))))),(np.floor(np.cos(( np.sin(data["Medical_Keyword_46"])-(( data["Medical_Keyword_23"] >(data["Medical_Keyword_43"] * data["Medical_Keyword_47"])).astype(float)))))))+ 
(0.138462 * np.sin(((( np.maximum(( np.minimum(( data["BMI"]),(data["BMI"]))),(np.round(data["Medical_Keyword_43"])))==(( data["Product_Info_4"] > data["Medical_History_40"] ).astype(float)) ).astype(float)) * data["SumMedicalKeywords"])))+
np.round(( np.minimum(((data["Ht"] + data["Product_Info_5"])) ,(((data["Employment_Info_5"] +(( data["Medical_Keyword_6"] +(data["Medical_History_7"] +(( data["Medical_Keyword_13"] + data["Employment_Info_5"])/2.0)))/2.0)) /2.0)))*(( data["Product_Info_5"] >(data["Wt"] + 2.212120)).astype(float)))) + 
(((( data["Medical_History_9"] > data["Medical_History_41"] ).astype(float)) <= np.minimum(( data["InsuredInfo_5"]),(((np.maximum(( data["InsuredInfo_1"]),(((np.maximum(( data["Medical_Keyword_12"]),(( data["Medical_History_9"] * data["Medical_History_37"])))+(( data["BMI"] + data["Medical_Keyword_12"])/2.0)) /2.0)))+ data["Medical_Keyword_1"])/2.0)))).astype(float)) +
np.tanh(((data["Medical_Keyword_12"] - 0.367879)*(( data["Medical_History_39"] >=(( 1.0 > np.minimum(( data["Ins_Age"]),(( data["Medical_History_18"] - np.minimum(( data["Medical_Keyword_14"]),(( np.maximum(( data["Medical_Keyword_14"]),(data["Medical_History_39"])) - data["Medical_History_32"])))))) ).astype(float)) ).astype(float)))) + 
(( -(((((data["Insurance_History_7"] >=(( -(data["Insurance_History_4"])) / 2.0)).astype(float)) ==(( data["Insurance_History_9"] < np.minimum(( data["Medical_Keyword_41"]),(((np.tanh(data["Insurance_History_9"])+(data["Medical_Keyword_13"] / 2.0)) / 2.0)))).astype(float)) ).astype(float)))) * 2.0))
return p+4.5
def Individual2(data):
p =(((((( data["Product_Info_4"] + data["Medical_History_4"])> data["Medical_Keyword_3"] ).astype(float)) -(((( data["SumMedicalKeywords"] + np.maximum(( data["BMI"]),(data["Medical_Keyword_3"])))/2.0)+ data["BMI"])/2.0)) + np.sin(((data["Medical_History_23"] >(( data["Medical_Keyword_3"] + data["BMI"])/2.0)).astype(float)))) + 
(((((((( data["Medical_History_15"] - data["InsuredInfo_5"])- data["Medical_History_5"])+(( data["Family_Hist_4"] - data["Insurance_History_2"])- data["InsuredInfo_7"])) /2.0)+(( data["Medical_History_40"] +(-(data["Medical_History_30"])))/2.0)) /2.0)+(( data["Medical_History_15"] + data["Medical_History_4"])/2.0)) /2.0)+
np.tanh(np.minimum(((data["Medical_History_20"] + data["Medical_History_11"])) ,(((np.ceil(np.minimum(( data["Product_Info_4"]),(((data["Medical_History_7"] +(data["Medical_History_27"] +(-(data["Medical_Keyword_38"])))) /2.0)))) +(( data["BMI"] + np.maximum(( data["InsuredInfo_6"]),(data["Product_Info_4"])))/2.0)) /2.0)))) + 
(((( data["Medical_History_24"] >= data["Medical_Keyword_41"] ).astype(float)) +(((((np.minimum(((data["Employment_Info_2"] * np.round(data["Medical_History_28"]))),(data["Product_Info_2_N"])) + data["Medical_History_13"])+(( data["Medical_Keyword_41"] + data["Family_Hist_2"])/2.0)) /2.0)+(( data["Insurance_History_5"] + data["Medical_Keyword_25"])/2.0)) /2.0)) /2.0)+ 
(0.138462 *(data["SumMedicalKeywords"] +(((((( data["Medical_History_31"] - data["Medical_History_35"])-(data["Medical_History_18"] - data["Medical_Keyword_33"])) - data["InsuredInfo_1"])+ np.maximum(( data["Medical_History_21"]),(data["InsuredInfo_6"])))/2.0)- data["Ins_Age"])))+
np.minimum(((( np.sin(np.maximum(( data["InsuredInfo_2"]),(data["Medical_History_15"])))+(( np.tanh(((((data["Medical_History_1"] + data["Medical_History_3"])/2.0)+ data["Medical_History_33"])/2.0)) / 2.0)-(( data["InsuredInfo_2"] >= data["Medical_History_17"] ).astype(float)))) /2.0)) ,(np.cos(( -(data["Ins_Age"])))))+
np.minimum(( np.sin(np.maximum(( np.abs(data["Medical_History_11"])) ,(( data["Medical_Keyword_9"] * 2.0))))),(( np.sin(np.abs(np.maximum(( np.maximum(( data["Medical_Keyword_15"]),(data["SumNAs"]))),(data["Medical_History_11"])))) +(( np.abs(data["Family_Hist_4"])+ data["SumNAs"])/2.0)))) +
np.tanh(np.sin(((data["Medical_History_15"] <=(( np.sin(((((((np.sin(( data["Product_Info_2_N"] * 2.0)) >= 0.840000 ).astype(float)) >=(data["Medical_History_4"] / 2.0)).astype(float)) > np.abs(data["Product_Info_4"])).astype(float)))/ 2.0)- 0.840000)).astype(float)))) + 
(((data["Medical_Keyword_47"] <(( data["Medical_History_15"] + data["Medical_History_22"])/2.0)).astype(float)) * np.minimum(((( data["Medical_History_15"] == 0.094340 ).astype(float))),(((( data["Medical_History_15"] +(( data["BMI"] + data["Medical_History_15"])+ data["Medical_History_15"])) /2.0)+ data["Medical_History_15"])))) + 
(((((( data["Medical_History_1"] >= data["Medical_History_30"] ).astype(float)) / 2.0)+(-(((data["Medical_History_6"] <=(( np.cos(data["Wt"])<=(((( data["Medical_History_18"] <= np.ceil(data["Product_Info_4"])).astype(float)) <=(( data["Medical_History_6"] <= data["Medical_History_30"] ).astype(float)) ).astype(float)) ).astype(float)) ).astype(float)))))/2.0)/ 2.0)+ 
(((((1.0/(1.0 + np.exp(- np.floor(data["Medical_History_15"])))) >(np.abs(data["Medical_History_15"])+(( data["Product_Info_4"] >(( data["Family_Hist_5"] != data["BMI"] ).astype(float)) ).astype(float)))).astype(float)) +(( np.minimum(( data["Ins_Age"]),(data["BMI"])) >(( data["BMI"] != data["Family_Hist_2"] ).astype(float)) ).astype(float)))/2.0)+
np.minimum(( 0.585714),(np.maximum(( np.minimum(( data["InsuredInfo_6"]),(data["Medical_Keyword_3"]))),(( np.cos(data["Product_Info_2_C"])*(((( 0.318310 <=(( data["Medical_Keyword_41"] + np.abs(data["Product_Info_2_C"])) /2.0)).astype(float)) +(( data["Medical_History_10"] + data["Product_Info_2_N"])/2.0)) /2.0)))))) +
np.minimum(((( np.floor(((data["Family_Hist_3"] +(( np.floor(((data["BMI"] + data["Medical_History_19"])/2.0)) <= data["Medical_History_39"] ).astype(float)))/2.0)) / 2.0)/ 2.0)) ,(np.cos(( data["Product_Info_4"] -(1.0/(1.0 + np.exp(-(( data["BMI"] <= np.cos(data["Family_Hist_3"])).astype(float)))))))))+
np.minimum(((data["SumMedicalKeywords"] * np.sinh(((data["Medical_History_18"] > data["Medical_History_39"] ).astype(float))))),(np.minimum(((( data["Medical_History_5"] > data["Medical_History_20"] ).astype(float))),(( data["SumMedicalKeywords"] * np.sinh(((np.sinh(((data["Medical_History_5"] > data["Medical_History_17"] ).astype(float)))> data["Medical_History_20"] ).astype(float)))))))) +
np.maximum(((0.058823 * data["Family_Hist_2"])) ,(np.tanh(np.minimum(( 0.301030),(np.maximum(((((((data["Medical_Keyword_34"] + data["InsuredInfo_7"])/2.0)+(( data["Medical_Keyword_19"] > np.cos(np.minimum(( data["SumInsuredInfo"]),(data["InsuredInfo_7"])))).astype(float)))/2.0)/ 2.0)) ,(data["Medical_Keyword_45"])))))))+ 
(( data["Ins_Age"] * np.sin(( np.sin(np.minimum(( 0.367879),(np.minimum(( np.maximum(( data["Wt"]),(data["Medical_Keyword_23"]))),(np.cos(data["Medical_History_18"])))))) / 2.0)))/ 2.0)+
np.minimum(((( np.sin(data["Medical_History_22"])+(((np.sin(np.cos(data["Ins_Age"])) *(( data["Family_Hist_5"] + data["Medical_History_29"])/2.0)) + data["Medical_Keyword_2"])/2.0)) /2.0)) ,(( data["Family_Hist_5"] *(0.094340 * np.cos(data["SumNAs"])))))+ 
(((np.minimum(( data["Medical_Keyword_6"]),(((( data["Employment_Info_1"] + data["Employment_Info_5"])+(( data["Employment_Info_2"] > data["Insurance_History_8"] ).astype(float)))/ 2.0)))/ 2.0)+(np.minimum(( 0.094340),(((data["InsuredInfo_6"] > data["Insurance_History_8"] ).astype(float)))) * 2.0)) /2.0)+ 
(((data["SumMedicalKeywords"] *(( data["InsuredInfo_2"] >=(data["SumMedicalKeywords"] *(( data["Medical_History_30"] >= np.cos(( data["InsuredInfo_6"] +(data["Medical_Keyword_15"] + data["Medical_History_23"])))).astype(float)))).astype(float)))+ np.sin(((-(data["Medical_History_38"])) / 2.0)))/2.0)+
np.ceil(np.minimum(( np.maximum(( np.sin(np.minimum(((data["Medical_Keyword_46"] * 8.0)) ,(data["InsuredInfo_6"])))) ,(np.sinh(np.minimum(( data["Medical_Keyword_34"]),(data["Medical_Keyword_14"])))))) ,(( data["Insurance_History_5"] + data["Insurance_History_1"])))) +
np.floor(((( 1.0/(1.0 + np.exp(- data["Medical_History_32"])))+(np.tanh(data["BMI"])/ 2.0)) + np.round(( data["BMI"] * np.tanh(np.minimum(((data["Medical_History_11"] * data["Medical_History_5"])) ,(np.cos(( 1.0/(1.0 + np.exp(- data["InsuredInfo_5"])))))))))))+ 
(((np.maximum(( data["Wt"]),(data["Medical_History_28"])) - np.cos(( data["BMI"] * 2.0)))-(( data["Employment_Info_4"] > data["Medical_Keyword_25"] ).astype(float)))* np.minimum(( data["Medical_History_35"]),(((data["Insurance_History_5"] > data["Wt"] ).astype(float)))))+
np.sin(np.maximum(((( data["Medical_Keyword_25"] + np.minimum(( data["InsuredInfo_5"]),(data["Medical_Keyword_1"])))/2.0)) ,(np.maximum(( data["Medical_Keyword_25"]),(( data["Medical_Keyword_11"] *(( data["Medical_Keyword_43"] > np.sin(np.round(((np.maximum(( data["Medical_Keyword_25"]),(data["Product_Info_5"])) + data["Medical_History_7"])/2.0)))).astype(float)))))))) + 
(((-(np.floor(data["Product_Info_4"])))* 0.138462)*(np.sin(data["Medical_History_4"])* np.tanh(np.minimum(( np.minimum(( np.sin(data["Medical_Keyword_42"])) ,(data["Medical_History_1"]))),(np.round(data["Medical_History_4"])))))) +
np.minimum(((( 0.058823 <= np.minimum(( data["Medical_History_30"]),(((data["Medical_Keyword_32"] + data["Medical_Keyword_3"])/2.0)))).astype(float))),(np.cos(np.minimum(( np.minimum(( data["BMI"]),(data["Medical_History_4"]))),(( -(( np.sin(np.sinh(np.sin(np.sinh(data["BMI"])))) * 2.0)))))))) + 
(np.minimum(( 0.094340),(((((np.maximum(( data["Medical_Keyword_37"]),(data["Medical_History_23"])) <= data["BMI"] ).astype(float)) + data["Insurance_History_2"])/2.0)))*(( data["Medical_Keyword_15"] +(((data["BMI"] * data["Insurance_History_2"])+ data["SumMedicalKeywords"])/2.0)) /2.0)) + 
(np.sin(np.minimum(((((( data["Medical_Keyword_12"] + data["Medical_Keyword_15"])/2.0)+(( data["SumEmploymentInfo"] <= data["Medical_History_13"] ).astype(float)))/2.0)) ,(( data["Medical_Keyword_15"] *(-(( data["Medical_Keyword_15"] *(-(((data["Medical_Keyword_12"] >= data["Medical_History_13"] ).astype(float)))))))))))/ 2.0)+
np.minimum(( np.tanh(( -(((2.212120 <(data["Ins_Age"] *(( data["Medical_History_33"] +(( data["Medical_History_14"] < data["BMI"] ).astype(float)))/2.0)) ).astype(float)))))) ,(np.tanh(( -(((2.212120 < data["Ins_Age"] ).astype(float)))))))+
np.maximum(( np.ceil(np.tanh(np.minimum(( data["InsuredInfo_5"]),(data["Medical_History_32"]))))),(np.maximum(( np.minimum(( data["Medical_Keyword_19"]),(((np.cos(data["Medical_Keyword_39"])<= data["BMI"] ).astype(float))))),(( data["Medical_History_17"] -(( data["Product_Info_2_C"] <= np.cos(data["Medical_Keyword_20"])).astype(float)))))))+
np.sin(np.maximum(( data["Medical_Keyword_25"]),(np.sin(np.maximum(( data["Medical_Keyword_29"]),(np.maximum(( data["Medical_Keyword_25"]),(( data["Medical_History_13"] *(( data["SumNAs"] >(2.409090 -(((data["Employment_Info_2"] >(2.409090 - data["Product_Info_7"])).astype(float)) * 2.0)) ).astype(float)))))))))))+ 
(0.094340 *(-(((((data["Medical_Keyword_37"] >=(-(((((data["Employment_Info_2"] >=(( 0.058823 >(data["Medical_History_19"] + np.maximum(( data["Employment_Info_2"]),(data["Medical_Keyword_48"])))).astype(float)) ).astype(float)) > data["Employment_Info_2"] ).astype(float)))) ).astype(float)) > np.abs(data["Employment_Info_5"])).astype(float)))))+
np.minimum(( np.abs(( data["Ins_Age"] * data["Medical_Keyword_17"]))),(np.minimum(((0.138462 *(( 0.693147 >=(((((( data["Medical_History_2"] < data["Medical_Keyword_11"] ).astype(float)) < data["Medical_History_2"] ).astype(float)) * 2.0)- data["Medical_History_2"])).astype(float)))) ,(np.cos(data["Medical_History_32"])))))+ 
(((data["Product_Info_2_N"] < data["Medical_Keyword_31"] ).astype(float)) * np.floor(np.floor(np.cos(((data["Product_Info_3"] +(((data["Medical_History_20"] + np.floor(data["Insurance_History_3"])) /2.0)*(( data["Medical_Keyword_31"] >(( data["Medical_History_27"] + data["Medical_Keyword_31"])/2.0)).astype(float)))) /2.0)))))+
np.minimum(( np.maximum(( data["Insurance_History_5"]),(((data["Insurance_History_5"] + data["Insurance_History_9"])/2.0)))) ,(( -3.0 *(( 0.367879 <=(data["Insurance_History_5"] -(( np.maximum(( data["Insurance_History_7"]),(np.floor(data["Insurance_History_9"])))<(( data["Insurance_History_4"] < 0.0 ).astype(float)) ).astype(float)))).astype(float)))))+ 
(((data["Product_Info_7"] >=(data["Medical_History_38"] * data["SumEmploymentInfo"])).astype(float)) *(((data["Medical_History_4"] >= data["Medical_History_5"] ).astype(float)) *(( data["Medical_History_13"] + data["Medical_Keyword_40"])/2.0)))+ 
(((data["BMI"] *(((data["InsuredInfo_7"] +(( -(np.maximum(( data["Medical_History_23"]),(( data["Medical_History_40"] * data["Medical_History_30"])))))*(( data["Product_Info_4"] + np.minimum(( data["Medical_History_20"]),(data["Medical_History_27"])))/2.0)))> data["Medical_History_31"] ).astype(float)))/ 2.0)/ 2.0)+ 
(-(( 0.138462 *(((np.cos(data["Medical_History_28"])* np.sin(((( data["Product_Info_2_N"] <=(( data["Ht"] == np.abs(0.636620)).astype(float)) ).astype(float)) * data["Ins_Age"])))< np.minimum(( data["Medical_History_12"]),(data["Product_Info_2_N"])) ).astype(float)))))+ 
(((((np.minimum(( data["Medical_History_28"]),(((data["Product_Info_7"] + data["Medical_Keyword_5"])/2.0)))> np.cos(np.minimum(( data["Medical_Keyword_3"]),(data["Medical_Keyword_40"])))).astype(float)) >(( np.cos(data["Medical_Keyword_39"])+ np.maximum(( data["Medical_Keyword_10"]),(np.cos(data["Medical_History_25"])))) /2.0)).astype(float)) / 2.0)+ 
(np.sin(( data["Medical_History_5"] *(( data["Medical_History_19"] >(data["Product_Info_1"] * np.minimum(( data["Medical_Keyword_47"]),(((data["Medical_History_19"] - 0.094340)- np.sinh(data["Product_Info_2_C"])))))).astype(float)))) * np.maximum(( data["Medical_History_3"]),(data["Medical_History_29"])))+ 
(0.094340 *(np.minimum(((( data["Medical_History_41"] >= data["Medical_History_3"] ).astype(float))),(np.ceil(((((data["Medical_History_4"] * 2.0)*(( data["Medical_Keyword_3"] >(( data["Medical_Keyword_23"] >= data["Medical_Keyword_48"] ).astype(float)) ).astype(float)))+ data["Medical_Keyword_23"])/2.0)))) * data["Medical_Keyword_3"])) + 
(((( data["SumEmploymentInfo"] > np.minimum(( data["Medical_Keyword_12"]),(data["Family_Hist_5"])) ).astype(float)) <(( np.minimum(( np.minimum(((-(data["Medical_History_7"]))),(data["Family_Hist_5"]))),(data["Medical_History_21"])) >=(1.0/(1.0 + np.exp(-(data["Medical_Keyword_8"] -(data["Medical_Keyword_12"] - data["Medical_Keyword_8"])))))).astype(float)) ).astype(float)) + 
(np.minimum(((( data["InsuredInfo_7"] >= data["Medical_History_32"] ).astype(float))),(((data["Medical_History_32"] >= data["Medical_History_20"] ).astype(float)))) +(((data["Medical_History_9"] >= np.cos(((np.ceil(data["Medical_History_34"])==(( data["Medical_History_32"] >= 20.750000 ).astype(float)) ).astype(float)))).astype(float)) * 2.0)) + 
(( -(((((data["Ht"] == data["Medical_Keyword_44"] ).astype(float)) > np.cos(((data["SumMedicalHistory"] - data["Medical_Keyword_44"])/ 2.0)) ).astype(float)))) * np.sinh(np.abs(((data["Product_Info_6"] <= data["BMI"] ).astype(float)))))+
np.sin(((( data["Medical_Keyword_12"] + data["Medical_Keyword_20"])/2.0)*(-(((data["Medical_Keyword_26"] >(data["Medical_Keyword_10"] *(data["Medical_Keyword_39"] *(( np.sin(data["Medical_Keyword_12"])<= data["Employment_Info_6"] ).astype(float)))) ).astype(float)))))) + 
(data["Medical_Keyword_38"] *(np.minimum(( data["Medical_History_30"]),(np.tanh(np.minimum(( data["Product_Info_3"]),(((np.sinh(( data["Medical_Keyword_45"] -(data["Medical_Keyword_3"] * data["Medical_Keyword_13"])))/ 2.0)/ 2.0)))))) / 2.0)) + 
(( data["SumNAs"] >=(5.200000 - np.maximum(((data["Medical_Keyword_39"] * data["Medical_Keyword_47"])) ,(np.maximum(((np.minimum(( data["Medical_History_15"]),(np.minimum(( 5.200000),(((data["SumFamilyHistory"] >= data["Medical_Keyword_3"] ).astype(float)))))) * data["Medical_Keyword_2"])) ,(np.abs(data["Ht"])))))) ).astype(float)) + 
(-(np.minimum(( np.minimum(((( data["Medical_Keyword_47"] >(data["Medical_Keyword_24"] * np.minimum(( data["Medical_History_28"]),(((( data["Product_Info_1"] > data["Medical_History_13"] ).astype(float)) * 2.0)))) ).astype(float))),(( 1.0/(1.0 + np.exp(- data["Medical_History_3"])))))) ,(((data["Insurance_History_8"] >= data["Medical_History_11"] ).astype(float)))))) +
np.floor(np.tanh(( data["Medical_Keyword_18"] *(data["Medical_Keyword_17"] *(((data["Medical_History_19"] >=(-(data["Medical_Keyword_45"])) ).astype(float)) -(data["InsuredInfo_7"] * np.tanh(((( data["Medical_History_19"] >(-(data["Medical_Keyword_4"])) ).astype(float)) / 2.0)))))))) + 
(-(((((data["Employment_Info_4"] <= data["Medical_Keyword_23"] ).astype(float)) > np.floor(((((np.sin(data["Medical_History_11"])<= data["Medical_Keyword_23"] ).astype(float)) >(( data["Medical_Keyword_46"] +(( data["Medical_History_11"] < data["Medical_Keyword_16"] ).astype(float)))/2.0)).astype(float)))).astype(float)))) +
np.maximum(((( np.minimum(( data["Ins_Age"]),(((( np.minimum(( data["Medical_History_30"]),(data["Medical_History_10"])) * data["Medical_History_10"])> np.cos(data["Family_Hist_1"])).astype(float)))) == np.ceil(data["Medical_History_6"])).astype(float))),(np.floor(np.minimum(( data["Employment_Info_3"]),(np.minimum(( data["Medical_Keyword_16"]),(data["Employment_Info_6"])))))))+
np.sinh(np.abs(((((( data["SumMedicalHistory"] *(((data["Employment_Info_1"] / 2.0)<= data["Employment_Info_4"] ).astype(float)))>(data["Medical_History_36"] +(9.869604 / 2.0)) ).astype(float)) > np.cos(np.minimum(( data["Medical_Keyword_36"]),(((data["Medical_History_28"] + data["SumMedicalHistory"])/2.0)))) ).astype(float)))) +
np.sin(( data["SumMedicalKeywords"] * np.minimum(((1.0/(1.0 + np.exp(- data["Medical_History_40"])))) ,(((data["InsuredInfo_5"] >=(data["SumMedicalKeywords"] * np.sinh(np.minimum(((1.0/(1.0 + np.exp(- np.floor(data["InsuredInfo_5"]))))),(((data["Medical_History_19"] >= data["Medical_History_31"] ).astype(float)))))) ).astype(float)))))) + 
(( np.minimum(( data["Medical_History_38"]),(data["Medical_Keyword_39"])) / 2.0)*(-(((data["Medical_Keyword_39"] >(((( np.round(((data["Medical_History_36"] + data["Product_Info_6"])/2.0)) + data["SumInsuredInfo"])/2.0)/ 2.0)/ 2.0)).astype(float)))))+ 
(((((((( data["Medical_History_12"] > data["Medical_History_13"] ).astype(float)) > np.floor(( data["InsuredInfo_1"] / 2.0)) ).astype(float)) >(( data["Medical_History_11"] < np.sin(np.minimum(( data["Medical_Keyword_43"]),(((data["SumEmploymentInfo"] > data["Medical_Keyword_9"] ).astype(float)))))).astype(float)) ).astype(float)) <(( data["Medical_Keyword_42"] > data["Medical_History_40"] ).astype(float)) ).astype(float)) + 
(-(((((((np.minimum(( data["Medical_Keyword_42"]),(data["Medical_Keyword_40"])) >(( data["Employment_Info_1"] +(1.0/(1.0 + np.exp(- data["Employment_Info_4"])))) /2.0)).astype(float)) >(( data["Employment_Info_4"] <=(data["Medical_Keyword_40"] * data["SumInsuredInfo"])).astype(float)) ).astype(float)) > np.ceil(data["Medical_Keyword_3"])).astype(float)))) + 
(np.tanh(((-(np.maximum(( data["Medical_History_4"]),(( data["Medical_Keyword_36"] / 2.0)))))*(( data["SumInsuranceHistory"] >= np.ceil(data["Medical_History_40"])).astype(float)))) *(((( data["SumInsuranceHistory"] >= np.ceil(data["Medical_History_40"])).astype(float)) >= np.abs(data["Medical_History_28"])).astype(float)))+ 
(( data["Medical_History_19"] < np.minimum(((data["Medical_History_19"] * data["Medical_History_15"])) ,(np.minimum(( data["Medical_Keyword_3"]),(( -(( 1.0/(1.0 + np.exp(- np.round(np.minimum(( np.minimum(( data["Medical_History_40"]),(np.minimum(( data["Medical_History_22"]),(( data["Medical_History_35"] * data["Medical_History_19"])))))) ,(data["BMI"])))))))))))) ).astype(float)) + 
(( 5.428570 <(data["Medical_History_19"] +(((data["Employment_Info_2"] < np.ceil(( data["Medical_History_9"] *(( data["Insurance_History_2"] >= np.maximum(( data["Medical_History_5"]),(data["Medical_Keyword_33"])) ).astype(float)))) ).astype(float)) *(( data["Insurance_History_2"] >=(data["Medical_History_7"] - data["Medical_History_5"])).astype(float)))) ).astype(float)) +
np.floor(( 1.0/(1.0 + np.exp(-(data["Product_Info_5"] +(data["Medical_History_7"] +(((data["Medical_Keyword_14"] + data["Medical_Keyword_32"])+ data["InsuredInfo_7"])* np.maximum(( data["Medical_Keyword_46"]),(( data["Medical_Keyword_39"] * data["SumInsuredInfo"])))))))))) + 
(( 1.0/(1.0 + np.exp(- data["Product_Info_6"])))*(np.floor(np.sin(np.floor(((np.sin(np.maximum(((data["Medical_History_13"] -(-(data["BMI"])))) ,(np.maximum(( data["Employment_Info_2"]),(np.maximum(( data["Employment_Info_1"]),(data["Medical_History_13"])))))))/ 2.0)/ 2.0)))) / 2.0)) + 
(data["Family_Hist_5"] *(((data["Medical_History_28"] * data["Medical_Keyword_13"])>=(1.0/(1.0 + np.exp(-(np.minimum(((data["Ins_Age"] * data["Medical_History_5"])) ,(data["InsuredInfo_3"])) +(data["Ins_Age"] * data["Medical_History_30"])))))).astype(float)))+
np.round(( np.sin(np.ceil(np.ceil(((((data["Wt"] - data["SumNAs"])<(((data["Medical_History_40"] < data["Wt"] ).astype(float)) * data["Employment_Info_1"])).astype(float)) * np.minimum(( data["Medical_Keyword_12"]),(data["Medical_Keyword_25"])))))) * 2.0)) + 
(np.minimum(( data["Medical_Keyword_44"]),(((np.minimum(( data["Medical_Keyword_44"]),(((data["Employment_Info_4"] > data["Wt"] ).astype(float)))) > data["Wt"] ).astype(float)))) *(( data["Medical_History_12"] >=(-(((np.minimum(((data["Medical_Keyword_44"] / 2.0)) ,(data["SumInsuredInfo"])) + data["Medical_Keyword_47"])/2.0)))).astype(float)))+ 
(0.138462 *(((data["Ins_Age"] * np.minimum(( np.maximum(( data["Medical_Keyword_27"]),(data["Medical_Keyword_22"]))),(np.cos(data["Medical_History_24"])))) +(np.minimum(( np.minimum(( data["Medical_History_20"]),(data["Medical_History_13"]))),(data["Medical_History_23"])) *(data["InsuredInfo_1"] / 2.0)))/2.0)))
 return p+4.5
def Individual3(data):
p =(((((( -(data["BMI"])) +(( data["Medical_History_4"] <(( data["BMI"] < data["Medical_History_23"] ).astype(float)) ).astype(float)))+(data["Medical_History_4"] - data["SumMedicalKeywords"])) /2.0)+ np.cos(((data["Medical_Keyword_3"] +(data["Medical_History_40"] - data["BMI"])) /2.0)))+ 
(((( data["InsuredInfo_6"] + data["Medical_History_15"])/2.0)+(( np.minimum(((np.ceil(np.minimum(( data["Product_Info_4"]),(( np.ceil(data["Product_Info_4"])* 2.0)))) * 2.0)) ,(( -(((data["Insurance_History_2"] +(data["Medical_History_30"] + data["InsuredInfo_7"])) /2.0)))))+ data["Product_Info_4"])/2.0)) /2.0)+
np.tanh(( np.minimum(((np.cos(data["Ins_Age"])- data["InsuredInfo_5"])) ,(np.minimum(( data["Medical_History_20"]),(data["Medical_History_27"])))) -(data["Medical_History_5"] *(data["Medical_Keyword_22"] +(( data["Family_Hist_4"] + data["SumMedicalKeywords"])+ data["Medical_History_5"])))))+
np.tanh(((( np.maximum(( data["Medical_Keyword_41"]),(data["SumMedicalKeywords"])) +(( data["Insurance_History_5"] +(-(np.maximum(( data["Medical_History_18"]),(np.maximum(( np.maximum(( data["Medical_Keyword_3"]),(data["Medical_History_30"]))),(np.maximum(( data["Medical_History_28"]),(( data["Medical_Keyword_38"] - data["Medical_History_11"])))))))))) /2.0)) /2.0)/ 2.0)) +
np.tanh(((data["Medical_History_31"] +(((((data["BMI"] * data["Ins_Age"])+ np.minimum(( data["Medical_History_13"]),(data["Product_Info_2_N"])))/2.0)+ np.minimum(( np.cos(data["Product_Info_4"])) ,(( np.cos(data["Product_Info_4"])+(data["Medical_History_1"] + data["Family_Hist_2"])))))/2.0)) /2.0)) + 
(((( data["Medical_History_24"] >= data["Medical_Keyword_18"] ).astype(float)) + np.minimum(( np.minimum(((((data["Medical_History_7"] + data["Employment_Info_2"])/2.0)/ 2.0)) ,(( data["Medical_History_35"] * data["Medical_History_24"])))) ,(np.minimum(( np.cos(np.round(data["Wt"]))),(( data["Medical_History_5"] * data["InsuredInfo_2"])))))) /2.0)+
np.minimum(( np.sin(( data["Medical_History_11"] * 2.0))),(np.maximum(( data["Medical_History_4"]),(( np.maximum(( data["Medical_History_24"]),(data["Medical_History_15"])) +(np.maximum(( data["Medical_History_24"]),(data["Medical_History_15"])) +(( data["Wt"] +(data["Medical_History_15"] - 0.058823)) /2.0)))))))+ 
(((((data["Medical_History_23"] +(((-(data["InsuredInfo_1"])) + data["Medical_History_3"])/2.0)) /2.0)+(((( data["SumMedicalKeywords"] + data["Medical_Keyword_25"])/2.0)+(( data["Medical_Keyword_33"] +(((data["Medical_History_17"] - data["InsuredInfo_1"])+ data["Medical_History_17"])/2.0)) /2.0)) /2.0)) /2.0)/ 2.0)+
np.sin(np.minimum(( data["Medical_History_33"]),(((( data["Medical_Keyword_28"] +(((( data["SumNAs"] +(np.cos(data["BMI"])- data["Medical_Keyword_9"])) /2.0)+(((( data["Medical_History_39"] +(data["Medical_Keyword_19"] + data["Medical_Keyword_32"])) /2.0)+ data["Medical_Keyword_11"])/2.0)) /2.0)) /2.0)/ 2.0)))) +
np.minimum(( np.ceil(np.minimum(((( data["Employment_Info_1"] / 2.0)/ 2.0)) ,(((2.0 * np.floor(np.cos(( data["Insurance_History_7"] + data["Insurance_History_5"])))) * 2.0))))),(( data["BMI"] *(( data["Medical_History_5"] >= np.cos(data["Medical_History_14"])).astype(float)))))+
np.minimum(( np.minimum(( 0.138462),(((data["Family_Hist_2"] <= np.round(( data["Medical_History_15"] + data["Product_Info_2_N"])) ).astype(float))))),(( data["Medical_History_32"] +(((( data["Insurance_History_1"] < np.round(np.sin(np.ceil(data["Product_Info_2_N"])))).astype(float)) + data["Medical_Keyword_19"])/2.0)))) +
np.minimum(( 0.301030),(np.maximum(( data["Medical_History_10"]),(((((((data["Product_Info_2_C"] >= np.round(( data["Product_Info_2_C"] - data["Medical_Keyword_45"])) ).astype(float)) >= np.abs(((data["Medical_Keyword_7"] <(np.cos(data["Medical_Keyword_2"])- data["Medical_Keyword_26"])).astype(float)))).astype(float)) >= data["Medical_History_40"] ).astype(float)))))) +
np.sin(np.minimum(((( data["Medical_History_13"] == data["Medical_History_18"] ).astype(float))),(((((data["Medical_History_27"] >(data["Medical_History_15"] * data["Medical_History_18"])).astype(float)) * 2.0)* data["Medical_History_15"])))) + 
(((( data["Medical_History_15"] < np.minimum(( np.sin(np.floor(np.minimum(((( data["Medical_History_15"] - data["Medical_History_18"])- data["Medical_History_18"])) ,(( data["Medical_History_15"] - data["Medical_History_18"])))))) ,(data["Medical_Keyword_41"])) ).astype(float)) +(( data["Medical_Keyword_34"] >= np.abs(data["Medical_History_22"])).astype(float)))/2.0)+ 
(np.minimum(( np.minimum(( np.maximum(( data["Medical_History_4"]),(( data["Medical_History_15"] / 2.0)))) ,(data["Medical_Keyword_43"]))),(np.sin(data["InsuredInfo_2"])))* np.sin(np.minimum(( np.minimum(( data["Medical_History_4"]),(( data["SumNAs"] + data["Medical_History_4"])))) ,(((data["Medical_Keyword_37"] > data["Medical_History_1"] ).astype(float)))))) + 
(( 0.058823 *(((data["Medical_History_6"] + np.minimum(((-(np.ceil(np.maximum(( data["Medical_History_19"]),(data["InsuredInfo_2"])))))) ,(data["Medical_History_22"])))+ data["Employment_Info_5"])/2.0)) + np.sin(np.cos(np.maximum(( 1.584910),(data["Ins_Age"])))))+ 
(((( 0.058823 +(((( data["Medical_History_18"] >= data["Medical_History_28"] ).astype(float)) <= data["Medical_History_13"] ).astype(float)))/2.0)+(-(((((data["SumEmploymentInfo"] >= data["Medical_History_18"] ).astype(float)) < np.round(((0.058823 <(( data["Medical_Keyword_5"] < data["Medical_History_28"] ).astype(float)) ).astype(float)))).astype(float)))))/2.0)+ 
(((((( data["Medical_Keyword_23"] * data["Medical_Keyword_46"])<= np.minimum(((data["Medical_Keyword_46"] - data["Medical_History_15"])) ,(((((data["Medical_History_20"] <=(data["Medical_History_5"] + data["Medical_Keyword_27"])).astype(float)) > data["Medical_History_20"] ).astype(float)))) ).astype(float)) * data["Ins_Age"])/ 2.0)/ 2.0)+ 
(((20.750000 <= data["Medical_History_32"] ).astype(float)) +(((data["InsuredInfo_6"] *(((( data["Insurance_History_7"] + data["InsuredInfo_6"])/2.0)< data["Medical_History_23"] ).astype(float)))* np.minimum(( data["Medical_Keyword_3"]),(np.cos(( 1.0/(1.0 + np.exp(- data["InsuredInfo_6"])))))))/ 2.0)) +
np.minimum(( np.minimum(((((( np.minimum(( data["Medical_Keyword_3"]),(data["Family_Hist_3"])) >=(data["Medical_Keyword_39"] * data["Medical_Keyword_6"])).astype(float)) / 2.0)/ 2.0)) ,(np.maximum(( data["SumMedicalKeywords"]),(data["Medical_History_39"]))))),(np.maximum(( data["SumMedicalKeywords"]),(((data["Medical_History_23"] + data["Medical_History_20"])/2.0)))))+
np.minimum(((data["Medical_History_15"] *(( np.ceil(data["Medical_History_15"])< np.sin(((data["Medical_History_15"] > data["Employment_Info_3"] ).astype(float)))).astype(float)))) ,(( data["Product_Info_2_N"] *(((np.minimum(( data["Ins_Age"]),(data["Medical_History_18"])) >=(1.0/(1.0 + np.exp(- data["Medical_Keyword_43"])))).astype(float)) / 2.0)))) + 
(0.094340 *(((data["Family_Hist_3"] +(( data["Medical_Keyword_15"] -(data["Medical_History_4"] + data["Ht"])) -(( data["SumEmploymentInfo"] >=(1.0/(1.0 + np.exp(-(data["Medical_History_15"] - data["Medical_History_36"])))) ).astype(float)))) /2.0)- np.minimum(( data["Medical_History_15"]),(data["Ins_Age"])))) + 
(-(np.sin(( np.abs(data["Medical_History_5"])*(( np.minimum(((data["Medical_History_39"] - data["BMI"])) ,(np.minimum(( data["Medical_History_37"]),(np.ceil(np.ceil(data["Product_Info_4"])))))) <=(( data["Medical_History_30"] * data["Medical_History_39"])- data["Medical_History_13"])).astype(float)))))) +
np.abs(( np.cos(data["Wt"])* np.tanh(( np.minimum(( data["SumInsuredInfo"]),(data["Medical_History_4"])) *(-2.0 *(data["Medical_History_4"] *(data["Medical_History_10"] *(( data["Medical_History_15"] <= np.cos(-2.0)).astype(float)))))))))+ 
(np.minimum(( np.maximum(( data["InsuredInfo_7"]),(( -(np.ceil(data["Product_Info_4"])))))) ,(((data["BMI"] +(( data["Medical_History_12"] <=(np.minimum(((data["Product_Info_4"] / 2.0)) ,(((data["Medical_History_17"] + data["InsuredInfo_7"])/2.0)))/ 2.0)).astype(float)))/2.0)))/ 2.0)+
np.sin(np.sinh(np.minimum(((1.0/(1.0 + np.exp(- data["BMI"])))) ,(( data["BMI"] * np.sin(np.round(np.round(((data["Medical_History_39"] -(data["BMI"] * np.sin(np.round(data["Medical_History_11"])))) +(data["Insurance_History_2"] / 2.0)))))))))) +
np.sin(( data["Medical_History_5"] *(((( data["Medical_History_24"] +(np.maximum(( data["Medical_Keyword_48"]),(data["Medical_Keyword_23"])) * data["Medical_History_20"])) /2.0)+(( data["Medical_Keyword_7"] >(( data["Medical_History_2"] +(1.0/(1.0 + np.exp(- data["Medical_Keyword_8"])))) /2.0)).astype(float)))/2.0)))+ 
(((data["Medical_History_20"] <(( np.ceil(data["Medical_Keyword_24"])<(((((-(data["InsuredInfo_5"])) < data["Medical_History_18"] ).astype(float)) >= data["Medical_History_17"] ).astype(float)) ).astype(float)) ).astype(float)) *(((((data["Medical_History_21"] >= data["Medical_Keyword_21"] ).astype(float)) >= data["Medical_History_40"] ).astype(float)) / 2.0)) +
np.minimum(((((data["Medical_History_15"] + data["InsuredInfo_1"])/2.0)*(np.ceil(data["Medical_History_23"])* 0.058823))),(((data["Medical_History_1"] +(( data["InsuredInfo_2"] <=(data["Medical_History_37"] * 2.0)).astype(float)))/2.0)))+
np.sin(( np.ceil(np.ceil(np.minimum(( np.round(((data["Medical_Keyword_12"] + np.minimum(( data["Product_Info_4"]),(data["Medical_Keyword_15"])))/2.0))),(data["Medical_History_40"])))) *(( data["Medical_Keyword_15"] <= np.minimum(( data["Medical_History_4"]),(( data["InsuredInfo_4"] - data["BMI"])))).astype(float)))) +
np.minimum(((0.058823 *(np.cos(data["Employment_Info_4"])- np.minimum(( data["Medical_History_3"]),(np.sinh(data["Ins_Age"])))))) ,(((((data["Medical_Keyword_11"] >= data["Product_Info_2_C"] ).astype(float)) +(-(((data["Medical_History_38"] >= 0.0 ).astype(float)))))/2.0)))+
np.sin(( data["Medical_History_11"] *(( data["Medical_History_37"] >=(((data["Medical_Keyword_25"] <=(data["Medical_History_8"] * data["Medical_Keyword_33"])).astype(float)) -(((data["Medical_Keyword_16"] + data["Medical_Keyword_5"])+(( data["Medical_Keyword_9"] + data["Medical_Keyword_29"])- data["Medical_History_18"])) /2.0)) ).astype(float)))) + 
(np.sin(np.sin(np.minimum(( data["SumMedicalKeywords"]),(data["InsuredInfo_5"])))) *(( data["SumInsuranceHistory"] >= np.ceil(((np.minimum(( data["Medical_History_17"]),(((((data["Medical_History_17"] >= np.abs(data["InsuredInfo_5"])).astype(float)) >= np.abs(data["SumMedicalKeywords"])).astype(float)))) + data["Medical_Keyword_19"])/2.0)) ).astype(float)))+
np.minimum(((( np.tanh(np.cos(((data["Ht"] + np.minimum(( data["Medical_Keyword_39"]),(data["Medical_Keyword_47"])))/2.0)))< np.minimum(( data["Medical_Keyword_14"]),(((data["Medical_Keyword_39"] + data["Medical_Keyword_34"])/2.0)))).astype(float))),(np.cos(np.minimum(( data["Product_Info_7"]),(((data["SumNAs"] + data["Medical_Keyword_42"])/2.0)))))) + 
(0.058823 * np.round(((( data["Medical_History_1"] >=(data["Medical_Keyword_47"] * 2.0)).astype(float)) - np.abs(np.sinh(((data["Product_Info_2_N"] + np.sinh(np.minimum(( data["Product_Info_2_N"]),(((data["Medical_Keyword_11"] + data["Medical_Keyword_47"])/2.0)))))/2.0)))))) +
np.minimum(( 0.138462),(np.maximum(((( data["Medical_Keyword_21"] + data["Medical_Keyword_16"])/2.0)) ,(np.maximum(( np.maximum(((( data["Medical_Keyword_20"] + data["Medical_Keyword_2"])/2.0)) ,(((((data["Medical_Keyword_29"] + data["Product_Info_7"])/2.0)+ data["Medical_Keyword_8"])/2.0)))) ,(((0.058823 >= np.cos(data["Family_Hist_5"])).astype(float)))))))) +
np.tanh(np.tanh(( data["Medical_Keyword_3"] *(((( data["Product_Info_5"] >= data["Medical_History_7"] ).astype(float)) >=(((data["Medical_History_22"] +(( np.ceil(data["Product_Info_4"])- data["Product_Info_5"])- data["Medical_History_35"])) /2.0)- data["Medical_Keyword_38"])).astype(float)))))+
np.minimum(((np.maximum(( np.ceil(data["Medical_History_6"])) ,(( data["Ht"] / 2.0)))/ 2.0)) ,(((2.718282 < np.maximum(((data["SumNAs"] -(( data["Medical_History_28"] > data["SumEmploymentInfo"] ).astype(float)))) ,(((data["Medical_History_19"] +(data["Medical_History_28"] * data["Medical_History_7"])) /2.0)))).astype(float)))) +
np.tanh(( np.minimum(( data["Medical_Keyword_24"]),(data["SumMedicalKeywords"])) *(( data["Medical_History_10"] >=(np.cos(data["InsuredInfo_1"])*(np.minimum(( data["Medical_History_27"]),(((data["Medical_History_18"] >= data["Medical_Keyword_24"] ).astype(float)))) * data["Medical_History_18"])) ).astype(float)))) + 
(( np.minimum(( np.ceil(np.minimum(( data["Product_Info_7"]),(data["Medical_History_6"])))) ,(data["Medical_Keyword_21"])) > np.cos(((np.minimum(( data["Medical_History_10"]),(( data["Medical_History_30"] - np.minimum(( data["Medical_History_22"]),(data["Medical_History_40"])))))* 2.0)- np.minimum(( data["Product_Info_7"]),(data["Medical_History_40"])))) ).astype(float)) +
np.ceil(np.minimum(( data["Medical_Keyword_13"]),(((( data["Medical_Keyword_38"] +(data["Medical_Keyword_11"] *(-(((data["Medical_Keyword_43"] >=(data["Medical_History_7"] *(data["Medical_History_22"] +(data["Medical_History_3"] * np.floor(data["Medical_History_28"])))) ).astype(float)))))) /2.0)/ 2.0)))) + 
(np.sin(np.sin(np.floor(np.sin(((data["Medical_History_20"] +(( np.abs(np.maximum(( np.abs(data["Medical_History_27"])) ,(data["Medical_Keyword_31"])))+ np.minimum(( data["Medical_History_24"]),(((( data["Medical_Keyword_4"] * data["Medical_History_22"])+ data["Medical_Keyword_31"])/2.0)))) /2.0)) /2.0)))))* 2.0)+ 
(( np.maximum(( data["Medical_History_28"]),(np.maximum(( data["Medical_History_27"]),(((np.cos(np.maximum(( np.maximum(( data["Medical_Keyword_23"]),(data["Wt"]))),(data["Medical_Keyword_17"])))>(np.maximum(( data["Medical_History_19"]),(data["Medical_Keyword_24"])) / 2.0)).astype(float)))))) <(data["Medical_Keyword_32"] * data["Medical_Keyword_46"])).astype(float)) + 
(((np.minimum(((( data["SumMedicalKeywords"] > data["Medical_History_22"] ).astype(float))),(((np.minimum(((( data["Medical_Keyword_3"] > data["Medical_History_22"] ).astype(float))),(((data["Medical_Keyword_40"] > data["Medical_History_31"] ).astype(float)))) > data["Medical_History_31"] ).astype(float)))) >= np.maximum(( data["Medical_History_20"]),(((data["Insurance_History_9"] < data["InsuredInfo_1"] ).astype(float)))) ).astype(float)) / 2.0)+ 
(((np.minimum(( np.sin(np.maximum(( data["SumMedicalKeywords"]),(np.ceil(np.maximum(((-(data["Medical_History_12"]))),(np.maximum(((data["Employment_Info_2"] * 5.200000)) ,(data["Medical_Keyword_3"]))))))))),(((data["Medical_History_37"] > np.abs(data["SumMedicalKeywords"])).astype(float)))) / 2.0)/ 2.0)/ 2.0)+
np.floor(np.sin(np.round(( data["Product_Info_1"] *(((((( data["Medical_History_12"] >(data["Medical_Keyword_41"] * data["Insurance_History_3"])).astype(float)) > np.cos(np.abs(data["Employment_Info_1"])) ).astype(float)) !=(data["Medical_History_8"] *(( data["Medical_Keyword_14"] >= data["Medical_History_7"] ).astype(float)))).astype(float)))))) +
np.minimum(( np.cos(data["SumEmploymentInfo"])) ,(np.minimum(( np.sin(np.round(data["Medical_History_35"]))),(np.cos(np.minimum(( data["Medical_History_10"]),(( data["Medical_Keyword_42"] + np.maximum(( data["Medical_History_3"]),(np.maximum(( np.floor(data["SumMedicalHistory"])) ,(data["Medical_History_35"])))))))))))) +
np.sin(np.maximum(((0.058823 *(( np.ceil(data["Product_Info_2_C"])< data["Ins_Age"] ).astype(float)))) ,(((np.minimum(( data["InsuredInfo_5"]),(( 0.058823 +(((( data["Medical_History_4"] > data["InsuredInfo_6"] ).astype(float)) > np.abs(data["Ins_Age"])).astype(float)))))* 2.0)* 2.0)))) + 
(( data["InsuredInfo_5"] *(((data["InsuredInfo_5"] * data["InsuredInfo_1"])>=(( data["SumInsuredInfo"] >= data["Medical_Keyword_24"] ).astype(float)) ).astype(float)))*(((( data["Medical_History_40"] <= np.cos(( data["SumInsuredInfo"] * 2.0)) ).astype(float)) / 2.0)/ 2.0)) + 
(np.minimum(( np.maximum(((( np.round(data["Ins_Age"])+ 0.693147)/2.0)) ,(( data["Medical_History_33"] - data["InsuredInfo_7"])))) ,(((( data["Medical_Keyword_46"] >= np.maximum(( data["Ins_Age"]),(data["Medical_History_39"])) ).astype(float)) * data["InsuredInfo_6"])))/ 2.0)+
np.minimum(((-(((data["Product_Info_3"] <= np.minimum(( -3.0),(np.minimum(((data["Ht"] +(-3.0 * data["InsuredInfo_3"]))),(( data["Medical_History_29"] + -3.0)))))).astype(float))))),(np.maximum(( data["Medical_History_11"]),(np.tanh(data["Product_Info_3"])))))+
np.sin(((1.197370 <= np.minimum(( np.abs(data["Employment_Info_2"])) ,(((((data["InsuredInfo_1"] + np.minimum(( data["Medical_Keyword_38"]),(data["Medical_History_28"])))+(( data["Medical_Keyword_30"] > data["Medical_Keyword_7"] ).astype(float)))+ np.minimum(( data["Medical_Keyword_1"]),(data["Medical_Keyword_16"])))/ 2.0)))).astype(float)))+ 
(( np.minimum(( data["Medical_Keyword_47"]),(np.maximum(( data["Medical_History_5"]),(np.maximum(( data["Medical_Keyword_2"]),(np.maximum(( data["Medical_Keyword_43"]),(np.maximum(( data["Medical_Keyword_26"]),(( data["Medical_Keyword_36"] + data["Product_Info_5"])))))))))))>=(np.abs(data["Medical_Keyword_14"])- np.minimum(( data["Medical_History_28"]),(data["Medical_Keyword_36"])))).astype(float)) + 
(0.094340 * np.floor(np.cos(((( data["Medical_History_18"] +(data["Medical_History_13"] +(data["Medical_Keyword_40"] *(( np.tanh(data["Medical_History_10"])!=(( data["Product_Info_2_C"] == data["Product_Info_2_C"] ).astype(float)) ).astype(float)))))/2.0)* 2.0)))) +
np.minimum(( 0.094340),(((((( data["Product_Info_2_C"] >(((((data["Medical_Keyword_22"] + data["Medical_History_37"])/2.0)+(( data["Medical_Keyword_21"] + data["Product_Info_6"])/2.0)) > data["Medical_Keyword_10"] ).astype(float)) ).astype(float)) + np.maximum(( data["Medical_History_10"]),(data["Medical_Keyword_11"])))/2.0)/ 2.0)))+ 
(((( data["Employment_Info_2"] +(-(((2.409090 < data["Ins_Age"] ).astype(float)))))<= data["Product_Info_4"] ).astype(float)) * np.sinh(np.ceil(np.minimum(((-(((2.409090 < data["Ins_Age"] ).astype(float))))),(( data["Wt"] / 2.0)))))) +
np.ceil(((( np.tanh(data["Medical_Keyword_42"])>=(( data["Medical_Keyword_20"] < data["Medical_History_11"] ).astype(float)) ).astype(float)) -(( np.minimum(( data["Medical_History_23"]),(data["Wt"])) >(((( data["Insurance_History_9"] <= data["Medical_History_10"] ).astype(float)) >= np.minimum(( data["Medical_Keyword_38"]),(data["Ht"])) ).astype(float)) ).astype(float)))) + 
(data["Insurance_History_1"] *(-(( data["Medical_Keyword_39"] *(np.round(np.sin(( data["Medical_History_38"] - np.minimum(((( data["Medical_History_9"] >(( data["Medical_Keyword_39"] > data["SumNAs"] ).astype(float)) ).astype(float))),(data["SumMedicalKeywords"])))))/ 2.0)))))+ 
(((( data["Insurance_History_1"] >= data["Medical_History_5"] ).astype(float)) <(((( data["Medical_Keyword_43"] >= data["Medical_History_7"] ).astype(float)) >(((data["Medical_Keyword_19"] +(( data["Medical_Keyword_43"] >= data["Wt"] ).astype(float)))<=(( data["Product_Info_6"] >= data["Insurance_History_1"] ).astype(float)) ).astype(float)) ).astype(float)) ).astype(float)) +
np.minimum(( np.maximum(((data["Medical_History_27"] -(data["Medical_Keyword_30"] *(data["Medical_History_7"] - data["Medical_History_19"])))) ,(data["Medical_Keyword_25"]))),(( data["Medical_Keyword_25"] *(data["Medical_Keyword_35"] *(( data["Medical_Keyword_12"] >= data["Medical_Keyword_18"] ).astype(float)))))) + 
(((data["Wt"] / 2.0)*(((data["Medical_Keyword_23"] *(( data["Medical_History_31"] <=(((( data["Medical_History_30"] + data["Medical_Keyword_31"])/2.0)+ data["Medical_Keyword_46"])/2.0)).astype(float)))<=(( data["Medical_History_30"] + data["Medical_Keyword_14"])/2.0)).astype(float)))/ 2.0)+
np.sin(np.maximum(( data["Medical_Keyword_43"]),(((((((data["Employment_Info_1"] < 0.693147 ).astype(float)) <(( data["Medical_Keyword_35"] > data["Medical_History_10"] ).astype(float)) ).astype(float)) == np.maximum(( data["Medical_History_27"]),(((( data["Medical_History_22"] * data["SumMedicalHistory"])<= data["Employment_Info_4"] ).astype(float)))) ).astype(float)))))+ 
(((( np.minimum(( np.floor(((data["Medical_History_14"] >= data["Insurance_History_5"] ).astype(float)))) ,(np.minimum(((( data["Medical_Keyword_16"] + np.ceil(data["Product_Info_7"])) /2.0)) ,(np.floor(( -(data["Insurance_History_5"])))))))==(( data["Medical_History_21"] >= data["Medical_History_24"] ).astype(float)) ).astype(float)) > np.cos(data["Medical_History_5"])).astype(float)) + 
(( 2.409090 <(( data["SumMedicalHistory"] +(np.minimum(( data["Medical_History_10"]),(((data["Medical_Keyword_14"] +(((np.abs(( data["Medical_Keyword_15"] * data["Medical_History_36"])) + data["Medical_Keyword_20"])+ data["Medical_Keyword_4"])/2.0)) /2.0)))* 2.0)) /2.0)).astype(float)))
 return p+4.5
def Individual4(data):
p =(( np.minimum(( data["Medical_History_40"]),(np.power(np.abs(( -2.0 + data["BMI"])) , data["Medical_History_39"])))+ np.power(np.abs(( -2.0 + data["BMI"])) ,(( data["Medical_History_4"] +(data["Product_Info_4"] +(((data["Medical_History_4"] * 2.0)+ data["Medical_History_23"])/2.0)))/2.0)))+ 
(np.sin(data["Medical_History_30"])-(np.maximum(((( np.power(np.abs(data["Product_Info_4"]), 31.006277)<= data["Medical_Keyword_3"] ).astype(float))),(((( np.abs(data["Medical_History_15"])<= np.minimum(( data["SumInsuranceHistory"]),(data["Medical_History_15"])) ).astype(float)) * 2.0)))+(( data["Medical_History_13"] >= data["Medical_History_15"] ).astype(float)))) + 
(np.ceil(((data["Medical_History_39"] < np.floor(data["InsuredInfo_6"])).astype(float)))-(( data["Medical_History_20"] < np.maximum(( np.floor(( data["InsuredInfo_5"] * data["Insurance_History_2"]))),(np.sinh(np.maximum(( np.maximum(( data["InsuredInfo_7"]),(data["Medical_History_5"]))),(( data["Ins_Age"] * 2.0)))))) ).astype(float)))+ 
(np.minimum(( data["Medical_History_18"]),(((( np.tanh(np.minimum(( data["Medical_History_24"]),(( data["Medical_History_6"] - data["Medical_History_15"])))) +(( data["Medical_History_18"] <=(( data["Medical_History_13"] > data["Medical_History_35"] ).astype(float)) ).astype(float)))/2.0)- data["Medical_Keyword_38"])))-(( data["Employment_Info_2"] < data["Medical_History_28"] ).astype(float)))+ 
(((data["Medical_Keyword_41"] + np.sin(( data["BMI"] / 2.0)))/2.0)-(((-(((data["Medical_History_27"] <= data["Medical_History_35"] ).astype(float)))) <(( data["Medical_History_7"] <=(data["Medical_History_5"] +(((data["BMI"] / 2.0)<= np.sin(data["Medical_History_11"])).astype(float)))).astype(float)) ).astype(float)))+ 
(((-(np.maximum(( data["Medical_Keyword_48"]),(np.floor(data["Product_Info_4"])))))+(( np.maximum(( data["Family_Hist_4"]),(np.sin(( data["InsuredInfo_6"] - data["InsuredInfo_1"])))) +(((data["Insurance_History_5"] +(data["InsuredInfo_6"] - data["InsuredInfo_1"])) + data["Family_Hist_2"])/2.0)) /2.0)) /2.0)+
np.sin(np.minimum(( np.cos(data["Medical_History_19"])) ,(((( data["Medical_History_40"] <=(( data["Medical_History_31"] <= data["Medical_History_39"] ).astype(float)) ).astype(float)) -(data["Medical_Keyword_9"] +(((data["Medical_History_31"] <= data["InsuredInfo_2"] ).astype(float)) -(( data["Medical_Keyword_48"] >= data["Medical_History_39"] ).astype(float)))))))) + 
(((( data["Medical_Keyword_33"] +(((( data["Medical_Keyword_25"] - np.sin(np.sin(data["Product_Info_2_N"])))+(( round(2.675680)< data["Medical_History_1"] ).astype(float)))/2.0)- data["Medical_Keyword_23"])) /2.0)+(data["Medical_History_17"] - np.round(2.675680)))/2.0)+ 
(((np.sin(((( data["Medical_Keyword_45"] +(np.sin(np.sinh(data["Product_Info_2_C"])) + data["Medical_Keyword_22"])) /2.0)* 2.0)) +(( data["Employment_Info_1"] >(( data["Medical_History_4"] >(( np.minimum(( data["Medical_History_4"]),(data["Medical_History_15"])) <= data["Medical_Keyword_45"] ).astype(float)) ).astype(float)) ).astype(float)))/2.0)/ 2.0)+
np.minimum(((( np.round(((data["BMI"] > 0.367879 ).astype(float)))- data["BMI"])* data["Product_Info_4"])) ,(np.minimum(((( data["Insurance_History_7"] < data["Product_Info_2_N"] ).astype(float))),(((data["BMI"] + np.floor(( data["Product_Info_4"] - 0.058823)))/2.0)))))+
np.minimum(( np.sin(( data["Medical_History_35"] + np.power(np.abs(-2.0), data["Medical_History_11"])))) ,(( np.sin(((((data["Medical_History_39"] <=(( data["Medical_Keyword_3"] < data["SumMedicalKeywords"] ).astype(float)) ).astype(float)) +(-(((data["Medical_History_39"] < np.sinh(data["Medical_Keyword_3"])).astype(float)))))/2.0)) * 2.0)))+ 
(((( -(((((data["SumInsuranceHistory"] - data["Medical_History_15"])< data["Medical_Keyword_37"] ).astype(float)) / 2.0)))-(( data["Medical_Keyword_37"] + data["Employment_Info_1"])/2.0)) + np.floor(np.power(np.abs(data["Medical_Keyword_41"]), np.power(np.abs(data["BMI"]), data["Medical_History_15"])))) /2.0)+ 
(np.minimum(((0.058823 * np.cos(data["SumEmploymentInfo"]))),(np.minimum(((((data["Medical_History_39"] < data["Product_Info_2_N"] ).astype(float)) / 2.0)) ,(np.minimum(( data["Employment_Info_1"]),(((data["BMI"] * 2.0)- np.sinh(data["Ins_Age"])))))))) * 2.0)+ 
(((((( 0.720430 <= data["Ins_Age"] ).astype(float)) * data["BMI"])+ np.power(np.abs(np.round(( data["Ins_Age"] * np.sinh(data["BMI"])))) , data["Medical_History_11"])) /2.0)-(( data["Medical_History_23"] <=(( data["Medical_Keyword_16"] >= data["SumMedicalKeywords"] ).astype(float)) ).astype(float)))+
np.minimum(( data["Medical_Keyword_38"]),(( data["Medical_Keyword_3"] + np.minimum(((( -(data["Medical_Keyword_18"])) / 2.0)) ,(np.sinh(np.floor(np.minimum(( data["Employment_Info_1"]),(np.floor(np.sinh(np.floor(( data["Insurance_History_5"] * np.round(np.cos(data["Insurance_History_7"])))))))))))))))+ 
(((( data["BMI"] <=(np.cos(( data["Medical_History_4"] *(1.0/(1.0 + np.exp(- data["Medical_History_11"])))))/ 2.0)).astype(float)) +(((data["Medical_Keyword_19"] +(-(((data["Product_Info_4"] < data["Medical_Keyword_24"] ).astype(float)))))+(( data["Product_Info_4"] >= data["Medical_History_4"] ).astype(float)))/2.0)) /2.0)+
np.minimum(( np.cos(((((data["Medical_History_20"] >= data["SumMedicalKeywords"] ).astype(float)) + data["Medical_History_30"])/2.0))),(np.minimum(((( -(np.power(np.abs(data["Ht"]), data["SumEmploymentInfo"])))/ 2.0)) ,(( -(((data["Ins_Age"] >= np.sin(((data["Medical_History_20"] > data["Medical_Keyword_31"] ).astype(float)))).astype(float)))))))) + 
(1.0/(1.0 + np.exp(-(np.maximum(( data["Insurance_History_2"]),(data["Insurance_History_1"])) -(np.power(np.abs(data["Medical_History_11"]), np.power(np.abs(data["Insurance_History_1"]), np.maximum(( np.round(data["BMI"])) ,(np.maximum(( data["Ins_Age"]),(data["SumMedicalKeywords"])))))) - np.minimum(( data["SumMedicalKeywords"]),(data["Family_Hist_3"])))))))+
np.minimum(((((( data["SumMedicalKeywords"] + data["Medical_History_15"])/2.0)+ np.cos(data["InsuredInfo_5"])) /2.0)) ,(( -(np.power(np.abs(data["Wt"]), np.maximum(( data["Medical_History_23"]),(((data["SumMedicalKeywords"] +(8.0 *(( data["Medical_History_15"] < 8.0 ).astype(float)))) /2.0)))))))) +
np.minimum(( np.power(np.abs(data["BMI"]), data["Medical_History_23"])) ,(((((np.power(np.abs(data["Medical_History_15"]), data["Product_Info_3"])>=(data["Medical_Keyword_28"] + np.round(data["BMI"])) ).astype(float)) < np.maximum(( data["Medical_History_5"]),(data["InsuredInfo_7"])) ).astype(float)))) +
np.minimum(((data["Medical_Keyword_38"] +(data["Ins_Age"] *(-(((data["Medical_Keyword_47"] +(( data["InsuredInfo_6"] < data["Medical_History_18"] ).astype(float)))/2.0)))))) ,(( -(((data["Medical_History_20"] <=(( data["InsuredInfo_1"] +(( data["Insurance_History_2"] + data["Medical_Keyword_47"])/2.0)) /2.0)).astype(float)))))) + 
(((data["Medical_History_21"] > data["Medical_History_7"] ).astype(float)) +(( -(((1.414214 <(data["Medical_History_5"] *(((data["Medical_History_15"] <(data["Ins_Age"] - data["Medical_History_28"])).astype(float)) - data["Ins_Age"])) ).astype(float)))) * 2.0)) + 
(((0.138462 * np.sin(((-(0.138462)) *(data["Medical_History_2"] / 2.0)))) +(( data["Medical_History_39"] <(( data["Medical_History_30"] +(((data["Medical_Keyword_3"] >= 0.138462 ).astype(float)) * np.maximum(( data["Medical_Keyword_24"]),(data["Medical_Keyword_40"])))) /2.0)).astype(float)))/2.0)+ 
(((((data["Medical_History_39"] < data["Medical_History_41"] ).astype(float)) +(np.tanh(((((data["Medical_History_1"] > np.maximum(( np.minimum(( 9.869604),(( data["Medical_History_39"] / 2.0)))) ,(9.869604)) ).astype(float)) + data["Medical_Keyword_34"])/2.0)) -(( data["Medical_History_39"] < data["InsuredInfo_6"] ).astype(float)))) /2.0)/ 2.0)+ 
(((np.minimum(( data["Medical_Keyword_39"]),(data["Medical_Keyword_47"])) + np.power(np.abs(((data["Medical_Keyword_14"] >(-(np.minimum(( data["Medical_History_10"]),(( data["Medical_Keyword_37"] + data["Medical_Keyword_24"])))))).astype(float))), np.sinh(( data["Medical_History_40"] + np.maximum(( data["Medical_History_1"]),(data["Family_Hist_2"])))))) /2.0)* 2.0)+
np.minimum(( np.cos(( data["BMI"] * 2.0))),(( np.minimum(( np.cos(( data["Medical_History_4"] - np.sinh(data["BMI"])))) ,(((data["Medical_History_4"] >(np.sinh(data["BMI"])+ np.floor(np.ceil(( data["BMI"] * 2.0)))) ).astype(float)))) * 2.0)))+ 
(0.138462 *(((((data["SumMedicalKeywords"] < np.cos(data["Product_Info_2_C"])).astype(float)) >= np.sin(((data["Product_Info_3"] + data["SumMedicalKeywords"])/2.0)) ).astype(float)) -(( data["Medical_History_24"] >=(-(( data["Medical_History_4"] * np.sin(data["Medical_Keyword_23"])))) ).astype(float)))) + 
(np.maximum(((0.318310 *(( data["BMI"] < np.minimum(((1.0/(1.0 + np.exp(- np.sin(data["Medical_History_32"]))))),(( np.sin(data["Medical_History_40"])* 2.0)))).astype(float)))) ,(((data["Medical_History_18"] > data["Medical_History_40"] ).astype(float)))) -(( 9.869604 > data["Product_Info_3"] ).astype(float))))
return p
def Individual5(data):
p =(( 5.428570 -(( data["BMI"] +(((data["BMI"] +(((data["Medical_Keyword_3"] -(data["Product_Info_4"] - data["SumMedicalKeywords"])) - np.cos(data["BMI"])) - data["Medical_History_23"])) /2.0)- np.sin(data["Medical_History_4"])))/2.0)) + 
(np.tanh(((data["Medical_History_40"] +(data["Medical_History_15"] -(((( data["InsuredInfo_5"] + data["Medical_History_5"])/2.0)+(data["Insurance_History_2"] +(data["Medical_History_30"] - data["Medical_History_4"])))/2.0)))/2.0)) -(( np.ceil(data["Product_Info_4"])< data["InsuredInfo_7"] ).astype(float)))+
np.tanh(( np.abs(data["Medical_Keyword_41"])+(data["Medical_History_27"] + np.minimum(( data["Medical_History_20"]),(((data["BMI"] +(((data["Family_Hist_4"] +(( data["Medical_History_39"] + data["Medical_History_13"])+ data["InsuredInfo_6"])) /2.0)+ data["Medical_History_11"])) /2.0)))))) + 
(((( data["Medical_Keyword_38"] < data["Medical_History_24"] ).astype(float)) +(( np.minimum(( data["Insurance_History_5"]),(((np.minimum(((-(np.maximum(( data["Medical_History_18"]),(data["Medical_Keyword_38"]))))),(np.minimum(( data["Medical_History_40"]),(data["Medical_History_7"])))) + data["SumMedicalKeywords"])/2.0)))+(( data["InsuredInfo_5"] < data["Product_Info_2_N"] ).astype(float)))/2.0)) /2.0)+
np.minimum(((1.414214 - data["Ins_Age"])) ,(np.minimum(( np.cos(( data["Medical_History_28"] * data["Employment_Info_3"]))),(np.minimum(( np.cos(np.floor(data["Product_Info_4"]))),(np.tanh(( np.tanh(data["Medical_History_31"])-(( data["Medical_History_5"] + data["Medical_History_35"])/2.0)))))))))+ 
(( data["BMI"] *(((((data["Ins_Age"] +(( -(data["Medical_History_4"])) * 2.0)) /2.0)+(((-(data["Wt"])) +(data["SumMedicalKeywords"] * 2.0)) /2.0)) /2.0)/ 2.0)) / 2.0)+ 
(( np.minimum(( np.cos(data["InsuredInfo_1"])) ,(np.tanh(( -(data["InsuredInfo_5"])))))+(( np.tanh(data["Medical_History_1"])+(((np.maximum(( data["Medical_Keyword_25"]),(( np.maximum(( data["Medical_Keyword_6"]),(data["Medical_Keyword_45"])) + data["InsuredInfo_6"])))+ data["Medical_Keyword_22"])/2.0)/ 2.0)) /2.0)) /2.0)+
np.sin(np.round(np.minimum(((np.minimum(( data["Medical_History_11"]),(np.minimum(( data["Medical_History_40"]),(np.minimum(( data["Medical_History_11"]),(data["Medical_History_17"])))))) * 2.0)) ,(np.minimum(( data["Medical_History_33"]),(( -(((data["InsuredInfo_2"] > np.tanh(( data["Medical_History_35"] * data["Medical_Keyword_9"])) ).astype(float)))))))))) +
np.sin(np.maximum(( np.minimum(( np.cos(( data["Medical_Keyword_3"] - data["Medical_Keyword_48"]))),(np.minimum(( np.cos(data["SumEmploymentInfo"])) ,(((np.tanh(np.sin(np.ceil(data["Medical_History_15"])))+(( data["Product_Info_2_C"] >= np.cos(data["Medical_Keyword_33"])).astype(float)))/2.0)))))) ,(data["Medical_Keyword_33"])))+
np.sin(np.minimum(((( data["Product_Info_2_N"] + np.abs(data["Product_Info_2_C"])) /2.0)) ,(np.minimum(( 0.367879),(np.maximum(( data["Medical_Keyword_29"]),(( data["Medical_Keyword_38"] * data["Medical_History_30"])))))))) + 
(0.058823 *(((data["Medical_Keyword_3"] *(data["SumMedicalKeywords"] + np.floor(np.minimum(((data["Medical_Keyword_15"] + data["Family_Hist_5"])) ,(data["Medical_History_30"])))))+(data["Family_Hist_2"] + data["Family_Hist_5"])) +(( data["SumMedicalKeywords"] + data["Medical_History_33"])/2.0)))+
np.minimum(((( data["Product_Info_4"] < np.floor(data["InsuredInfo_7"])).astype(float))),(((((data["Medical_History_20"] >(( data["Product_Info_4"] < np.tanh(((( np.tanh(np.tanh(data["Product_Info_4"])) + np.floor(np.floor(data["InsuredInfo_7"])))/2.0)* 2.0)) ).astype(float)) ).astype(float)) + data["BMI"])/2.0)))+
np.tanh(np.tanh(( np.minimum(( data["BMI"]),(((data["Medical_History_40"] + data["Medical_History_15"])/2.0)))* np.minimum(( np.tanh(((( 1.0/(1.0 + np.exp(- data["Medical_History_15"])))>(-(np.tanh(data["Medical_History_15"])))).astype(float)))) ,(( -(np.tanh(data["Medical_History_15"])))))))) + 
(((( data["Ins_Age"] *(( data["Medical_History_33"] <=(data["Ins_Age"] *(((( data["Medical_History_38"] >= data["Medical_History_38"] ).astype(float)) <= data["BMI"] ).astype(float)))).astype(float)))/ 2.0)+(data["Ins_Age"] * np.tanh(data["Medical_History_5"])))/2.0)+
np.minimum(( 0.318310),(np.minimum(((((( data["Employment_Info_1"] + data["Medical_Keyword_21"])/2.0)+(( data["Medical_History_6"] >= np.floor(data["Insurance_History_8"])).astype(float)))/2.0)) ,(np.sinh(np.floor(np.sinh(( data["Insurance_History_5"] *(( data["Insurance_History_4"] <= np.tanh(data["Employment_Info_2"])).astype(float)))))))))) +
np.minimum(( 0.138462),(((( -(np.floor(np.abs(( data["Product_Info_2_N"] * data["Product_Info_2_N"])))))>= np.minimum(( data["Product_Info_2_C"]),(np.round(np.abs(np.minimum(( np.sin(data["Medical_History_2"])) ,(data["SumMedicalKeywords"])))))) ).astype(float)))) + 
(-(((( math.sin(-1.0)/ 2.0)< np.minimum(( np.ceil(( data["Insurance_History_2"] -(( np.minimum(( np.sin(data["Medical_Keyword_40"])) ,(( -(data["Medical_Keyword_40"])))) < data["Medical_History_15"] ).astype(float))))),(data["Medical_History_15"])) ).astype(float)))) +
np.abs(( np.cos(((data["Medical_Keyword_19"] > data["Medical_History_15"] ).astype(float)))*(((np.tanh(data["Insurance_History_2"])-(( data["Medical_History_15"] >(( np.cos(((data["Insurance_History_2"] > data["Medical_History_4"] ).astype(float)))+ data["Medical_History_4"])/2.0)).astype(float)))>= np.round(data["Medical_History_4"])).astype(float)))) + 
(0.058823 *(( data["InsuredInfo_6"] + np.minimum(( data["Medical_Keyword_15"]),(( data["InsuredInfo_6"] * data["Medical_History_18"])))) +(( data["Medical_Keyword_28"] +(( -(data["Medical_History_19"])) +(( data["Medical_Keyword_3"] * data["InsuredInfo_6"])+ data["Medical_Keyword_19"])))/2.0)))+
np.minimum(( np.maximum(( data["Medical_History_23"]),(data["SumMedicalKeywords"]))),(np.minimum(((np.sin(np.maximum(( data["Medical_History_17"]),(np.floor(data["SumMedicalKeywords"])))) / 2.0)) ,(((data["InsuredInfo_7"] >=(( data["Medical_Keyword_38"] * data["SumMedicalKeywords"])* data["Medical_Keyword_2"])).astype(float)))))) + 
(0.138462 *(( np.cos(( np.sinh(data["BMI"])* 2.0)) + np.cos(((((np.round(data["Medical_History_4"])< data["Ins_Age"] ).astype(float)) - np.sinh(((np.abs(data["Medical_History_22"])< np.sinh(data["BMI"])).astype(float)))) * 2.0)))/2.0)) +
np.minimum(((np.sin(data["Medical_Keyword_32"])*(( data["Employment_Info_2"] >(np.floor(data["Employment_Info_2"])-(np.minimum(( data["Medical_Keyword_37"]),(3.0)) * 2.0)) ).astype(float)))) ,(np.maximum(( np.sin(data["Medical_History_18"])) ,(data["Medical_History_22"])))) +
np.sin(( data["Medical_History_4"] * np.maximum(( data["Medical_Keyword_3"]),(np.sin(( data["Medical_History_4"] * np.minimum(( 0.094340),(((np.maximum(( data["Medical_Keyword_34"]),(data["InsuredInfo_5"])) >(( -(data["Medical_Keyword_15"])) + data["Medical_History_1"])).astype(float)))))))))) +
np.sin(( np.sin(( np.maximum(( data["Medical_History_38"]),(np.round(( data["Medical_History_35"] +(-(((data["Medical_Keyword_24"] > np.minimum(((data["Medical_History_7"] * data["Ht"])) ,(np.maximum(( data["Employment_Info_2"]),(data["Medical_History_13"])))) ).astype(float)))))))) * 2.0)) * 2.0)) + 
(((((( np.minimum(( data["BMI"]),(data["Insurance_History_2"])) >(np.cos(np.cos(data["InsuredInfo_6"])) - np.minimum(( data["Ins_Age"]),(np.abs(data["InsuredInfo_6"])))) ).astype(float)) >= np.tanh(((1.584910 + data["SumInsuredInfo"])/2.0)) ).astype(float)) / 2.0)/ 2.0)+ 
(np.minimum(( np.maximum(((np.minimum(( data["Medical_History_18"]),(data["Medical_History_10"])) * 2.0)) ,(( -(np.minimum(( 5.200000),(data["BMI"]))))))),(np.minimum(( np.tanh(data["SumMedicalKeywords"])) ,(np.round(data["SumMedicalKeywords"])))))*(((data["Medical_History_18"] > data["Medical_History_6"] ).astype(float)) / 2.0)) +
np.tanh(((((((((data["InsuredInfo_1"] < data["BMI"] ).astype(float)) <(( data["InsuredInfo_1"] < data["Medical_History_12"] ).astype(float)) ).astype(float)) <(data["Medical_History_27"] *(data["Medical_History_20"] * data["Medical_History_5"])) ).astype(float)) * data["BMI"])/ 2.0)) + 
(((( data["Medical_History_9"] >(( data["Medical_History_32"] <=(20.750000 + data["InsuredInfo_5"])).astype(float)) ).astype(float)) >=(( np.minimum(( data["InsuredInfo_5"]),(data["Medical_Keyword_1"])) <=(-(np.minimum(( data["InsuredInfo_5"]),(np.minimum(( data["InsuredInfo_6"]),(np.cos(data["Medical_History_40"])))))))).astype(float)) ).astype(float)))
 return p
def Individual6(data):
p =(((5.200000 + np.sin(((data["Medical_History_23"] >(( data["Medical_Keyword_3"] + data["BMI"])/2.0)).astype(float)))) -(((( data["Medical_Keyword_3"] + np.maximum(( data["BMI"]),(data["SumMedicalKeywords"])))/2.0)+(data["BMI"] - data["Medical_History_4"])) /2.0)) + 
(((( data["Medical_History_15"] + np.minimum(((data["Medical_History_40"] - data["Insurance_History_2"])) ,(np.minimum(((data["Product_Info_4"] - data["Medical_History_30"])) ,(np.ceil(( data["Medical_History_13"] - data["InsuredInfo_5"])))))))/2.0)+ np.tanh(( np.ceil(data["Product_Info_4"])- data["InsuredInfo_7"])))/2.0)+
np.minimum(( np.tanh(((data["Medical_History_27"] + np.minimum(( data["Medical_History_11"]),(( np.minimum(( data["Medical_History_31"]),(( np.round(((data["Medical_History_7"] + data["Product_Info_4"])/2.0)) + data["Medical_History_20"])))* 2.0)))) /2.0))),(np.cos(np.maximum(( data["Ins_Age"]),(np.sinh(data["Medical_History_5"])))))) + 
(((((data["InsuredInfo_6"] +(( data["Medical_History_15"] + data["BMI"])- data["Medical_History_18"])) /2.0)+(((( data["Medical_Keyword_25"] - data["Employment_Info_3"])+ data["Insurance_History_3"])+(data["Product_Info_2_N"] +(data["Family_Hist_4"] + data["Medical_Keyword_41"])))/2.0)) /2.0)/ 2.0)+
np.sin(((np.maximum(( data["InsuredInfo_2"]),(np.maximum(( np.floor(data["Product_Info_2_C"])) ,(((data["Medical_History_24"] > data["Medical_History_38"] ).astype(float)))))) + np.sin(((((data["Medical_History_1"] +(( data["Medical_Keyword_33"] + data["Medical_History_4"])/2.0)) /2.0)+(data["Medical_History_5"] * data["Medical_Keyword_3"])) /2.0)))/2.0)) +
np.sin(np.minimum(((data["Medical_History_15"] *(((((data["Medical_History_17"] <=(( 0.720430 + data["Medical_History_15"])/2.0)).astype(float)) * 2.0)-(( data["Product_Info_3"] <= data["Insurance_History_2"] ).astype(float)))* 2.0))),(( data["Medical_History_11"] * 2.0)))) + 
(np.cos(8.0)* np.round(((( data["Medical_Keyword_38"] + data["Medical_History_35"])+(data["InsuredInfo_1"] -(data["Family_Hist_2"] + np.maximum(( np.maximum(( data["Medical_Keyword_34"]),(data["InsuredInfo_5"]))),(data["Medical_Keyword_22"])))))/2.0)))+
np.minimum(( np.tanh(((1.0/(1.0 + np.exp(- data["InsuredInfo_6"])))*(( data["InsuredInfo_6"] + np.cos(data["Medical_History_15"])) /2.0)))) ,(((np.cos(( data["BMI"] -(( data["Medical_History_4"] <(1.0/(1.0 + np.exp(- data["Ins_Age"])))).astype(float)))) + data["Medical_History_15"])/2.0)))+ 
(( np.sin(np.maximum(( data["Medical_History_28"]),(( data["Employment_Info_3"] * data["Medical_History_40"])))) +(( np.maximum(( np.minimum(( data["Medical_History_40"]),(np.cos(((((data["InsuredInfo_5"] + data["Medical_History_40"])/2.0)+ data["Insurance_History_2"])/2.0))))),(data["Medical_History_4"])) < data["Medical_Keyword_19"] ).astype(float)))/2.0)+ 
(0.094340 *(( np.minimum(((data["Medical_History_6"] - data["Medical_Keyword_9"])) ,(np.minimum(( data["Medical_History_39"]),(data["Medical_History_33"])))) +(((data["SumMedicalKeywords"] * data["Ins_Age"])- data["Family_Hist_4"])-(data["Ins_Age"] + data["Product_Info_4"])))/2.0)) +
np.sin(np.sin(np.sin(( 0.138462 *(((data["Medical_Keyword_45"] + data["Medical_Keyword_15"])/2.0)+ np.cos(( np.ceil(data["Product_Info_2_N"])- np.floor(((data["Product_Info_2_N"] < np.power(np.abs(data["Medical_History_21"]), data["Medical_History_21"])).astype(float)))))))))) +
np.minimum(((( np.tanh(data["Medical_History_16"])> data["Medical_History_15"] ).astype(float))),(np.sin(np.round(np.maximum(((data["InsuredInfo_2"] * data["Medical_History_5"])) ,(( np.minimum(( 1.584910),(( -(data["Medical_History_4"])))) * 2.0)))))))+ 
(np.minimum(( np.minimum(((np.minimum(((1.0/(1.0 + np.exp(- data["Product_Info_2_C"])))) ,(data["Medical_Keyword_32"])) * data["Product_Info_2_C"])) ,(np.cos(np.maximum(( np.tanh(data["Product_Info_2_C"])) ,(data["Ins_Age"])))))) ,(((data["Employment_Info_1"] +(( data["Medical_History_33"] > data["Insurance_History_8"] ).astype(float)))/2.0)))/ 2.0)+ 
(((( data["Medical_History_40"] - data["Medical_History_30"])<(( np.sin(data["Medical_Keyword_2"])< data["Medical_Keyword_40"] ).astype(float)) ).astype(float)) *(( data["Medical_Keyword_3"] >=(((( data["Medical_Keyword_32"] * data["Medical_History_30"])* data["Medical_Keyword_3"])+ data["Medical_History_11"])/2.0)).astype(float)))+
np.minimum(((data["SumMedicalKeywords"] *(( data["Medical_History_18"] >= data["Medical_History_39"] ).astype(float)))) ,(np.minimum(( 0.058823),(np.maximum(( data["Wt"]),(np.minimum(( np.sin(np.ceil(data["Product_Info_4"]))),(( data["InsuredInfo_6"] *(( data["Medical_History_19"] > data["Medical_History_39"] ).astype(float)))))))))))+
np.minimum(((0.138462 *(((( data["Medical_History_23"] <=(data["Medical_Keyword_25"] - data["Medical_History_13"])).astype(float)) <=(data["Medical_Keyword_12"] - data["Product_Info_4"])).astype(float)))) ,(((0.094340 - np.minimum(((( data["InsuredInfo_5"] < data["Product_Info_4"] ).astype(float))),(data["BMI"])))/ 2.0)))+ 
(( np.tanh(((data["Medical_History_23"] >=(( data["BMI"] < np.sinh(np.power(np.abs(0.094340), data["Medical_History_32"])) ).astype(float)) ).astype(float)))+ np.sin(( data["Medical_History_13"] * np.floor(((data["Insurance_History_2"] >= data["Medical_History_40"] ).astype(float)))))) /2.0)+ 
(((data["Medical_History_22"] <(((np.cos(np.minimum(( data["Medical_History_22"]),(np.floor(((266)* data["Medical_History_15"])))))* np.cos(data["Medical_Keyword_3"])) < data["Medical_History_19"] ).astype(float)) ).astype(float)) * np.minimum(( data["Insurance_History_2"]),(( data["Medical_History_41"] / 2.0)))) +
np.sinh(( np.floor(np.cos(((data["Insurance_History_5"] - 0.367879)+(data["Insurance_History_7"] + np.minimum(( data["Insurance_History_5"]),(( data["Insurance_History_5"] +(data["Insurance_History_4"] - 31.006277)))))))) * 2.0)) + 
(np.sin(((((data["Medical_Keyword_28"] > np.cos(data["Medical_Keyword_6"])).astype(float)) >= np.cos(np.maximum(( np.minimum(( np.round(data["Family_Hist_5"])) ,(data["BMI"]))),(((data["Medical_Keyword_3"] *(( data["InsuredInfo_6"] > data["Medical_History_36"] ).astype(float)))+ data["Medical_Keyword_2"])))) ).astype(float)))/ 2.0)+
np.minimum(((( np.sin(data["Medical_Keyword_41"])>= data["Medical_History_15"] ).astype(float))),(((data["SumMedicalKeywords"] *(( data["Medical_History_5"] >= np.minimum(((( data["SumMedicalKeywords"] *(((( data["InsuredInfo_5"] >= data["Medical_History_20"] ).astype(float)) >= data["Medical_History_31"] ).astype(float)))/ 2.0)) ,(data["Medical_History_17"])) ).astype(float)))/ 2.0)))+
np.tanh(( data["Medical_History_4"] * np.sinh(( np.minimum(( np.minimum(((((( -(data["BMI"])) * data["Product_Info_5"])>= data["Medical_History_17"] ).astype(float))),(np.maximum(( 0.138462),(data["Medical_History_15"]))))),(np.maximum(((-(data["BMI"]))),(data["Medical_History_15"])))) / 2.0)))) + 
(np.tanh(np.sin(np.tanh(np.sin(data["Medical_Keyword_12"])))) * np.minimum(( np.cos(np.floor(( -(( data["Medical_History_2"] *(997))))))),(np.cos(( -(((data["Medical_History_2"] * 8.0)*(997)))))))) + 
(0.058823 * np.minimum(( np.power(np.abs(data["Product_Info_4"]),(( 112)*(( data["Product_Info_4"] <= data["Medical_Keyword_15"] ).astype(float))))),(((data["Medical_Keyword_15"] * 2.0)+(np.cos(((1.630430 * data["Employment_Info_2"])* 2.0)) + data["Medical_History_29"])))))+ 
(( data["Ins_Age"] *(((( data["Medical_History_5"] >= np.cos(np.power(np.abs(data["BMI"]),(np.abs(((data["Ins_Age"] + data["BMI"])/2.0)) / 2.0)))).astype(float)) >= np.cos(((np.power(np.abs(data["Ins_Age"]), data["Medical_Keyword_23"])/ 2.0)/ 2.0)) ).astype(float)))/ 2.0)+
np.sin(np.maximum(( data["Medical_Keyword_29"]),(np.maximum(( data["Medical_Keyword_25"]),(np.tanh(((( data["Medical_Keyword_8"] * data["Medical_History_18"])>= np.abs(((( np.maximum(((data["Medical_History_15"] / 2.0)) ,(data["Medical_Keyword_29"])) + data["Medical_Keyword_29"])/2.0)-(data["Medical_History_15"] / 2.0)))).astype(float)))))))) +
np.tanh(((data["InsuredInfo_5"] * np.maximum(((( np.floor(data["Medical_History_40"])*(1.584910 - data["InsuredInfo_1"])) / 2.0)) ,(np.minimum(( data["Employment_Info_3"]),(( 5.428570 *(( data["Medical_History_28"] > data["Medical_Keyword_38"] ).astype(float)))))))) * 2.0)) +
np.minimum(((( data["Medical_History_27"] >=(( data["Medical_History_10"] <(2.44962)).astype(float)) ).astype(float))),(np.sin(np.sin(np.ceil(np.maximum(( data["SumMedicalHistory"]),(np.maximum(( data["SumEmploymentInfo"]),(np.maximum(( data["SumMedicalHistory"]),(( data["Medical_History_11"] * data["Ht"])))))))))))))
 return p
def MungeData(train, test):
le = LabelEncoder()
train.Product_Info_2.fillna('Z0', inplace=True)
 test.Product_Info_2.fillna('Z0', inplace=True)
 train.insert(0, 'Product_Info_2_N', train.Product_Info_2.str[1:])
 train.insert(0, 'Product_Info_2_C', train.Product_Info_2.str[0])
 train.drop('Product_Info_2', inplace=True, axis=1)
 test.insert(0, 'Product_Info_2_N', test.Product_Info_2.str[1:])
 test.insert(0, 'Product_Info_2_C', test.Product_Info_2.str[0])
 test.drop('Product_Info_2', inplace=True, axis=1)
 le.fit(list(train.Product_Info_2_C)+list(test.Product_Info_2_C))
train.Product_Info_2_C = le.transform(train.Product_Info_2_C)
 test.Product_Info_2_C = le.transform(test.Product_Info_2_C)
 trainids = train.Id
testids = test.Id
train.drop('Id', axis=1, inplace=True)
 test.drop('Id', axis=1, inplace=True)
 responses = train.Response.values
train.drop('Response', inplace=True, axis=1)
 train = train.astype(float)
 test = test.astype(float)
 train.insert(0,
'SumNAs',
len(train.columns)-train.count(axis=1))
test.insert(0,
'SumNAs',
len(test.columns)-test.count(axis=1))
train.insert(0,
'SumMedicalKeywords',
train[train.columns[train.columns.str.contains('Medical_Keyword')]] 
.sum(axis=1, skipna=True))
test.insert(0,
'SumMedicalKeywords',
test[test.columns[test.columns.str.contains('Medical_Keyword')]] 
.sum(axis=1, skipna=True))
train.insert(0,
'SumFamilyHistory',
train[train.columns[train.columns.str.contains('Family_Hist')]] 
.sum(axis=1, skipna=True))
test.insert(0,
'SumFamilyHistory',
test[test.columns[test.columns.str.contains('Family_Hist')]] 
.sum(axis=1, skipna=True))
train.insert(0,
'SumInsuranceHistory',
train[train.columns[train.columns.str 
.contains('Insurance_History')]] 
.sum(axis=1, skipna=True))
test.insert(0,
'SumInsuranceHistory',
test[test.columns[test.columns.str.contains('Insurance_History')]] 
.sum(axis=1, skipna=True))
train.insert(0,
'SumInsuredInfo',
train[train.columns[train.columns.str.contains('InsuredInfo')]] 
.sum(axis=1, skipna=True))
test.insert(0,
'SumInsuredInfo',
test[test.columns[test.columns.str.contains('InsuredInfo')]] 
.sum(axis=1, skipna=True))
train.insert(0,
'SumEmploymentInfo',
train[train.columns[train.columns.str.contains('Employment_Info')]] 
.sum(axis=1, skipna=True))
test.insert(0,
'SumEmploymentInfo',
test[test.columns[test.columns.str.contains('Employment_Info')]] 
.sum(axis=1, skipna=True))
train.insert(0,
'SumMedicalHistory',
train[train.columns[train.columns.str.contains('Medical_History')]] 
.sum(axis=1, skipna=True))
test.insert(0,
'SumMedicalHistory',
test[test.columns[test.columns.str.contains('Medical_History')]] 
.sum(axis=1, skipna=True))
train.fillna(-1, inplace=True)
 test.fillna(-1, inplace=True)
 train['Response'] = responses
train.insert(0, 'Id', trainids)
 test.insert(0, 'Id', testids)
 return train, test
if __name__ == "__main__":
ss = StandardScaler()
train = pd.read_csv(".. /input/train.csv")
 test = pd.read_csv(".. /input/test.csv")
 train, test = MungeData(train, test)
 features = train.columns[1:-1]
scaledtrain = train.copy()
scaledtest = test.copy()
scaledtrain[features] = ss.fit_transform(scaledtrain[features])
 scaledtrain[features] = np.round(scaledtrain[features],6)
 scaledtest[features] = ss.transform(scaledtest[features])
 scaledtest[features] = np.round(scaledtest[features],6)
 train[features] = np.round(train[features],6)
 test[features] = np.round(test[features],6)
 trainindividual1 = np.clip(Individual1(scaledtrain),1,8)
 trainindividual2 = np.clip(Individual2(scaledtrain),1,8)
 trainindividual3 = np.clip(Individual3(scaledtrain),1,8)
 trainindividual4 = np.clip(Individual4(train),1,8)
 trainindividual5 = np.clip(Individual5(scaledtrain),1,8)
 trainindividual6 = np.clip(Individual6(scaledtrain),1,8)
 testindividual1 = np.clip(Individual1(scaledtest),1,8)
 testindividual2 = np.clip(Individual2(scaledtest),1,8)
 testindividual3 = np.clip(Individual3(scaledtest),1,8)
 testindividual4 = np.clip(Individual4(test),1,8)
 testindividual5 = np.clip(Individual5(scaledtest),1,8)
 testindividual6 = np.clip(Individual6(scaledtest),1,8)
 trainPredictions =(trainindividual1+trainindividual2+trainindividual3+trainindividual4+trainindividual5+trainindividual6)/6.
 testPredictions =(testindividual1+testindividual2+testindividual3+testindividual4+testindividual5+testindividual6)/6.
 cutoffs = [2.951759, 3.653780, 4.402781, 4.911808, 5.543988, 6.135754, 6.716891]
trainPredictions = np.digitize(trainPredictions,cutoffs)+1
testPredictions = np.digitize(testPredictions,cutoffs)+1
pdtrain = pd.DataFrame({"Id": train.Id.astype(int), "Prediction":trainPredictions.astype(int), "Response": train.Response.astype(int)})
 pdtrain = pdtrain.set_index('Id')
 pdtrain.to_csv('gptrain.csv')
 pdtest = pd.DataFrame({"Id": test.Id.astype(int), "Response": testPredictions.astype(int)})
 pdtest = pdtest.set_index('Id')
 pdtest.to_csv('gptest.csv')
<load_from_disk>
start = time.time()
params = {
'metric': 'rmse',
'objective': 'mse',
'verbose': 0,
'learning_rate': 0.1,
'num_leaves': 31,
'min_data_in_leaf': 20 ,
'max_depth': -1,
'save_binary': True,
'bagging_fraction': 0.8,
'bagging_freq': 1,
'bagging_seed': 2**7,
'feature_fraction': 0.8,
}
lgbm_model = create_lgbm_model(X_train, y_train, X_val, y_val, params, categorical_features)
 print('it tooks: ', round(time.time() - start), 'seconds' )
train_df=pd.read_json('.. /input/train.json')
 test_df=pd.read_json('.. /input/test.json' )<feature_engineering>
start = time.time()
evaluate_model(lgbm_model, X_train, y_train, X_val, y_val)
 print('it tooks: ', round(time.time() - start), 'seconds' )
train_df["price_t"] =train_df["price"]/train_df["bedrooms"]
test_df["price_t"] = test_df["price"]/test_df["bedrooms"]
train_df["room_sum"] = train_df["bedrooms"]+train_df["bathrooms"]
test_df["room_sum"] = test_df["bedrooms"]+test_df["bathrooms"]
train_df["num_photos"] = train_df["photos"].apply(len)
 test_df["num_photos"] = test_df["photos"].apply(len)
 train_df["num_features"] = train_df["features"].apply(len)
 test_df["num_features"] = test_df["features"].apply(len)
 train_df["num_description_words"] = train_df["description"].apply(lambda x: len(x.split(" ")))
 test_df["num_description_words"] = test_df["description"].apply(lambda x: len(x.split(" ")))
 features_to_use=["bathrooms", "bedrooms", "latitude", "longitude", "price","price_t","num_photos", "num_features", "num_description_words","listing_id"]<train_model>
y_test_pred = lgbm_model.predict(X_test ).clip(0, 20)
 submission = pd.DataFrame({
"ID": test.ID,
"item_cnt_month": y_test_pred
})
 submission.to_csv('lgbm_submission.csv', index = False )