Kaggle competition: ASHRAE - Great Energy Predictor III
<SOS> metric: RMSLE Kaggle data source: ashrae-great-energy-predictor-iii<define_variables>
myfavouritenumber = 0
seed = myfavouritenumber
random.seed(seed)
 warnings.filterwarnings('ignore' )
DP_DIR = '.. /input/shuffle-csvs/'
INPUT_DIR = '.. /input/quickdraw-doodle-recognition/'
BASE_SIZE = 256
NCSVS = 100
NCATS = 340
np.random.seed(seed=1987)
 tf.set_random_seed(seed=1987)
 def f2cat(filename: str)-> str:
return filename.split('.')[0]
def list_all_categories() :
files = os.listdir(os.path.join(INPUT_DIR, 'train_simplified'))
return sorted([f2cat(f)for f in files], key=str.lower )<define_variables>
%%time
df_train = pd.read_feather('.. /input/ashrae-great-energy-predictor-iii-featherdataset/train.feather')
 df_test = pd.read_feather('.. /input/ashrae-great-energy-predictor-iii-featherdataset/test.feather')
 building = pd.read_feather('.. /input/ashrae-great-energy-predictor-iii-featherdataset/building_metadata.feather')
 le = LabelEncoder()
building.primary_use = le.fit_transform(building.primary_use)
 DATA_PATH = ".. /input/ashrae-energy-prediction/"
weather_train = pd.read_csv(DATA_PATH + 'weather_train.csv')
 weather_test = weather_df = pd.read_csv(DATA_PATH + 'weather_test.csv' )
