切换模式
返回顶部
首页
首页
Trick: 根据索引自适应二维矩阵数据显示
默认分类
·
01-06
ly
## 结果  ## 思路 - 简单而言就是先列举行和列,去重。 - 根据行和列的列表取出索引来填充列表。 - `from IPython.display import Markdown` 直接在Jupyter中显示内容。 ## 代码 ```python import glob def readTxt(path): human_plus=open(path,'r').read().split("\t")[-1].split("\n")[0] human=open(path,'r').read().split("\t")[-2].split("\n")[0] return (human_plus,human) def getInfo(path): _list=path.split("/") return _list[-3],_list[-2] models=set() datasets=set() for path in glob.glob("qwencoder-eval/instruct/eval_plus/results/Qwen/*/*/humaneval_results.txt"): model,dataset=getInfo(path) models.add(model) datasets.add(dataset) models=list(models) datasets=list(datasets) output_array_human=[[0]*len(datasets) for _ in range(len(models))] output_array_humanplus=[[0]*len(datasets) for _ in range(len(models))] for path in glob.glob("qwencoder-eval/instruct/eval_plus/results/Qwen/*/*/humaneval_results.txt"): model,dataset=getInfo(path) model_index,dataset_index=models.index(model),datasets.index(dataset) human,human_plus=readTxt(path) output_array_human[model_index][dataset_index]=human output_array_humanplus[model_index][dataset_index]=human_plus for model_index in range(len(models)): output_array_human[model_index].insert(0,models[model_index]) output_array_humanplus[model_index].insert(0,models[model_index]) datasets=[i.replace("human_eval_docs.","").replace(".jsonl","") for i in datasets] datasets.insert(0,"") output_array_human.insert(0,datasets) output_array_humanplus.insert(0,datasets) def list_to_markdown_table(lst): # 首先,提取表头,即列表的第一行元素 headers = lst[0] # 然后,提取表格的数据部分,即列表的其余行 data = lst[1:] # 构建 Markdown 表格的表头部分 markdown = "| " + " | ".join(headers) + " |\n" markdown += "| " + " | ".join(["---"] * len(headers)) + " |\n" # 遍历数据行,将每一行数据添加到 Markdown 表格中 for row in data: markdown += "| " + " | ".join(str(item) for item in row) + " |\n" return markdown from IPython.display import Markdown markdown_table=list_to_markdown_table(output_array_human) display(Markdown(markdown_table)) ```
取消回复
提交评论
ly
热门文章
最新评论
鍗庣撼鍏徃鍚堜綔寮€鎴锋墍闇€鏉愭枡锛熺數璇濆彿鐮?5587291507 寰俊STS5099: 华纳东方明珠客服电话是多少?(??155--8729--1507...
鍗庣撼鍏徃鍚堜綔寮€鎴锋墍闇€鏉愭枡锛熺數璇濆彿鐮?5587291507 寰俊STS5099: 华纳东方明珠客服电话是多少?(??155--8729--1507...
鍗庣撼鍏徃鍚堜綔寮€鎴锋墍闇€鏉愭枡锛熺數璇濆彿鐮?5587291507 寰俊STS5099: 华纳东方明珠客服电话是多少?(??155--8729--1507...
鍗庣撼鍏徃鍚堜綔寮€鎴锋墍闇€鏉愭枡锛熺數璇濆彿鐮?5587291507 寰俊STS5099: 华纳东方明珠客服电话是多少?(??155--8729--1507...
鍗庣撼鍏徃鍚堜綔寮€鎴锋墍闇€鏉愭枡锛熺數璇濆彿鐮?5587291507 寰俊STS5099: 华纳东方明珠客服电话是多少?(▲18288362750?《?微信...
鍗庣撼鍏徃鍚堜綔寮€鎴锋墍闇€鏉愭枡锛熺數璇濆彿鐮?5587291507 寰俊STS5099: 华纳东方明珠客服电话是多少?(▲18288362750?《?微信...
鍗庣撼鍏徃鍚堜綔寮€鎴锋墍闇€鏉愭枡锛熺數璇濆彿鐮?5587291507 寰俊STS5099: 华纳东方明珠客服电话是多少?(▲18288362750?《?微信...
热门标签
关于站长
Theme
Jasmine
by
Kent Liao