This commit is contained in:
mlxu995 2021-12-16 12:50:10 +08:00
parent 4dd49e0f5c
commit 8383ae2f90

View File

@ -38,16 +38,17 @@ def plot_det_curve(keywords, stats_dir, figure_file):
plt.rcParams['font.size'] = 12 plt.rcParams['font.size'] = 12
for index, keyword in enumerate(keywords): for index, keyword in enumerate(keywords):
stats_file = os.path.join(stats_dir, 'stats.'+str(index)+'.txt') stats_file = os.path.join(stats_dir, 'stats.' + str(index) + '.txt')
values = load_stats_file(stats_file) values = load_stats_file(stats_file)
plt.plot(values[:, 0], values[:, 1], label=keyword) plt.plot(values[:, 0], values[:, 1], label=keyword)
plt.xlim([0, 5]) plt.xlim([0, 5])
plt.ylim([0, 0.35]) plt.ylim([0, 0.35])
plt.xticks([0, 1, 2, 3, 4, 5], ['0', '1','2','3','4','5']) plt.xticks([0, 1, 2, 3, 4, 5], ['0', '1', '2', '3', '4', '5'])
plt.yticks([0, 0.05, 0.10, 0.15, 0.20, 0.25, 0.30, 0.35], ['0', '5','10','15','20','25','30','35']) plt.yticks([0, 0.05, 0.10, 0.15, 0.20, 0.25, 0.30, 0.35],
['0', '5', '10', '15', '20', '25', '30', '35'])
plt.xlabel('False Alarm Per Hour') plt.xlabel('False Alarm Per Hour')
plt.ylabel('False Rejection Rate (\%)') plt.ylabel('False Rejection Rate (\\%)')
plt.grid(linestyle='--') plt.grid(linestyle='--')
plt.legend(loc='best', fontsize=16) plt.legend(loc='best', fontsize=16)
plt.savefig(figure_file) plt.savefig(figure_file)
@ -55,7 +56,8 @@ def plot_det_curve(keywords, stats_dir, figure_file):
if __name__ == '__main__': if __name__ == '__main__':
parser = argparse.ArgumentParser(description='plot det curve') parser = argparse.ArgumentParser(description='plot det curve')
parser.add_argument('--keywords', required=True, help='keywords, must in the same order as in "dict/words.txt" separated by ", "') parser.add_argument('--keywords', required=True,
help='keywords, must in the same order as in "dict/words.txt" separated by ", "')
parser.add_argument('--stats_dir', required=True, help='dir of stats files') parser.add_argument('--stats_dir', required=True, help='dir of stats files')
parser.add_argument('--figure_file', required=True, help='path to save det curve') parser.add_argument('--figure_file', required=True, help='path to save det curve')