-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathplot.py
More file actions
27 lines (23 loc) · 840 Bytes
/
plot.py
File metadata and controls
27 lines (23 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import argparse
import glob
import json
import matplotlib.pyplot as plt
import re
parser = argparse.ArgumentParser(description='Plot results from compare.py')
parser.add_argument('-em', '--eval-metric',
dest='metric',
help='Plot a specific metric',
default='rmse')
options = parser.parse_args()
fig, ax = plt.subplots(1, 1)
for filename in glob.glob('results/*.json'):
title = re.match('results/(.*).json', filename).group(1)
with open(filename) as f:
model_metrics = json.load(f)
if options.metric in model_metrics['train']:
ax.plot(model_metrics['train'][options.metric], label=title)
ax.legend()
ax.set_title('Comparing Mangaki Zero algorithms on Movielens')
ax.set_ylabel(options.metric.upper())
ax.set_xlabel('Epochs')
fig.savefig('plot.png')