简单的结果融合


import pandas as pd


def read_data(file_path):
    str = ""
    temp_dict = {}
    with open(file_path, 'r', encoding='utf-8-sig') as f:
        for idx, line in enumerate(f):
            if idx >=1:
                line = line.strip().split(',')
                id = line[0]
                level = line[1]
                temp_dict[id]=level
    return temp_dict
if __name__ == "__main__":
   # filepath = ['bert_0.7644559585492228.csv','bert_0.7630326851468763.csv',
   #         'bert_0.7609861770167113.csv','bert_0.7598887515451175.csv',
   #         'bert_0.7572367070416752.csv','bert_0.7563051055977035.csv']
   # temp_dict = read_data(filepath)
   # print(temp_dict)
   temp_dict1 = read_data('bert0.7909.csv')
   temp_dict2 = read_data('bert0.7915.csv')
   # temp_dict3 = read_data('ber3.csv')
   # temp_dict4 = read_data('ber4.csv')
   # temp_dict5 = read_data('ber5.csv')
   # temp_dict6 = read_data('ber6.csv')
   # temp_dict7 = read_data('ber7.csv')
   # temp_dict8 = read_data('ber8.csv')
   # temp_dict9 = read_data('ber9.csv')
   # temp_dict10 = read_data('ber10.csv')
   # temp_dict11 = read_data('ber11.csv')
   # temp_dict12 = read_data('ber12.csv')
   # temp_dict13 = read_data('ber13.csv')
   # temp_dict14 = read_data('ber14.csv')
   # temp_dict15 = read_data('ber15.csv')
   # temp_dict16 = read_data('ber16.csv')
   # temp_dict17 = read_data('ber17.csv')
   t_dict = {}

   with open('bert0.7909.csv', 'r', encoding='utf-8-sig') as f:
       for idx, line in enumerate(f):
           if idx >= 1:
               line = line.strip().split(',')
               id = line[0]
               temp_list = []

               temp_list.append(int(temp_dict1[id]))
               temp_list.append(int(temp_dict2[id]))
               # temp_list.append(int(temp_dict3[id]))
               # temp_list.append(int(temp_dict4[id]))
               # temp_list.append(int(temp_dict5[id]))
               # temp_list.append(int(temp_dict6[id]))
               # temp_list.append(int(temp_dict7[id]))
               # temp_list.append(int(temp_dict8[id]))
               # temp_list.append(int(temp_dict9[id]))
               # temp_list.append(int(temp_dict10[id]))
               # temp_list.append(int(temp_dict11[id]))
               # temp_list.append(int(temp_dict12[id]))
               # temp_list.append(int(temp_dict13[id]))
               # temp_list.append(int(temp_dict14[id]))
               # temp_list.append(int(temp_dict15[id]))
               # temp_list.append(int(temp_dict16[id]))
               # temp_list.append(int(temp_dict17[id]))

               value_max = 0
               index_max = 0
               value_max = max(temp_list.count(1),temp_list.count(2),temp_list.count(3),temp_list.count(4))
               if value_max == temp_list.count(1):
                   index_max = 1
               if value_max == temp_list.count(2):
                   index_max = 2
               if value_max == temp_list.count(3):
                   index_max = 3
               if value_max == temp_list.count(4):
                   index_max = 4
               t_dict[id] = index_max
   f.close()
   with open('bert_0.99.csv', 'w', encoding='utf-8-sig') as file99:
       with open('bert0.7909.csv', 'r', encoding='utf-8-sig') as f:
           for idx, line in enumerate(f):
               if idx >= 1:
                   line = line.strip().split(',')
                   id = line[0]
                   temp_str = id + "," + str(t_dict[id]) + "\n"
                   file99.write(temp_str)
       f.close()
   file99.close()
   count_1 = 0
   count_2 = 0
   count_3 = 0
   count_4 = 0
   with open('bert_0.99.csv', 'r', encoding='utf-8-sig') as f:
       for idx, line in enumerate(f):
               line = line.strip().split(',')
               id = line[0]
               level = line[1]
               # print(id,level)
               level = int(level)
               if level == 1:
                   count_1 = count_1 + 1
               if level == 2:
                   count_2 = count_2 + 1
               if level == 3:
                   count_3 = count_3 + 1
               if level == 4:
                   count_4 = count_4 + 1
   print(count_1, count_2, count_3, count_4, count_3+count_4+count_2+count_1)
   # 2173 2334 317 72 4896
   # 2216 2327 288 65 4896
   # 2181 2335 310 70 4896

























  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值