|
|
import os
|
|
|
|
|
|
import pyecharts
|
|
|
from pyecharts.charts import Line
|
|
|
from pyecharts import options as opts
|
|
|
from pyecharts.globals import ThemeType
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
dir_path = r'E:\Data\Research\Outcome\Walmart-Amazon_dirty'
|
|
|
filename_list = os.listdir(dir_path)
|
|
|
iter_list = []
|
|
|
precision = []
|
|
|
recall = []
|
|
|
f1 = []
|
|
|
interpretability = []
|
|
|
performance = []
|
|
|
for _ in filename_list:
|
|
|
if _.startswith('eval_result'):
|
|
|
it = int(_[12:13])
|
|
|
iter_list.append(str(it))
|
|
|
with open(dir_path + '\\' + _, 'r') as f:
|
|
|
# 读取每一行的md,加入该文件的md列表
|
|
|
for line in f.readlines():
|
|
|
if line.startswith('Precision'):
|
|
|
lt = line.split(' ')
|
|
|
value = float(lt[2].replace('%', ''))/100
|
|
|
precision.append(value)
|
|
|
elif line.startswith('Recall'):
|
|
|
lt = line.split(' ')
|
|
|
value = float(lt[2].replace('%', ''))/100
|
|
|
recall.append(value)
|
|
|
elif line.startswith('F1'):
|
|
|
lt = line.split(' ')
|
|
|
value = float(lt[2].replace('%', ''))/100
|
|
|
f1.append(value)
|
|
|
elif line.startswith('interpretability'):
|
|
|
lt = line.split(':')
|
|
|
value = float(lt[1])
|
|
|
interpretability.append(value)
|
|
|
elif line.startswith('performance'):
|
|
|
lt = line.split(':')
|
|
|
value = float(lt[1])
|
|
|
performance.append(value)
|
|
|
|
|
|
line = (
|
|
|
Line(init_opts=opts.InitOpts(theme=ThemeType.LIGHT))
|
|
|
.add_xaxis(iter_list)
|
|
|
.add_yaxis('Precision', precision)
|
|
|
.add_yaxis('Recall', recall)
|
|
|
.add_yaxis('F1', f1)
|
|
|
.add_yaxis('Interpretability', interpretability)
|
|
|
.add_yaxis('Performance', performance)
|
|
|
.set_global_opts(title_opts=opts.TitleOpts(title=dir_path.split('\\')[-1]))
|
|
|
)
|
|
|
line.render(dir_path + '\\' + "line.html")
|