size = 256
batchsize = 512<drop_column>
%%time
df_train = df_train.query('not(building_id <= 104 & meter == 0 & timestamp <= "2016-05-20 18")')
 df_train = df_train.query('not(building_id == 681 & meter == 0 & timestamp <= "2016-04-27")')
 df_train = df_train.query('not(building_id == 761 & meter == 0 & timestamp <= "2016-09-02")')
 df_train = df_train.query('not(building_id == 799 & meter == 0 & timestamp <= "2016-09-02")')
 df_train = df_train.query('not(building_id == 802 & meter == 0 & timestamp <= "2016-08-24")')
 df_train = df_train.query('not(building_id == 1073 & meter == 0 & timestamp <= "2016-10-26")')
 df_train = df_train.query('not(building_id == 1094 & meter == 0 & timestamp <= "2016-09-08")')
 df_train = df_train.query('not(building_id == 29 & meter == 0 & timestamp <= "2016-08-10")')
 df_train = df_train.query('not(building_id == 40 & meter == 0 & timestamp <= "2016-06-04")')
 df_train = df_train.query('not(building_id == 45 & meter == 0 & timestamp <= "2016-07")')
 df_train = df_train.query('not(building_id == 106 & meter == 0 & timestamp <= "2016-11")')
 df_train = df_train.query('not(building_id == 107 & meter == 0 & timestamp >= "2016-11-10")')
 df_train = df_train.query('not(building_id == 112 & meter == 0 & timestamp < "2016-10-31 15")')
 df_train = df_train.query('not(building_id == 144 & meter == 0 & timestamp > "2016-05-14" & timestamp < "2016-10-31")')
 df_train = df_train.query('not(building_id == 147 & meter == 0 & timestamp > "2016-06-05 19" & timestamp < "2016-07-18 15")')
 df_train = df_train.query('not(building_id == 171 & meter == 0 & timestamp <= "2016-07-05")')
 df_train = df_train.query('not(building_id == 177 & meter == 0 & timestamp > "2016-06-04" & timestamp < "2016-06-25")')
 df_train = df_train.query('not(building_id == 258 & meter == 0 & timestamp > "2016-09-26" & timestamp < "2016-12-12")')
 df_train = df_train.query('not(building_id == 258 & meter == 0 & timestamp > "2016-08-30" & timestamp < "2016-09-08")')
 df_train = df_train.query('not(building_id == 258 & meter == 0 & timestamp > "2016-09-18" & timestamp < "2016-09-25")')
 df_train = df_train.query('not(building_id == 260 & meter == 0 & timestamp <= "2016-05-11")')
 df_train = df_train.query('not(building_id == 269 & meter == 0 & timestamp > "2016-06-04" & timestamp < "2016-06-25")')
 df_train = df_train.query('not(building_id == 304 & meter == 0 & timestamp >= "2016-11-20")')
 df_train = df_train.query('not(building_id == 545 & meter == 0 & timestamp > "2016-01-17" & timestamp < "2016-02-10")')
 df_train = df_train.query('not(building_id == 604 & meter == 0 & timestamp < "2016-11-21")')
 df_train = df_train.query('not(building_id == 693 & meter == 0 & timestamp > "2016-09-07" & timestamp < "2016-11-23")')
 df_train = df_train.query('not(building_id == 693 & meter == 0 & timestamp > "2016-07-12" & timestamp < "2016-05-29")')
 df_train = df_train.query('not(building_id == 723 & meter == 0 & timestamp > "2016-10-06" & timestamp < "2016-11-22")')
 df_train = df_train.query('not(building_id == 733 & meter == 0 & timestamp > "2016-05-29" & timestamp < "2016-06-22")')
 df_train = df_train.query('not(building_id == 733 & meter == 0 & timestamp > "2016-05-19" & timestamp < "2016-05-20")')
 df_train = df_train.query('not(building_id == 803 & meter == 0 & timestamp > "2016-9-25")')
 df_train = df_train.query('not(building_id == 815 & meter == 0 & timestamp > "2016-05-17" & timestamp < "2016-11-17")')
 df_train = df_train.query('not(building_id == 848 & meter == 0 & timestamp > "2016-01-15" & timestamp < "2016-03-20")')
 df_train = df_train.query('not(building_id == 857 & meter == 0 & timestamp > "2016-04-13")')
 df_train = df_train.query('not(building_id == 909 & meter == 0 & timestamp < "2016-02-02")')
 df_train = df_train.query('not(building_id == 909 & meter == 0 & timestamp < "2016-06-23")')
 df_train = df_train.query('not(building_id == 1008 & meter == 0 & timestamp > "2016-10-30" & timestamp < "2016-11-21")')
 df_train = df_train.query('not(building_id == 1113 & meter == 0 & timestamp < "2016-07-27")')
 df_train = df_train.query('not(building_id == 1153 & meter == 0 & timestamp < "2016-01-20")')
 df_train = df_train.query('not(building_id == 1169 & meter == 0 & timestamp < "2016-08-03")')
 df_train = df_train.query('not(building_id == 1170 & meter == 0 & timestamp > "2016-06-30" & timestamp < "2016-07-05")')
 df_train = df_train.query('not(building_id == 1221 & meter == 0 & timestamp < "2016-11-04")')
 df_train = df_train.query('not(building_id == 1225 & meter == 0 & timestamp > "2016-09-28 07" & timestamp < "2016-10-20 13")')
 df_train = df_train.query('not(building_id == 1234 & meter == 0 & timestamp > "2016-09-28 07" & timestamp < "2016-10-20 13")')
 df_train = df_train.query('not(building_id >= 1233 & building_id <= 1234 & meter == 0 & timestamp > "2016-01-13 22" & timestamp < "2016-03-08 12")')
 df_train = df_train.query('not(building_id == 1241 & meter == 0 & timestamp > "2016-07-14" & timestamp < "2016-11-19")')
 df_train = df_train.query('not(building_id == 1250 & meter == 0 & timestamp > "2016-09-28 07" & timestamp < "2016-10-20 13")')
 df_train = df_train.query('not(building_id == 1255 & meter == 0 & timestamp > "2016-09-28 07" & timestamp < "2016-10-20 13")')
 df_train = df_train.query('not(building_id == 1264 & meter == 0 & timestamp > "2016-08-23")')
 df_train = df_train.query('not(building_id == 1265 & meter == 0 & timestamp > "2016-05-06" & timestamp < "2016-05-26")')
 df_train = df_train.query('not(building_id == 1272 & meter == 0 & timestamp > "2016-09-28 07" & timestamp < "2016-10-20 13")')
 df_train = df_train.query('not(building_id >= 1275 & building_id <= 1280 & meter == 0 & timestamp > "2016-09-28 07" & timestamp < "2016-10-20 13")')
 df_train = df_train.query('not(building_id == 1283 & meter == 0 & timestamp > "2016-07-08" & timestamp < "2016-08-03")')
 df_train = df_train.query('not(building_id >= 1291 & building_id <= 1302 & meter == 0 & timestamp > "2016-09-28 07" & timestamp < "2016-10-20 13")')
 df_train = df_train.query('not(building_id == 1303 & meter == 0 & timestamp > "2016-07-25 22" & timestamp < "2016-07-27 16")')
 df_train = df_train.query('not(building_id == 1303 & meter == 0 & timestamp > "2016-01-26" & timestamp < "2016-06-02 12")')
 df_train = df_train.query('not(building_id == 1319 & meter == 0 & timestamp > "2016-05-17 16" & timestamp < "2016-06-07 12")')
 df_train = df_train.query('not(building_id == 1319 & meter == 0 & timestamp > "2016-08-18 14" & timestamp < "2016-09-02 14")')
 df_train = df_train.query('not(building_id == 1322 & meter == 0 & timestamp > "2016-09-28 07" & timestamp < "2016-10-20 13")')
 df_train = df_train.query('not(building_id >= 874 & building_id <= 997 & meter == 0 & timestamp > "2016-10-14 22" & timestamp < "2016-10-17 08")')
 df_train = df_train.query('not(building_id >= 874 & building_id <= 997 & meter == 0 & timestamp > "2016-07-01 14" & timestamp < "2016-07-05 06")')
 df_train = df_train.query('not(building_id >= 874 & building_id <= 997 & meter == 1 & timestamp > "2016-10-14 22" & timestamp < "2016-10-17 08")')
 df_train = df_train.query('not(building_id >= 874 & building_id <= 997 & meter == 1 & timestamp > "2016-07-01 14" & timestamp < "2016-07-05 06")')
 df_train = df_train.query('not(building_id >= 874 & building_id <= 997 & meter == 2 & timestamp > "2016-10-14 22" & timestamp < "2016-10-17 08")')
 df_train = df_train.query('not(building_id >= 874 & building_id <= 997 & meter == 2 & timestamp > "2016-07-01 14" & timestamp < "2016-07-05 06")')
 df_train = df_train.query('not(building_id == 1272 & meter == 1 & timestamp > "2016-09-28 07" & timestamp < "2016-10-20 13")')
 df_train = df_train.query('not(building_id >= 1291 & building_id <= 1297 & meter == 1 & timestamp > "2016-09-28 07" & timestamp < "2016-10-20 13")')
 df_train = df_train.query('not(building_id == 1300 & meter == 1 & timestamp > "2016-09-28 07" & timestamp < "2016-10-20 13")')
 df_train = df_train.query('not(building_id == 1302 & meter == 1 & timestamp > "2016-09-28 07" & timestamp < "2016-10-20 13")')
 df_train = df_train.query('not(building_id >= 1291 & building_id <= 1299 & meter == 2 & timestamp > "2016-09-28 07" & timestamp < "2016-10-20 13")')
 df_train = df_train.query('not(building_id == 1221 & meter == 0 & timestamp > "2016-09-28 07" & timestamp < "2016-10-20 13")')
 df_train = df_train.query('not(building_id >= 1225 & building_id <= 1226 & meter == 0 & timestamp > "2016-09-28 07" & timestamp < "2016-10-20 13")')
 df_train = df_train.query('not(building_id >= 1233 & building_id <= 1234 & meter == 0 & timestamp > "2016-09-28 07" & timestamp < "2016-10-20 13")')
 df_train = df_train.query('not(building_id == 1241 & meter == 0 & timestamp > "2016-09-28 07" & timestamp < "2016-10-20 13")')
 df_train = df_train.query('not(building_id == 1223 & meter == 1 & timestamp > "2016-09-28 07" & timestamp < "2016-10-20 13")')
 df_train = df_train.query('not(building_id == 1226 & meter == 1 & timestamp > "2016-09-28 07" & timestamp < "2016-10-20 13")')
 df_train = df_train.query('not(building_id >= 1233 & building_id <= 1234 & meter == 1 & timestamp > "2016-09-28 07" & timestamp < "2016-10-20 13")')
 df_train = df_train.query('not(building_id >= 1225 & building_id <= 1226 & meter == 2 & timestamp > "2016-09-28 07" & timestamp < "2016-10-20 13")')
 df_train = df_train.query('not(building_id == 1305 & meter == 2 & timestamp > "2016-09-28 07" & timestamp < "2016-10-20 13")')
 df_train = df_train.query('not(building_id == 1307 & meter == 2 & timestamp > "2016-09-28 07" & timestamp < "2016-10-20 13")')
 df_train = df_train.query('not(building_id == 1223 & meter == 3 & timestamp > "2016-09-28 07" & timestamp < "2016-10-20 13")')
 df_train = df_train.query('not(building_id == 1231 & meter == 3 & timestamp > "2016-09-28 07" & timestamp < "2016-10-20 13")')
 df_train = df_train.query('not(building_id >= 1233 & building_id <= 1234 & meter == 3 & timestamp > "2016-09-28 07" & timestamp < "2016-10-20 13")')
 df_train = df_train.query('not(building_id == 1272 & meter == 3 & timestamp > "2016-09-28 07" & timestamp < "2016-10-20 13")')
 df_train = df_train.query('not(building_id >= 1275 & building_id <= 1297 & meter == 3 & timestamp > "2016-09-28 07" & timestamp < "2016-10-20 13")')
 df_train = df_train.query('not(building_id == 1300 & meter == 3 & timestamp > "2016-09-28 07" & timestamp < "2016-10-20 13")')
 df_train = df_train.query('not(building_id == 1302 & meter == 3 & timestamp > "2016-09-28 07" & timestamp < "2016-10-20 13")')
 df_train = df_train.query('not(building_id == 1293 & meter == 3 & timestamp > "2016-09-28 07" & timestamp < "2016-10-25 12")')
 df_train = df_train.query('not(building_id == 1302 & meter == 3 & timestamp > "2016-09-28 07" & timestamp < "2016-10-25 12")')
 df_train = df_train.query('not(building_id == 1223 & meter == 0 & timestamp > "2016-9-28 07" & timestamp < "2016-10-11 18")')
 df_train = df_train.query('not(building_id == 1225 & meter == 1 & timestamp > "2016-8-22 23" & timestamp < "2016-10-11 14")')
 df_train = df_train.query('not(building_id == 1230 & meter == 1 & timestamp > "2016-8-22 08" & timestamp < "2016-10-05 18")')
 df_train = df_train.query('not(building_id == 904 & meter == 0 & timestamp < "2016-02-17 08")')
 df_train = df_train.query('not(building_id == 986 & meter == 0 & timestamp < "2016-02-17 08")')
 df_train = df_train.query('not(building_id == 954 & meter == 0 & timestamp < "2016-08-08 11")')
 df_train = df_train.query('not(building_id == 954 & meter == 0 & timestamp < "2016-06-23 08")')
 df_train = df_train.query('not(building_id >= 745 & building_id <= 770 & meter == 1 & timestamp > "2016-10-05 01" & timestamp < "2016-10-10 09")')
 df_train = df_train.query('not(building_id >= 774 & building_id <= 787 & meter == 1 & timestamp > "2016-10-05 01" & timestamp < "2016-10-10 09")')
 df_train = df_train.query('not(building_id >= 874 & building_id <= 997 & meter == 0 & timestamp > "2016-05-11 09" & timestamp < "2016-05-12 01")')
 df_train = df_train.query('not(building_id >= 874 & building_id <= 997 & meter == 1 & timestamp > "2016-05-11 09" & timestamp < "2016-05-12 01")')
 df_train = df_train.query('not(building_id >= 874 & building_id <= 997 & meter == 2 & timestamp > "2016-05-11 09" & timestamp < "2016-05-12 01")')
 df_train = df_train.query('not(building_id >= 874 & building_id <= 997 & meter == 0 & timestamp == "2016-02-26 01")')
 df_train = df_train.query('not(building_id >= 874 & building_id <= 997 & meter == 1 & timestamp == "2016-02-26 01")')
 df_train = df_train.query('not(building_id >= 874 & building_id <= 997 & meter == 2 & timestamp == "2016-02-26 01")')
 df_train = df_train.query('not(building_id >= 874 & building_id <= 997 & meter == 0 & timestamp > "2016-03-29 10" & timestamp < "2016-03-30 12")')
 df_train = df_train.query('not(building_id >= 874 & building_id <= 997 & meter == 1 & timestamp > "2016-03-29 10" & timestamp < "2016-03-30 12")')
 df_train = df_train.query('not(building_id >= 874 & building_id <= 997 & meter == 2 & timestamp > "2016-03-29 10" & timestamp < "2016-03-30 12")')
 df_train = df_train.query('not(building_id >= 874 & building_id <= 997 & meter == 0 & timestamp > "2016-01-19 23" & timestamp < "2016-01-28 15")')
 df_train = df_train.query('not(building_id >= 874 & building_id <= 997 & meter == 1 & timestamp > "2016-01-19 23" & timestamp < "2016-01-28 15")')
 df_train = df_train.query('not(building_id >= 874 & building_id <= 997 & meter == 2 & timestamp > "2016-01-19 23" & timestamp < "2016-01-28 15")')
 df_train = df_train.query('not(building_id != 1227 & building_id != 1281 & building_id != 1314 & building_id >=1223 & building_id < 1335 & meter==0 & meter_reading==0)')
 df_train = df_train.query('not(building_id >= 1223 & building_id <= 1324 & meter==1 & timestamp > "2016-07-16 04" & timestamp < "2016-07-19 11")')
 df_train = df_train.query('not(building_id == 107 & meter == 0 & timestamp <= "2016-07-06")')
 df_train = df_train.query('not(building_id == 180 & timestamp >= "2016-02-17 12")')
 df_train = df_train.query('not(building_id == 182 & meter == 0)')
 df_train = df_train.query('not(building_id == 191 & meter == 0 & timestamp >= "2016-12-22 09")')
 df_train = df_train.query('not(building_id == 192 & meter == 1 & timestamp >= "2016-05-09 18")')
 df_train = df_train.query('not(building_id == 192 & meter == 3 & timestamp >= "2016-03-29 05" & timestamp <= "2016-04-04 08")')
 df_train = df_train.query('not(building_id == 207 & meter == 1 & timestamp > "2016-07-02 20" & timestamp < "2016-08-25 12")')
 df_train = df_train.query('not(building_id == 258 & timestamp > "2016-09-18" & timestamp < "2016-12-12 13")')
 df_train = df_train.query('not(building_id == 258 & timestamp > "2016-08-29 08" & timestamp < "2016-09-08 14")')
 df_train = df_train.query('not(building_id == 257 & meter == 1 & timestamp < "2016-03-25 16")')
 df_train = df_train.query('not(building_id == 260 & meter == 1 & timestamp > "2016-05-10 17" & timestamp < "2016-08-17 11")')
 df_train = df_train.query('not(building_id == 260 & meter == 1 & timestamp > "2016-08-28 01" & timestamp < "2016-10-31 13")')
 df_train = df_train.query('not(building_id == 220 & meter == 1 & timestamp > "2016-09-23 01" & timestamp < "2016-09-23 12")')
 df_train = df_train.query('not(building_id == 281 & meter == 1 & timestamp > "2016-10-25 08" & timestamp < "2016-11-04 15")')
 df_train = df_train.query('not(building_id == 273 & meter == 1 & timestamp > "2016-04-03 04" & timestamp < "2016-04-29 15")')
 df_train = df_train.query('not(building_id == 28 & meter == 0 & timestamp < "2016-10-14 20")')
 df_train = df_train.query('not(building_id == 71 & meter == 0 & timestamp < "2016-08-18 20")')
 df_train = df_train.query('not(building_id == 76 & meter == 0 & timestamp > "2016-06-04 09" & timestamp < "2016-06-04 14")')
 df_train = df_train.query('not(building_id == 101 & meter == 0 & timestamp > "2016-10-12 13" & timestamp < "2016-10-12 18")')
 df_train = df_train.query('not(building_id == 7 & meter == 1 & timestamp > "2016-11-03 09" & timestamp < "2016-11-28 14")')
 df_train = df_train.query('not(building_id == 9 & meter == 1 & timestamp > "2016-12-06 08")')
 df_train = df_train.query('not(building_id == 43 & meter == 1 & timestamp > "2016-04-03 08" & timestamp < "2016-06-06 13")')
 df_train = df_train.query('not(building_id == 60 & meter == 1 & timestamp > "2016-05-01 17" & timestamp < "2016-05-01 21")')
 df_train = df_train.query('not(building_id == 75 & meter == 1 & timestamp > "2016-08-05 13" & timestamp < "2016-08-26 12")')
 df_train = df_train.query('not(building_id == 95 & meter == 1 & timestamp > "2016-08-08 10" & timestamp < "2016-08-26 13")')
 df_train = df_train.query('not(building_id == 97 & meter == 1 & timestamp > "2016-08-08 14" & timestamp < "2016-08-25 14")')
 df_train = df_train.query('not(building_id == 1232 & meter == 1 & timestamp > "2016-06-23 16" & timestamp < "2016-08-31 20")')
 df_train = df_train.query('not(building_id == 1236 & meter == 1 & meter_reading >= 3000)')
 df_train = df_train.query('not(building_id == 1239 & meter == 1 & timestamp > "2016-03-11 16" & timestamp < "2016-03-27 17")')
 df_train = df_train.query('not(building_id == 1264 & meter == 1 & timestamp > "2016-08-22 17" & timestamp < "2016-09-22 20")')
 df_train = df_train.query('not(building_id == 1264 & meter == 1 & timestamp > "2016-09-28 07" & timestamp < "2016-10-20 13")')
 df_train = df_train.query('not(building_id == 1269 & meter == 1 & meter_reading >= 2000)')
 df_train = df_train.query('not(building_id == 1272 & meter == 1 & timestamp > "2016-08-11 12" & timestamp < "2016-08-30 19")')
 df_train = df_train.query('not(building_id == 1273 & meter == 1 & timestamp > "2016-05-31 14" & timestamp < "2016-06-17")')
 df_train = df_train.query('not(building_id == 1276 & meter == 1 & timestamp < "2016-02-03 23")')
 df_train = df_train.query('not(building_id == 1280 & meter == 1 & timestamp > "2016-05-18" & timestamp < "2016-05-26 09")')
 df_train = df_train.query('not(building_id == 1280 & meter == 1 & timestamp > "2016-02-28 23" & timestamp < "2016-05-02 05")')
 df_train = df_train.query('not(building_id == 1280 & meter == 1 & timestamp > "2016-06-12 01" & timestamp < "2016-7-07 06")')
 df_train = df_train.query('not(building_id == 1288 & meter == 1 & timestamp > "2016-07-07 15" & timestamp < "2016-08-12 17")')
 df_train = df_train.query('not(building_id == 1311 & meter == 1 & timestamp > "2016-04-25 18" & timestamp < "2016-05-13 14")')
 df_train = df_train.query('not(building_id == 1099 & meter == 2)')
 df_train = df_train.query('not(building_id == 1329 & meter == 0 & timestamp > "2016-04-28 00" & timestamp < "2016-04-28 07")')
 df_train = df_train.query('not(building_id == 1331 & meter == 0 & timestamp > "2016-04-28 00" & timestamp < "2016-04-28 07")')
 df_train = df_train.query('not(building_id == 1427 & meter == 0 & timestamp > "2016-04-11 10" & timestamp < "2016-04-11 14")')
 df_train = df_train.query('not(building_id == 1426 & meter == 2 & timestamp > "2016-05-03 09" & timestamp < "2016-05-03 14")')
 df_train = df_train.query('not(building_id == 1345 & meter == 0 & timestamp < "2016-03-01")')
 df_train = df_train.query('not(building_id == 1346 & timestamp < "2016-03-01")')
 df_train = df_train.query('not(building_id == 1359 & meter == 0 & timestamp > "2016-04-25 17" & timestamp < "2016-07-22 14")')
 df_train = df_train.query('not(building_id == 1365 & meter == 0 & timestamp > "2016-08-19 00" & timestamp < "2016-08-19 07")')
 df_train = df_train.query('not(building_id == 1365 & meter == 0 & timestamp > "2016-06-18 22" & timestamp < "2016-06-19 06")')
 df_train = df_train.query('not(building_id == 18 & meter == 0 & timestamp > "2016-06-04 09" & timestamp < "2016-06-04 16")')
 df_train = df_train.query('not(building_id == 18 & meter == 0 & timestamp > "2016-11-05 05" & timestamp < "2016-11-05 15")')
 df_train = df_train.query('not(building_id == 101 & meter == 0 & meter_reading > 800)')
 df_train = df_train.query('not(building_id == 1384 & meter == 0 & meter_reading == 0)')
 df_train = df_train.query('not(building_id >= 1289 & building_id <= 1301 & meter == 2 & meter_reading == 0)')
 df_train = df_train.query('not(building_id == 1243 & meter == 2 & meter_reading == 0)')
 df_train = df_train.query('not(building_id == 1263 & meter == 2 & meter_reading == 0)')
 df_train = df_train.query('not(building_id == 1284 & meter == 2 & meter_reading == 0)')
 df_train = df_train.query('not(building_id == 1286 & meter == 2 & meter_reading == 0)')
 df_train = df_train.query('not(building_id == 1263 & meter == 0 & timestamp > "2016-11-10 11" & timestamp < "2016-11-10 15")')
 df_train = df_train.query('not(building_id == 1238 & meter == 2 & meter_reading == 0)')
 df_train = df_train.query('not(building_id == 1329 & meter == 2 & timestamp > "2016-11-21 12" & timestamp < "2016-11-29 12")')
 df_train = df_train.query('not(building_id == 1249 & meter == 2 & meter_reading == 0)')
 df_train = df_train.query('not(building_id == 1250 & meter == 2 & meter_reading == 0)')
 df_train = df_train.query('not(building_id == 1256 & meter == 2 & timestamp > "2016-03-05 18" & timestamp < "2016-03-05 22")')
 df_train = df_train.query('not(building_id == 1256 & meter == 2 & timestamp > "2016-03-27 00" & timestamp < "2016-03-27 23")')
 df_train = df_train.query('not(building_id == 1256 & meter == 2 & timestamp > "2016-04-11 09" & timestamp < "2016-04-13 03")')
 df_train = df_train.query('not(building_id == 1256 & meter == 2 & timestamp > "2016-04-29 00" & timestamp < "2016-04-30 15")')
 df_train = df_train.query('not(building_id == 1303 & meter == 2 & timestamp < "2016-06-06 19")')
 df_train = df_train.query('not(building_id >= 1223 & building_id <= 1324 & meter == 1 & timestamp > "2016-08-11 17" & timestamp < "2016-08-12 17")')
 df_train = df_train.query('not(building_id >= 1223 & building_id <= 1324 & building_id != 1296 & building_id != 129 & building_id != 1298 & building_id != 1299 & meter == 2 & timestamp > "2016-08-11 17" & timestamp < "2016-08-12 17")')
 df_train = df_train.query('not(building_id >= 1223 & building_id <= 1324 & meter == 3 & timestamp > "2016-08-11 17" & timestamp < "2016-08-12 17")' )
