def get_ground_truth_dates(total_coin_results):
#ground_truth_dates = pickle.load(open(data_dir + 'get_ground_truth_dates.pickle', "rb"))
ground_truth_date_dict = {}
for seed_id, values in total_coin_results.iteritems():
for coin_id, result in values.iteritems():
if coin_id not in ground_truth_date_dict.iterkeys():
ground_truth_date_dict[coin_id] = [seed_id, 0]
if result > ground_truth_date_dict[coin_id][1]:
ground_truth_date_dict[coin_id] = [seed_id, result]
#it bugs me I am not using a more pythonic way here:
ground_truth_date_array = []
for coin_id, values in ground_truth_date_dict.iteritems():
seed_id = values[0]
result = values[1]
ground_truth_date_array.append([seed_id,coin_id, result,0,False,False])
ground_truth_date_array = sorted(ground_truth_date_array, key=lambda x: x[2],reverse = True)
ground_truth_date_array = sorted(ground_truth_date_array, key=lambda x: x[0])
pickle.dump(ground_truth_date_array, open(data_dir + 'ground_truth_dates.pickle', "wb"))
return ground_truth_date_array
评论列表
文章目录