()
| 52 | |
| 53 | |
| 54 | def plot_cross_splitter(): |
| 55 | fig = plt.figure() |
| 56 | for splitter in os.listdir('./'): |
| 57 | |
| 58 | if not splitter.startswith('chunk_size'): |
| 59 | continue |
| 60 | |
| 61 | if not os.path.isdir(splitter): |
| 62 | continue |
| 63 | |
| 64 | items = [] |
| 65 | for jsonl_file in os.listdir(splitter): |
| 66 | if not 'chunk_size' in jsonl_file: |
| 67 | continue |
| 68 | |
| 69 | print(splitter, jsonl_file) |
| 70 | datas = [] |
| 71 | |
| 72 | with open(os.path.join(splitter, jsonl_file)) as f: |
| 73 | for json_str in f: |
| 74 | json_obj = json.loads(json_str) |
| 75 | datas.append(json_obj) |
| 76 | datas.sort(key=lambda x: x['f1']) |
| 77 | |
| 78 | items.append({ |
| 79 | 'chunk_size': datas[-1]['chunk_size'], |
| 80 | 'f1': datas[-1]['f1'] |
| 81 | }) |
| 82 | |
| 83 | items.sort(key=lambda x: x['chunk_size']) |
| 84 | x = [] |
| 85 | y = [] |
| 86 | for item in items: |
| 87 | if item['chunk_size'] > 1000: |
| 88 | continue |
| 89 | x.append(item['chunk_size']) |
| 90 | y.append(item['f1']) |
| 91 | print(x, y) |
| 92 | # 绘制曲线 |
| 93 | label_name = splitter.split('chunk_size_')[-1] |
| 94 | plt.plot(x, y, label=label_name) |
| 95 | |
| 96 | # 添加标题和标签 |
| 97 | plt.xlabel('chunk_size') |
| 98 | plt.ylabel('best_f1') |
| 99 | plt.legend() |
| 100 | # 显示图形 |
| 101 | plt.show() |
| 102 | |
| 103 | |
| 104 | if __name__ == '__main__': |
nothing calls this directly
no outgoing calls
no test coverage detected