Python:实验数据保存

代码存档,读者可以绕道, 没有技术内容。

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"]))

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

DeniuHe

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值