You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
matching_dependency/draw/draw_inter_weight_lines.py

52 lines
2.2 KiB

11 months ago
import os
import pyecharts.options as opts
from pyecharts.charts import Line
from pyecharts.faker import Faker
if __name__ == '__main__':
outcome_dir = r'E:\Data\Research\Outcome'
datasets_list = os.listdir(outcome_dir)
inter_list = ['0', '0.5', '0.7', '0.9', '1']
configs_dir = r'\Magellan+Smac+roberta-large-nli-stsb-mean-tokens+inter-'
for _ in datasets_list:
block_recall_list = []
f1 = []
interpretability = []
for inter in inter_list:
path = outcome_dir + rf'\{_}' + configs_dir + inter
statistics_files = os.listdir(path)
for i in statistics_files:
if i.startswith('eval_result'):
with open(path + rf'\{i}', 'r') as f:
# 读取每一行的md加入该文件的md列表
for line in f.readlines():
if line.startswith('block_recall'):
lt = line.split(':')
value = float(lt[1])
block_recall_list.append(round(value, ndigits=3))
elif line.startswith('F1'):
lt = line.split(' ')
value = float(lt[2].replace('%', '')) / 100
f1.append(round(value, ndigits=3))
elif line.startswith('interpretability'):
lt = line.split(':')
value = float(lt[1])
interpretability.append(round(value, ndigits=3))
interpretability[0] = 0
c = (
Line()
.add_xaxis(inter_list)
.add_yaxis("Block Recall", block_recall_list)
.add_yaxis("F1", f1)
.add_yaxis("Interpretability", interpretability)
.set_global_opts(
title_opts=opts.TitleOpts(title=_),
# yaxis_opts=opts.AxisOpts(name="Block Recall", name_location="middle", name_gap=15, name_rotate=0),
xaxis_opts=opts.AxisOpts(name="Interpretability Weight", name_location="middle", name_gap=25)
)
.render(outcome_dir + rf'\{_}\inter_weight_lines.html')
)