代码存档,读者可以绕道, 没有技术内容。
import xlrd
import xlwt
import numpy as np
from pathlib import Path
from collections import OrderedDict
read_path_1 = Path(r"D:\AOR_experiment\pointwise\uncertainty")
read_path_2 = Path(r"D:\AOR_experiment\pointwise\LogitA")
read_path_3 = Path(r"D:\AOR_experiment\pointwise\ALeSVM")
read_path_list = [read_path_1,read_path_2,read_path_3]
save_path = Path(r"D:\R_experiment\conf_result")
names_old = ["SWD"]
names_new = ["SWD"]
sheet_names = ["Acc_mean", "Acc_std", "MAE_mean", "MAE_std", "F1_mean", "F1_std", "Recall_mean",
"Recall_std", "ALC_Acc_list", "ALC_MAE_list", "ALC_F1_list", "ALC_Recall_list",
"ALC_Acc", "ALC_MAE", "ALC_F1", "ALC_Recall"]
class Stores():
def __init__(self):
self.AccList_mean = []
self.AccList_std = []
self.AccList_max = []
self.AccList_min = []
## ---------------------
self.MAEList_mean = []
self.MAEList_std = []
##--------------------
self.F1List_mean = []
self.F1List_std = []
##---------------------
self.Recall_mean = []
self.Recall_std = []
##---------------------
self.ALC_Acc_mean = []
self.ALC_Acc_std = []
##--------------------
self.ALC_MAE_mean = []
self.ALC_MAE_std = []
##-------------------
self.ALC_F1_mean = []
self.ALC_F1_std = []
##-------------------
self.ALC_Recall_mean = []
self.ALC_Recall_std = []
##-------------------
self.ALC_Acc = []
self.ALC_MAE = []
self.ALC_F1 = []
self.ALC_Recall = []
sheet = ["Acc_mean", "Acc_std", "MAE_mean", "MAE_std", "F1_mean", "F1_std", "Recall_mean",
"Recall_std", "ALC_Acc_list", "ALC_MAE_list", "ALC_F1_list", "ALC_Recall_list",
"ALC_Acc", "ALC_MAE", "ALC_F1", "ALC_Recall"]
result = OrderedDict()
for name in names_old:
result[name] = OrderedDict()
for sn in sheet_names:
result[name][sn] = OrderedDict()
for read_path in read_path_list:
path_result = None
if read_path == read_path_1:
path_result = read_path.joinpath(name + ".xls")
elif read_path == read_path_2:
path_result = read_path_2.joinpath(name + "-nAOR.xls")
elif read_path == read_path_3:
path_result = read_path_3.joinpath(name + "-ALeSVM.xls")
book = xlrd.open_workbook(path_result)
table = book.sheet_by_name(sn)
n_rows = table.nrows
for i in range(n_rows):
result[name][sn][table.row_values(i)[0]] = table.row_values(i)[1:]
# path_result = read_path_1.joinpath(name + ".xls")
# book = xlrd.open_workbook(path_result)
# table = book.sheet_by_name(sn)
# n_rows = table.nrows
# for i in range(n_rows):
# result[name][sn][table.row_values(i)[0]] = table.row_values(i)[1:]
#
# path_result = read_path_2.joinpath(name + "-nAOR.xls")
# book = xlrd.open_workbook(path_result)
# table = book.sheet_by_name(sn)
# n_rows = table.nrows
# for i in range(n_rows):
# result[name][sn][table.row_values(i)[0]] = table.row_values(i)[1:]
#
# path_result = read_path_3.joinpath(name + "-ALeSVM.xls")
# book = xlrd.open_workbook(path_result)
# table = book.sheet_by_name(sn)
# n_rows = table.nrows
# for i in range(n_rows):
# result[name][sn][table.row_values(i)[0]] = table.row_values(i)[1:]
break
print(len(result["SWD"]["Acc_mean"]))