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.py

56 lines
2.1 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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