{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":82611,"databundleVersionId":9553358,"sourceType":"competition"}],"dockerImageVersionId":30786,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\nfrom sklearn.preprocessing import MinMaxScaler\nfrom sklearn.model_selection import GroupKFold\nfrom sklearn.impute import SimpleImputer\nfrom sklearn.metrics import mean_squared_error\n\nimport lightgbm as lgb\n\nimport tensorflow as tf\nfrom keras.utils import plot_model\nimport tensorflow.keras.backend as K\n\nimport gc,os,random\nimport warnings\nwarnings.filterwarnings(\"ignore\")","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2024-11-29T11:34:47.651902Z","iopub.execute_input":"2024-11-29T11:34:47.652317Z","iopub.status.idle":"2024-11-29T11:35:08.128606Z","shell.execute_reply.started":"2024-11-29T11:34:47.652279Z","shell.execute_reply":"2024-11-29T11:35:08.127339Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def set_seeds(seed):\n    os.environ['PYTHONHASHSEED'] = str(seed)\n    random.seed(seed)\n    tf.random.set_seed(seed)\n    np.random.seed(seed)\n\nset_seeds(seed=2024)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-29T11:35:08.130925Z","iopub.execute_input":"2024-11-29T11:35:08.131860Z","iopub.status.idle":"2024-11-29T11:35:08.139345Z","shell.execute_reply.started":"2024-11-29T11:35:08.131801Z","shell.execute_reply":"2024-11-29T11:35:08.138054Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train=pd.read_csv('/kaggle/input/brist1d/train.csv',parse_dates=['time'])\ntest=pd.read_csv('/kaggle/input/brist1d/test.csv',parse_dates=['time'])\n\ntrain.columns = train.columns.str.replace(':', '_')\ntrain.columns = train.columns.str.replace('-', '_')\ntest.columns = test.columns.str.replace(':', '_')\ntest.columns = test.columns.str.replace('-', '_')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-29T11:35:08.140655Z","iopub.execute_input":"2024-11-29T11:35:08.140978Z","iopub.status.idle":"2024-11-29T11:35:20.897358Z","shell.execute_reply.started":"2024-11-29T11:35:08.140948Z","shell.execute_reply":"2024-11-29T11:35:20.896264Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_cols=train.columns.tolist()\nbg_cols   = [col for col in train_cols if \"bg_\" in col ][-24:]\ninsu_cols = [col for col in train_cols if \"insulin_\" in col ][-24:]\ncarb_cols = [col for col in train_cols if \"carbs_\" in col ][-24:]\nhr_cols   = [col for col in train_cols if \"hr_\" in col ][-24:]\nstep_cols = [col for col in train_cols if \"steps_\" in col ][-24:]\ncals_cols = [col for col in train_cols if \"cals_\" in col ][-24:]\nactv_cols = [col for col in train_cols if \"activity_\" in col ][-24:]\n\nprint(len(bg_cols),len(insu_cols),len(carb_cols),len(hr_cols),len(step_cols),len(cals_cols), len(actv_cols))\nfeature_cols =  carb_cols +  hr_cols + bg_cols + insu_cols + step_cols + cals_cols \n\nlen_group_cols=6\n\n#target\ntrain.columns = train.columns.str.replace('bg+1_00', 'target')\ntest['target']=0\n\ntrain['hour']=train['time'].dt.hour\ntest['hour'] =test['time'].dt.hour\n\n#feature to create validation groups\nprint(train.p_num.unique())\nprint(test.p_num.unique())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-29T11:35:20.899715Z","iopub.execute_input":"2024-11-29T11:35:20.900080Z","iopub.status.idle":"2024-11-29T11:35:20.929799Z","shell.execute_reply.started":"2024-11-29T11:35:20.900045Z","shell.execute_reply":"2024-11-29T11:35:20.928518Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"#Extra training data from train and test.\nbg_cols_ex   = [col for col in train_cols if \"bg_\" in col ][:-24][-24:]\ninsu_cols_ex= [col for col in train_cols if \"insulin_\" in col ][:-24][-24:]\ncarb_cols_ex = [col for col in train_cols if \"carbs_\" in col ][:-24][-24:]\nhr_cols_ex   = [col for col in train_cols if \"hr_\" in col ][:-24][-24:]\nstep_cols_ex = [col for col in train_cols if \"steps_\" in col ][:-24][-24:]\ncals_cols_ex = [col for col in train_cols if \"cals_\" in col ][:-24][-24:]\nactv_cols_ex = [col for col in train_cols if \"activity_\" in col ][:-24][-24:]\nfeature_cols_ex =  carb_cols_ex +  hr_cols_ex + bg_cols_ex + insu_cols_ex + step_cols_ex + cals_cols_ex\n\n\ntrain_colunns_ex= ['p_num','hour','bg_1_00']+feature_cols_ex\ntrain_colunns= ['p_num','hour','target']+feature_cols\n\n\ntrain_ex1=train[train_colunns_ex].copy()\ntrain_ex2=test[train_colunns_ex].copy()\n\ntrain=train[train_colunns].copy()\ntest=test[train_colunns].copy()\n\ntrain_ex1.columns=train_colunns\ntrain_ex2.columns=train_colunns\n\ntrain_ex1.drop(train_ex1[train_ex1['target'].isna()].index, inplace=True)\ntrain_ex2.drop(train_ex2[train_ex2['target'].isna()].index, inplace=True)\n\ntrain_ex1['hour']=train_ex1['hour']-2\ntrain_ex2['hour']=train_ex2['hour']-2","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-29T11:35:20.931435Z","iopub.execute_input":"2024-11-29T11:35:20.931856Z","iopub.status.idle":"2024-11-29T11:35:21.415500Z","shell.execute_reply.started":"2024-11-29T11:35:20.931806Z","shell.execute_reply":"2024-11-29T11:35:21.414400Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_tmp=pd.concat([train,train_ex2,test])\n\nfor colset in [bg_cols, insu_cols, carb_cols, hr_cols, step_cols, cals_cols]:\n    df_tmp[colset] = df_tmp[colset].interpolate(axis=1)\n\nimputer = SimpleImputer(strategy='median')\ndf_tmp[feature_cols] = imputer.fit_transform(df_tmp[feature_cols])","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-29T11:35:21.416991Z","iopub.execute_input":"2024-11-29T11:35:21.417410Z","iopub.status.idle":"2024-11-29T11:35:43.991561Z","shell.execute_reply.started":"2024-11-29T11:35:21.417366Z","shell.execute_reply":"2024-11-29T11:35:43.990355Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"#Fauture engienering.\ndf_tmp['p_num']=df_tmp['p_num'].map({'p01':0,'p02':1, 'p03':2, 'p04':3, 'p05':4 ,'p06':5 ,'p10':6, 'p11':7 ,'p12':8,'p15':9 ,'p16':10, 'p18':11, 'p19':12, 'p21':13, 'p22':14 ,'p24':15})\n\nlist_extra_fet=[]\ndf_tmp['sin_hour'] = np.sin(np.pi * df_tmp['hour'] / 12)\ndf_tmp['cos_hour'] = np.cos(np.pi * df_tmp['hour']/ 12)\n\n\ndf_tmp['bg_mean'] = df_tmp[bg_cols].mean(axis=1)\ndf_tmp['bg_p_num_mean'] = df_tmp.groupby('p_num')['bg_mean'].transform('mean')\ndf_tmp['bg_last']  =  df_tmp['bg_0_00'] \ndf_tmp['bg_diff']  =  df_tmp['bg_1_00'] - df_tmp['bg_0_00'] \n\ndf_tmp['insu_mean'] = df_tmp[insu_cols].mean(axis=1)\ndf_tmp['insu_p_num_mean'] = df_tmp.groupby('p_num')['insu_mean'].transform('mean')\ndf_tmp['insu_last']  =  df_tmp['insulin_0_00']  \ndf_tmp['insu_diff']  =  df_tmp['insulin_1_00'] - df_tmp['insulin_0_00'] \n\n\n\n#feature_cols =  carb_cols + hr_cols + bg_cols + insu_cols + step_cols + cals_cols \nlgb_fet_extra= ['p_num','sin_hour', 'cos_hour','bg_last','bg_diff','insu_last','insu_diff','bg_mean','insu_mean']\nkeras_fet_extra=['sin_hour', 'cos_hour','bg_p_num_mean','bg_last','bg_diff','insu_p_num_mean','insu_last','insu_diff']\nset(keras_fet_extra+lgb_fet_extra)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-29T11:35:43.992663Z","iopub.execute_input":"2024-11-29T11:35:43.992998Z","iopub.status.idle":"2024-11-29T11:35:44.170670Z","shell.execute_reply.started":"2024-11-29T11:35:43.992964Z","shell.execute_reply":"2024-11-29T11:35:44.169458Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"#Scale features\nscale_cols=[col for col in feature_cols+list_extra_fet if 'hour' not in col]\nscaler = MinMaxScaler(feature_range=(0,1))\ndf_tmp[scale_cols]=scaler.fit_transform(df_tmp[scale_cols])\n\n#split\nsplt_colunns= ['target']+feature_cols+list(set(keras_fet_extra+lgb_fet_extra))\n\nvalid_test=df_tmp[len(train):-len(test):][splt_colunns].reset_index(drop=True)\ntrain=df_tmp[:len(train)][splt_colunns].reset_index(drop=True)\ntest=df_tmp[-len(test):][splt_colunns]\n\ndel df_tmp\ngc.collect()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-29T11:35:44.171781Z","iopub.execute_input":"2024-11-29T11:35:44.172120Z","iopub.status.idle":"2024-11-29T11:35:45.192353Z","shell.execute_reply.started":"2024-11-29T11:35:44.172090Z","shell.execute_reply":"2024-11-29T11:35:45.191320Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"class DataGenerator(tf.keras.utils.Sequence):\n    'Generates data for Keras'\n    def __init__(self,data,target,data_index,train_features,fet_extra,batch_size=1024*10,shuffle=False,mode='train',*args, **kwargs): \n\n        super().__init__(*args, **kwargs)\n        self.data=data\n        self.target=target\n        self.features=train_features\n        self.features_extra=fet_extra\n        self.data_index = data_index\n        self.batch_size = batch_size\n        self.shuffle = shuffle\n        self.mode = mode\n        self.n = 0\n        self.max = self.__len__()\n        self.on_epoch_end()\n        \n        \n    def __len__(self):\n        'Denotes the number of batches per epoch'\n        ct = int( np.ceil( len(self.data_index) / self.batch_size ) )\n        return ct\n\n    def __getitem__(self, index):\n        'Generate one batch of data'\n        indexes = self.indexes[index*self.batch_size:(index+1)*self.batch_size]\n        X1,X2,y = self.__data_generation(indexes)          \n        return {\"input_1\": X1, \"input_2\": X2},y\n        \n    def __next__(self):\n        if self.n >= self.max:\n            self.n = 0\n        result = self.__getitem__(self.n)\n        self.n += 1\n        return result\n\n    def on_epoch_end(self):\n        'Updates indexes after each epoch'\n        self.indexes = self.data_index\n        if self.shuffle: np.random.shuffle(self.indexes)            \n\n                        \n    def __data_generation(self, indexes):\n        'Generates data containing batch_size samples' \n    \n        X1 = self.data.iloc[indexes][self.features] \n        X1 = X1.values.reshape(len(indexes),len_group_cols,int(len(feature_cols)/len_group_cols))\n        X2 = self.data.iloc[indexes][self.features_extra].values\n        y = self.data.iloc[indexes][self.target].values         \n\n        return X1,X2,y","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-29T11:35:45.193729Z","iopub.execute_input":"2024-11-29T11:35:45.194099Z","iopub.status.idle":"2024-11-29T11:35:45.206869Z","shell.execute_reply.started":"2024-11-29T11:35:45.194062Z","shell.execute_reply":"2024-11-29T11:35:45.205569Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from matplotlib import pyplot as plt\ngen = DataGenerator(train,'target',train.head(1024*10).index,feature_cols,keras_fet_extra,shuffle=False, batch_size=1024,mode='train')\nX,y=next(gen)\nX=X.get('input_1')\n\nfor i in range(0,1024,300):\n    print(X[i].shape,y[i])    \n    print(X[i].shape)\n    fig = plt.figure()\n    plt.imshow(X[i])\n    plt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-29T11:35:45.210911Z","iopub.execute_input":"2024-11-29T11:35:45.211411Z","iopub.status.idle":"2024-11-29T11:35:45.876748Z","shell.execute_reply.started":"2024-11-29T11:35:45.211362Z","shell.execute_reply":"2024-11-29T11:35:45.875700Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def root_mean_squared_error(y_true, y_pred):\n        return K.sqrt(K.mean(K.square(y_pred - y_true))) \n\ndef make_model(img_rows,img_cols,channnels,len_extra):    \n    \n    input_1 = tf.keras.layers.Input(shape=(img_rows,img_cols,channnels),name='input_1')\n    input_2 = tf.keras.layers.Input(shape=(len_extra,),name='input_2')\n    \n    ########################################################\n    \n    conv1 = tf.keras.layers.Conv2D(32, kernel_size=(len_group_cols,3), activation='relu')(input_1)\n    conv1 = tf.keras.layers.Conv2D(32, kernel_size=(1,3),padding='same', activation='relu')(conv1)\n    conv1 = tf.keras.layers.MaxPooling2D(1,2)(conv1)\n    conv1 = tf.keras.layers.Conv2D(32, kernel_size=(1,3),padding='same', activation='relu')(conv1)\n    \n    conv1_fet = tf.keras.layers.GlobalAveragePooling2D()(conv1)    \n    conv1_flat = tf.keras.layers.Flatten()(conv1)      \n    \n    x1 = tf.keras.layers.Dense(128, activation='relu')(conv1_flat) \n    x1 = tf.keras.layers.Dropout(0.4)(x1)\n\n    x = tf.keras.layers.Concatenate()([x1,conv1_fet,input_2])\n    x = tf.keras.layers.Dense(16, activation='relu')(x)\n    x = tf.keras.layers.Dropout(0.2)(x)\n\n    \n    output = tf.keras.layers.Dense(1)(x)     \n\n    model = tf.keras.Model(inputs=[input_1,input_2], outputs=output)  \n    features = tf.keras.Model(inputs=[input_1,input_2],outputs=[conv1_flat])\n    \n    model.compile(optimizer=tf.keras.optimizers.Adam(1e-3), loss = 'mse')    \n                                   \n    return model,features\n\n\nimg_rows=len_group_cols\nimg_cols=24\nchannnels=1\nmodel,features=make_model(img_rows,img_cols,channnels,len(keras_fet_extra))\nmodel.summary()\nfeatures.summary()\n#plot_model(model, show_shapes=True, show_layer_names=True, to_file='model.png')\n#from IPython.display import Image\n#Image(retina=True, filename='model.png')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-29T11:35:45.878090Z","iopub.execute_input":"2024-11-29T11:35:45.878504Z","iopub.status.idle":"2024-11-29T11:35:46.074489Z","shell.execute_reply.started":"2024-11-29T11:35:45.878455Z","shell.execute_reply":"2024-11-29T11:35:46.073397Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"Folds=5\ncv = GroupKFold(Folds)\nK.clear_session()\ntest_gen=DataGenerator(test,'target',test.index,feature_cols,keras_fet_extra,shuffle=False, batch_size=256,mode='test')\ntest_valid_gen=DataGenerator(valid_test,'target',valid_test.index,feature_cols,keras_fet_extra,shuffle=False, batch_size=256,mode='test')\n\ntrain_oof_keras= np.zeros((len(train)))\ntrain_oof_lgb= np.zeros((len(train)))\ntest_valid_keras= np.zeros((len(valid_test)))\n\ntest_preds_keras= np.zeros((len(test)))\ntest_preds_lgb= np.zeros((len(test)))\n\n\nparams_lgb = {'learning_rate': 0.01,\n               'metric':'rmse',\n               'objective': 'regression_l2',\n               'boosting': 'gbdt',\n              'colsample_bytree':0.6,\n               'verbosity': -1,\n               'n_jobs': -1,\n               'force_col_wise':True}\n\n\nfor train_index, valid_index in cv.split(train, train.target, groups=train['p_num']):\n\n    es = tf.keras.callbacks.EarlyStopping(monitor='val_loss', patience=10, verbose=0, mode='min', baseline=None, restore_best_weights=True)\n    rlr = tf.keras.callbacks.ReduceLROnPlateau(monitor='val_loss', factor=0.9, patience=3,  mode='min', verbose=0)\n\n    print('train_p_num:',train.iloc[train_index]['p_num'].unique(),'*********  valid_p_num:',train.iloc[valid_index]['p_num'].unique())\n\n    train_gen=DataGenerator(train,'target',train_index,feature_cols,keras_fet_extra,shuffle=False, batch_size=256,mode='train')    \n    valid_gen=DataGenerator(train,'target',valid_index,feature_cols,keras_fet_extra,shuffle=False, batch_size=256,mode='train')\n    print(len(train_index),len(valid_index))\n    \n    model, features=make_model(img_rows,img_cols,channnels,len(keras_fet_extra))\n    model.fit(train_gen,validation_data =valid_gen, verbose=1, epochs=100,callbacks = [rlr,es] )\n\n    fold_test_keras = model.predict(test_gen,verbose=0).ravel()\n    test_preds_keras += fold_test_keras/Folds\n\n    fold_test_valid_keras = model.predict(test_valid_gen,verbose=0).ravel()    \n    test_valid_keras += fold_test_valid_keras/Folds\n    rmse = np.sqrt(mean_squared_error(valid_test.target, fold_test_valid_keras))\n    print(f\"RMSE test_valid Fold keras  Score: {rmse}\")\n\n    fold_valid_keras = model.predict(valid_gen,verbose=0).ravel()\n    train_oof_keras[valid_index] = fold_valid_keras\n    rmse = np.sqrt(mean_squared_error(train.iloc[valid_index].target, fold_valid_keras))\n    print(f\"RMSE oof keras  Score: {rmse}\")\n\n\n    ##************************************************************\n    #X_train_lgb =features.predict(train_gen,verbose=0)    \n    X_valid_lgb =features.predict(valid_gen,verbose=0)\n    X_test_valid_lgb =features.predict(test_valid_gen,verbose=0)\n    X_test_lgb =features.predict(test_gen,verbose=0 )\n\n    #X_train_lgb = np.concatenate((X_train_lgb,train.iloc[train_index][lgb_fet_extra].values),axis=1)\n    X_valid_lgb = np.concatenate((X_valid_lgb,train.iloc[valid_index][lgb_fet_extra].values),axis=1)\n    X_test_valid_lgb = np.concatenate((X_test_valid_lgb,valid_test[lgb_fet_extra].values),axis=1)\n    X_test_lgb = np.concatenate((X_test_lgb,test[lgb_fet_extra].values),axis=1)\n\n    lgb_cols_names=[f'keras_{col}' for col in range(352)]+lgb_fet_extra\n    X_valid_lgb = pd.DataFrame(X_valid_lgb,columns=lgb_cols_names)\n    X_test_valid_lgb = pd.DataFrame(X_test_valid_lgb,columns=lgb_cols_names)\n    X_test_lgb = pd.DataFrame(X_test_lgb,columns=lgb_cols_names)\n    \n    \n    train_dataset = lgb.Dataset(X_test_valid_lgb, valid_test['target'].values,categorical_feature=['p_num'] )\n    val_dataset = lgb.Dataset(X_valid_lgb, train.iloc[valid_index]['target'].values,categorical_feature=['p_num'])   \n\n    model_lgb = lgb.train(params = params_lgb, \n                train_set = train_dataset, \n                valid_sets =  val_dataset, \n                num_boost_round = 5000, \n                callbacks=[ lgb.early_stopping(stopping_rounds=200, verbose=True), lgb.log_evaluation(period=100)]) \n    \n    fold_valid_lgb = model_lgb.predict(X_valid_lgb)\n    train_oof_lgb[valid_index] = fold_valid_lgb \n\n    rmse = np.sqrt(mean_squared_error(train.iloc[valid_index].target, fold_valid_lgb))\n    print(f\"RMSE oof keras  Score:: {rmse}\")\n\n    rmse = np.sqrt(mean_squared_error(train.iloc[valid_index].target, (fold_valid_keras+fold_valid_lgb)/2))\n    print(f\"RMSE oof keras+lgb  Score:: {rmse}\")\n\n    test_preds_lgb += model_lgb.predict(X_test_lgb)/Folds\n\n    K.clear_session()\n    del model\n\n\nrmse = np.sqrt(mean_squared_error(train.target, train_oof_keras))\nprint(f\"Keras RMSE Score: {rmse}\")\n\nrmse = np.sqrt(mean_squared_error(train.target, train_oof_lgb))\nprint(f\"LGB RMSE Score: {rmse}\")\n\nrmse = np.sqrt(mean_squared_error(train.target, (train_oof_lgb+train_oof_keras)/2))\nprint(f\"Kera+LGB RMSE Score: {rmse}\")\n\nrmse = np.sqrt(mean_squared_error(valid_test.target,test_valid_keras))\nprint(f\"Test Valid RMSE Score: {rmse}\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-29T11:35:46.075928Z","iopub.execute_input":"2024-11-29T11:35:46.076334Z","iopub.status.idle":"2024-11-29T11:38:47.439341Z","shell.execute_reply.started":"2024-11-29T11:35:46.076300Z","shell.execute_reply":"2024-11-29T11:38:47.438135Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nimport seaborn as sns\nimport warnings\nwarnings.simplefilter(action='ignore', category=FutureWarning)\n\n\n# sorted(zip(clf.feature_importances_, X.columns), reverse=True)\nfeature_imp = pd.DataFrame(sorted(zip(model_lgb.feature_importance(),lgb_cols_names)), columns=['Value','Feature'])\n\nplt.figure(figsize=(20, 10))\nsns.barplot(x=\"Value\", y=\"Feature\", data=feature_imp.sort_values(by=\"Value\", ascending=False).head(40))\nplt.title('LightGBM Features (avg over folds)')\nplt.tight_layout()\nplt.show()\nplt.savefig('lgbm_importances-01.png')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-29T11:38:47.440976Z","iopub.execute_input":"2024-11-29T11:38:47.441372Z","iopub.status.idle":"2024-11-29T11:38:48.504481Z","shell.execute_reply.started":"2024-11-29T11:38:47.441326Z","shell.execute_reply":"2024-11-29T11:38:48.503220Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"submission=pd.read_csv('/kaggle/input/brist1d/sample_submission.csv')\nsubmission['bg+1:00']=(test_preds_lgb+test_preds_keras)/2\nsubmission.to_csv('submission.csv', index=False)\nsubmission.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-11-29T11:38:48.506029Z","iopub.execute_input":"2024-11-29T11:38:48.506896Z","iopub.status.idle":"2024-11-29T11:38:48.542517Z","shell.execute_reply.started":"2024-11-29T11:38:48.506857Z","shell.execute_reply":"2024-11-29T11:38:48.541111Z"}},"outputs":[],"execution_count":null}]}