train_datagen = image_generator_xd(size=size, batchsize=batchsize, ks=range(NCSVS - 1))<define_variables>
bm_cols = ['bm', 'weekday', 'hour',]
df_train['hour'] = df_train['timestamp'].dt.hour
df_train['weekday'] = df_train['timestamp'].dt.weekday
df_train['bm'] = df_train['building_id'].apply(lambda x: str(x)) + '_' + df_train['meter'].apply(lambda x: str(x))
bm = df_train.groupby(bm_cols)['meter_reading'].mean().rename('bm_week_hour' ).to_frame()
color = [(187,255,255),(106, 90, 205),(0, 255, 127),(255,255,0),(255,193,37),(205,92,92), 
(244, 164, 96),(255, 105, 180),(218, 112, 214),(255, 165, 0),(139, 134, 130),(24, 116, 205), 
(187,255,255),(106, 90, 205),(0, 255, 127),(255,255,0),(255,193,37),(205,92,92), 
(244, 164, 96),(255, 105, 180),(218, 112, 214),(255, 165, 0),(139, 134, 130),(24, 116, 205), 
(187,255,255),(106, 90, 205),(0, 255, 127),(255,255,0),(255,193,37),(205,92,92), 
(244, 164, 96),(255, 105, 180),(218, 112, 214),(255, 165, 0),(139, 134, 130),(24, 116, 205)]
def draw_cv2_strokes(raw_strokes, size=256, lw=4, color = color):
img = np.zeros(( size, size, 3), np.uint8)
 for t, stroke in enumerate(raw_strokes):
