Kaggle competition: Humpback Whale Identification
<SOS> metric: MAP@{K} Kaggle data source: humpback-whale-identification<feature_engineering>
import csv
import pandas as pd
x = [0,0,0,0]
num_x = [0,0,0,0]
for i in range(len(build_meter)) :
heat = df_train.meter_reading.loc[df_train.building_id==i].sum()
x[build_meter[i]-1] = x[build_meter[i]-1] + heat
num_x[build_meter[i]-1] = num_x[build_meter[i]-1]+1<data_type_conversions>
sub_files = [
'.. /input/esemble-lb-0-842/submission_1.csv',
'.. /input/humpback-ensemble/0.858_85_submission_0.45_standard_0.55_boostrap.csv',
]
sub_weight = [
0.842**2,
0.858**2,
]
<data_type_conversions><EOS> 
Hlabel = 'Image'
Htarget = 'Id'
npt = 6
place_weights = {}
for i in range(npt):
place_weights[i] =(1 /(i + 1))
print(place_weights)
 lg = len(sub_files)
 sub = [None]*lg
for i, file in enumerate(sub_files):
print("Reading {}: w={} - {}".format(i, sub_weight[i], file))
reader = csv.DictReader(open(file,"r"))
sub[i] = sorted(reader, key=lambda d: str(d[Hlabel]))
out = open("sub_ens.csv", "w", newline='')
 writer = csv.writer(out)
 writer.writerow([Hlabel,Htarget])
 for p, row in enumerate(sub[0]):
target_weight = {}
for s in range(lg):
row1 = sub[s][p]
for ind, trgt in enumerate(row1[Htarget].split(' ')) :
target_weight[trgt] = target_weight.get(trgt,0)+(place_weights[ind]*sub_weight[s])
 tops_trgt = sorted(target_weight, key=target_weight.get, reverse=True)[:npt]
writer.writerow([row1[Hlabel], " ".join(tops_trgt)])
 out.close()