cl = color[t]
for i in range(len(stroke[0])- 1):
_ = cv2.line(img,(stroke[0][i] * size // BASE_SIZE, stroke[1][i] * size // BASE_SIZE), 
(stroke[0][i + 1] * size // BASE_SIZE, stroke[1][i + 1] * size // BASE_SIZE), cl, lw)
 return img
def image_generator_xd(size, batchsize, ks, lw=6):
while True:
for k in np.random.permutation(ks):
filename = os.path.join(DP_DIR, 'train_k{}.csv.gz'.format(k))
for df in pd.read_csv(filename, chunksize=batchsize):
df['drawing'] = df['drawing'].apply(ast.literal_eval)
 x = np.zeros(( len(df), size, size, 3))
for i, raw_strokes in enumerate(df.drawing.values):
num_of_strokes = len(raw_strokes)
 if num_of_strokes == 1:
x[i, :, :, 0] = draw_cv2_strokes(raw_strokes, size=size, lw=lw 
)[:, :, 0]
x[i, :, :, 1] = draw_cv2_strokes(raw_strokes, size=size, lw=lw 
)[:, :, 1]
x[i, :, :, 2] = draw_cv2_strokes(raw_strokes, size=size, lw=lw 
)[:, :, 2]
elif num_of_strokes == 2:
x[i, :, :, 0] = draw_cv2_strokes(raw_strokes, size=size, lw=lw 
)[:, :, 0]
x[i, :, :, 1] = draw_cv2_strokes(raw_strokes, size=size, lw=lw 
)[:, :, 1]
x[i, :, :, 2] = draw_cv2_strokes(raw_strokes, size=size, lw=lw 
)[:, :, 2]
else:
x[i, :, :, 0] = draw_cv2_strokes(raw_strokes, size=size, lw=lw 
)[:, :, 0]
x[i, :, :, 1] = draw_cv2_strokes(raw_strokes, size=size, lw=lw 
)[:, :, 1]
x[i, :, :, 2] = draw_cv2_strokes(raw_strokes, size=size, lw=lw 
)[:, :, 2]
x = preprocess_input(x ).astype(np.float32)
 y = keras.utils.to_categorical(df.y, num_classes=NCATS)
 yield x, y
def df_to_image_array_xd(df, size, lw=6):
df['drawing'] = df['drawing'].apply(ast.literal_eval)
 x = np.zeros(( len(df), size, size, 3))
for i, raw_strokes in enumerate(df.drawing.values):
num_of_strokes = len(raw_strokes)
 if num_of_strokes == 1:
x[i, :, :, 0] = draw_cv2_strokes(raw_strokes, size=size, lw=lw 
)[:, :, 0]
x[i, :, :, 1] = draw_cv2_strokes(raw_strokes, size=size, lw=lw 
)[:, :, 1]
x[i, :, :, 2] = draw_cv2_strokes(raw_strokes, size=size, lw=lw 
)[:, :, 2]
elif num_of_strokes == 2:
x[i, :, :, 0] = draw_cv2_strokes(raw_strokes, size=size, lw=lw 
)[:, :, 0]
x[i, :, :, 1] = draw_cv2_strokes(raw_strokes, size=size, lw=lw 
)[:, :, 1]
x[i, :, :, 2] = draw_cv2_strokes(raw_strokes, size=size, lw=lw 
)[:, :, 2]
else:
x[i, :, :, 0] = draw_cv2_strokes(raw_strokes, size=size, lw=lw 
)[:, :, 0]
x[i, :, :, 1] = draw_cv2_strokes(raw_strokes, size=size, lw=lw 
)[:, :, 1]
x[i, :, :, 2] = draw_cv2_strokes(raw_strokes, size=size, lw=lw 
)[:, :, 2]
x = preprocess_input(x ).astype(np.float32)
 return x<drop_column>
df_train = df_train.merge(bm, right_index=True, left_on=bm_cols, how='left' )
train_datagen = image_generator_xd(size=size, batchsize=batchsize, ks=range(NCSVS - 1))<set_options>
df_train.drop(['bm'], axis=1, inplace=True)
 df_train.head()
warnings.filterwarnings('ignore')
 %matplotlib inline
%config InlineBackend.figure_format = 'retina' 
<import_modules>
weather = pd.concat([weather_train, weather_test],ignore_index=True)
 weather_key = ['site_id', 'timestamp']
full_weather = weather[weather_key + ['air_temperature']].drop_duplicates(subset=weather_key ).sort_values(by=weather_key ).copy()
import torch
import torch.nn as nn
from torch.utils.data import Dataset, DataLoader, ConcatDataset
import torchvision
from torchvision import transforms, utils<categorify>
full_weather['timestamp'] = pd.to_datetime(full_weather['timestamp'] )
en_dict = {}
path = '.. /input/train_simplified/'
filenames = glob.glob(os.path.join(path, '*.csv'))
filenames = sorted(filenames)
 def encode_files() :

 counter = 0
for fn in filenames:
en_dict[fn[:-4].split('/')[-1].replace(' ', '_')] = counter
counter += 1
encode_files()
dec_dict = {v: k for k, v in en_dict.items() }
def decode_labels(label):
return dec_dict[label]
def get_label(nfile):

 return en_dict[nfile.replace(' ', '_')[:-4]]<load_from_csv>
full_weather['temp_rank'] = full_weather.groupby(['site_id', full_weather.timestamp.dt.date])['air_temperature'].rank('average')
 df_2d = full_weather.groupby(['site_id', full_weather.timestamp.dt.hour])['temp_rank'].mean().unstack(level=1)
 site_ids_offsets = pd.Series(df_2d.values.argmax(axis=1)- 14)
 site_ids_offsets.index.name = 'site_id'
def timestamp_align(df):
df['offset'] = df.site_id.map(site_ids_offsets)
 df['timestamp_aligned'] =(df.timestamp - pd.to_timedelta(df.offset, unit='H'))
df['timestamp'] = df['timestamp_aligned']
del df['timestamp_aligned']
return df
class DoodlesDataset(Dataset):

 def __init__(self, csv_file, root_dir, mode='train', nrows=1000, skiprows=None, size=256, transform=None):

 self.root_dir = root_dir
file = os.path.join(self.root_dir, csv_file)
 self.size = size
self.mode = mode
self.doodle = pd.read_csv(file, usecols=['drawing'], nrows=nrows, skiprows=skiprows)
 self.transform = transform
if self.mode == 'train':
self.label = get_label(csv_file)
 @staticmethod
def _draw(raw_strokes, size=256, lw=6, time_color=True):
BASE_SIZE = 256
img = np.zeros(( BASE_SIZE, BASE_SIZE), np.uint8)
 for t, stroke in enumerate(raw_strokes):
for i in range(len(stroke[0])- 1):
color = 255 - min(t, 10)* 13 if time_color else 255
_ = cv2.line(img,(stroke[0][i], stroke[1][i]), 
(stroke[0][i + 1], stroke[1][i + 1]), color, lw)
 if size != BASE_SIZE:
return cv2.resize(img,(size, size))
else:
return img
def __len__(self):
return len(self.doodle)
 def __getitem__(self, idx):
raw_strokes = ast.literal_eval(self.doodle.drawing[idx])
 sample = self._draw(raw_strokes, size=self.size, lw=2, time_color=True)
 if self.transform:
sample = self.transform(sample)
 if self.mode == 'train':
return(sample[None]/255 ).astype('float32'), self.label
else:
return(sample[None]/255 ).astype('float32' )<create_dataframe>
def reduce_mem_usage(df, use_float16=False):

 start_mem = df.memory_usage().sum() / 1024**2
print("Memory usage of dataframe is {:.2f} MB".format(start_mem))
for col in df.columns:
if is_datetime(df[col])or is_categorical_dtype(df[col]):
continue
col_type = df[col].dtype
if col_type != object:
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 use_float16 and 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)
 else:
df[col] = df[col].astype("category")
 end_mem = df.memory_usage().sum() / 1024**2
print("Memory usage after optimization is: {:.2f} MB".format(end_mem))
print("Decreased by {:.1f}%".format(100 *(start_mem - end_mem)/ start_mem))
return df
SIZE = 224
select_nrows = 10000
doodles = ConcatDataset([DoodlesDataset(fn.split('/')[-1], path,
nrows=select_nrows, size=SIZE)for fn in filenames] )<load_pretrained>
def fill_weather_dataset(weather_df):
time_format = "%Y-%m-%d %H:%M:%S"
start_date = datetime.datetime.strptime(weather_df['timestamp'].min() ,time_format)
 end_date = datetime.datetime.strptime(weather_df['timestamp'].max() ,time_format)
 total_hours = int(((end_date - start_date ).total_seconds() + 3600)/ 3600)
 hours_list = [(end_date - datetime.timedelta(hours=x)).strftime(time_format)for x in range(total_hours)]
missing_hours = []
for site_id in range(16):
site_hours = np.array(weather_df[weather_df['site_id'] == site_id]['timestamp'])
 new_rows = pd.DataFrame(np.setdiff1d(hours_list,site_hours),columns=['timestamp'])
 new_rows['site_id'] = site_id
weather_df = pd.concat([weather_df,new_rows])
 weather_df = weather_df.reset_index(drop=True)
 weather_df["timestamp"] = pd.to_datetime(weather_df["timestamp"])
 weather_df["day"] = weather_df["timestamp"].dt.day
weather_df["week"] = weather_df["timestamp"].dt.week
weather_df["month"] = weather_df["timestamp"].dt.month
weather_df = weather_df.set_index(['site_id','day','month'])
 air_temperature_filler = pd.DataFrame(weather_df.groupby(['site_id','day','month'])['air_temperature'].mean() ,columns=["air_temperature"])
 weather_df.update(air_temperature_filler,overwrite=False)
 cloud_coverage_filler = weather_df.groupby(['site_id','day','month'])['cloud_coverage'].mean()
cloud_coverage_filler = pd.DataFrame(cloud_coverage_filler.fillna(method='ffill'),columns=["cloud_coverage"])
 weather_df.update(cloud_coverage_filler,overwrite=False)
 due_temperature_filler = pd.DataFrame(weather_df.groupby(['site_id','day','month'])['dew_temperature'].mean() ,columns=["dew_temperature"])
 weather_df.update(due_temperature_filler,overwrite=False)
 sea_level_filler = weather_df.groupby(['site_id','day','month'])['sea_level_pressure'].mean()
sea_level_filler = pd.DataFrame(sea_level_filler.fillna(method='ffill'),columns=['sea_level_pressure'])
 weather_df.update(sea_level_filler,overwrite=False)
 wind_direction_filler = pd.DataFrame(weather_df.groupby(['site_id','day','month'])['wind_direction'].mean() ,columns=['wind_direction'])
 weather_df.update(wind_direction_filler,overwrite=False)
 wind_speed_filler = pd.DataFrame(weather_df.groupby(['site_id','day','month'])['wind_speed'].mean() ,columns=['wind_speed'])
 weather_df.update(wind_speed_filler,overwrite=False)
 precip_depth_filler = weather_df.groupby(['site_id','day','month'])['precip_depth_1_hr'].mean()
precip_depth_filler = pd.DataFrame(precip_depth_filler.fillna(method='ffill'),columns=['precip_depth_1_hr'])
 weather_df.update(precip_depth_filler,overwrite=False)
 weather_df = weather_df.reset_index()
weather_df = weather_df.drop(['day','week','month'],axis=1)
 return weather_df
print('Train set:', len(doodles))
loader = DataLoader(doodles, batch_size=128, shuffle=True, num_workers=0)
<train_model>
weather_train = fill_weather_dataset(weather_train )
def validation(lossf, scoref):
model.eval()
loss, score = 0, 0
vlen = len(valid_loader)
 for x, y in valid_loader:
x, y = x.to(device), y.to(device)
 output = model(x)
 loss += lossf(output, y ).item()
score += scoref(output, y)[0].item()
model.train()
return loss/vlen, score/vlen<compute_test_metric>
df_train = reduce_mem_usage(df_train, use_float16=True)
 building = reduce_mem_usage(building, use_float16=True)
 weather_train = reduce_mem_usage(weather_train, use_float16=True )
def accuracy(output, target, topk=(3,)) :

 with torch.no_grad() :
maxk = max(topk)
 batch_size = target.size(0)
 _, pred = output.topk(maxk, 1, True, True)
 pred = pred.t()
correct = pred.eq(target.view(1, -1 ).expand_as(pred))
res = []
for k in topk:
correct_k = correct[:k].view(-1 ).float().sum(0, keepdim=True)
 res.append(correct_k.mul_(100.0 / batch_size))
return res<categorify>
def rmse(ytrue, ypred):
return np.sqrt(np.mean(np.square(ypred - ytrue), axis=0))
def rmsle(ytrue, ypred):
return np.sqrt(np.mean(np.square(np.log1p(ypred)- np.log1p(ytrue)) , axis=0))
def mapk(output, target, k=3):

 with torch.no_grad() :
batch_size = target.size(0)
 _, pred = output.topk(k, 1, True, True)
 pred = pred.t()
correct = pred.eq(target.view(1, -1 ).expand_as(pred))
for i in range(k):
correct[i] = correct[i]*(k-i)
 score = correct[:k].view(-1 ).float().sum(0, keepdim=True)
 score.mul_(1.0 /(k * batch_size))
return score<choose_model_class>
le = LabelEncoder()
def prepare_data(X, building_data, weather_data, test=False):

 weather_data = timestamp_align(weather_data)
 X = X.merge(building_data, on="building_id", how="left")
 X = X.merge(weather_data, on=["site_id", "timestamp"], how="left")
 X.sort_values("timestamp")
 X.reset_index(drop=True)
 gc.collect()
X.timestamp = pd.to_datetime(X.timestamp, format="%Y-%m-%d %H:%M:%S")
 X.square_feet = np.log1p(X.square_feet)
 X["hour"] = X.timestamp.dt.hour
X["weekday"] = X.timestamp.dt.weekday
X['hour'] = X['hour'].astype('int8')
 X['weekday'] = X['weekday'].astype('int8')
 drop_features = ["timestamp", "site_id","sea_level_pressure", "precip_depth_1_hr",]
X.drop(drop_features, axis=1, inplace=True)
 X = reduce_mem_usage(X, use_float16=True)
 if test:
row_ids = X.row_id
X.drop("row_id", axis=1, inplace=True)
 return X, row_ids
else:
y = np.log1p(X.meter_reading)
 X.drop("meter_reading", axis=1, inplace=True)
 return X, y
model = torchvision.models.resnet18(pretrained=True )<init_hyperparams>
X_train, y_train = prepare_data(df_train, building, weather_train)
 del df_train, weather_train
gc.collect()
def squeeze_weights(m):
m.weight.data = m.weight.data.sum(dim=1)[:,None]
m.in_channels = 1
model.conv1.apply(squeeze_weights);
num_classes = 340
model.fc = nn.Linear(in_features=512, out_features=num_classes, bias=True )<define_search_space>
%%time
X_half_1 = X_train[:int(X_train.shape[0] / 2)]
X_half_2 = X_train[int(X_train.shape[0] / 2):]
y_half_1 = y_train[:int(X_train.shape[0] / 2)]
y_half_2 = y_train[int(X_train.shape[0] / 2):]
categorical_features = ["building_id", "meter", "primary_use", "hour", "weekday"]
d_half_1 = lgb.Dataset(X_half_1, label=y_half_1, categorical_feature=categorical_features, free_raw_data=False)
 d_half_2 = lgb.Dataset(X_half_2, label=y_half_2, categorical_feature=categorical_features, free_raw_data=False)
 watchlist_1 = [d_half_1, d_half_2]
watchlist_2 = [d_half_2, d_half_1]
params = {
"objective": "regression",
"boosting": "gbdt",
"num_leaves": 40,
"learning_rate": 0.05,
"feature_fraction": 0.85,
"reg_lambda": 2,
"metric": "rmse",
"num_threads": 2
}
print("Building model with first half and validating on second half:")
 model_half_1 = lgb.train(params, train_set=d_half_1, num_boost_round=1000, valid_sets=watchlist_1, verbose_eval=200, early_stopping_rounds=200)
 print("Building model with second half and validating on first half:")
 model_half_2 = lgb.train(params, train_set=d_half_2, num_boost_round=1000, valid_sets=watchlist_2, verbose_eval=200, early_stopping_rounds=200 )
%%time
model(torch.randn(12,1,224,224)).size()<train_model>
%%time
pred = np.zeros(len(X_train))
pred1 = model_half_1.predict(X_half_2)
 pred2 = model_half_2.predict(X_half_1 )
device = 'cuda'
model.to(device);<choose_model_class>
pred = np.zeros(len(X_train))
pred[:len(pred2)] += pred2
pred[len(pred2):] += pred1
print(f"Half/Half RMSE: {rmse(pred, y_train):.4f}" )
criterion = nn.CrossEntropyLoss()
optimizer = torch.optim.Adam(model.parameters() , lr=0.002, amsgrad=True )<choose_model_class>
pickle.dump(model_half_1, open("model_half_1.pkl", "wb"))
pickle.dump(model_half_2, open("model_half_2.pkl", "wb"))
pickle.dump(pred, open("pred_L1.pkl", "wb"))
scheduler = torch.optim.lr_scheduler.MultiStepLR(optimizer, milestones=[5000,12000,18000], gamma=0.5 )<train_model>
del X_train, X_half_1, X_half_2, y_half_1, y_half_2, d_half_1, d_half_2,
del watchlist_1, watchlist_2, pred, pred1, pred2
gc.collect()
%%time
epochs = 1
lsize = len(loader)
 itr = 1
p_itr = 1000
model.train()
tloss, score = 0, 0
for epoch in range(epochs):
for x, y in loader:
x, y = x.to(device), y.to(device)
 optimizer.zero_grad()
output = model(x)
 loss = criterion(output, y)
 loss.backward()
optimizer.step()
tloss += loss.item()
score += mapk(output, y)[0].item()
scheduler.step()
if itr%p_itr==0:
print('Iteration {} -> Train Loss: {:.4f}, MAP@3: {:.3f}'.format(itr, tloss/p_itr, score/p_itr))
tloss, score = 0, 0
itr +=1<save_model>
weather_test = weather_df = pd.read_csv(DATA_PATH + 'weather_test.csv' )
filename_pth='checkpoint_resnet18.pth'
torch.save(model.state_dict() , filename_pth )<load_from_csv>
%%time
df_test = pd.read_feather('.. /input/ashrae-great-energy-predictor-iii-featherdataset/test.feather')
 weather_test = fill_weather_dataset(weather_test)
 df_test['hour'] = df_test['timestamp'].dt.hour
df_test['weekday'] = df_test['timestamp'].dt.weekday
df_test['bm'] = df_test['building_id'].apply(lambda x: str(x)) + '_' + df_test['meter'].apply(lambda x: str(x))
df_test = df_test.merge(bm, right_index=True, left_on=bm_cols, how='left')
 df_test.drop('bm', axis=1, inplace=True)
 df_test = reduce_mem_usage(df_test, use_float16=True)
 weather_test = reduce_mem_usage(weather_test, use_float16=True)
 X_test, row_ids = prepare_data(df_test, building, weather_test, test=True )
testset = DoodlesDataset('test_simplified.csv', '.. /input', mode='test', nrows=None, size=SIZE)
 testloader = DataLoader(testset, batch_size=128, shuffle=False, num_workers=0 )<find_best_params>
del df_test, building, weather_test
gc.collect()
model.eval()
labels = np.empty(( 0,3))
for x in tqdm.tqdm(testloader):
x = x.to(device)
 output = model(x)
 _, pred = output.topk(3, 1, True, True)
 labels = np.concatenate([labels, pred], axis = 0 )<load_from_csv>
%%time
pred = np.expm1(model_half_1.predict(X_test, num_iteration=model_half_1.best_iteration)) / 2
del model_half_1
gc.collect()
pred += np.expm1(model_half_2.predict(X_test, num_iteration=model_half_2.best_iteration)) / 2
del model_half_2
gc.collect()
%%time
submission = pd.read_csv('.. /input/test_simplified.csv', index_col='key_id')
 submission.drop(['countrycode', 'drawing'], axis=1, inplace=True)
 submission['word'] = ''
for i, label in enumerate(labels):
submission.word.iloc[i] = " ".join([decode_labels(l)for l in label] )<save_to_csv>
submission = pd.DataFrame({"row_id": row_ids, "meter_reading": np.clip(pred, 0, a_max=None)})
 submission['meter_reading'] = submission['meter_reading'].astype('float32')
 submission['row_id'] = submission['row_id'].astype('int32')
 submission.to_csv("submission.csv", index=False, chunksize=25000 )
<define_variables><EOS> 
submission[X_test['building_id'] > 105]