Save json dictionaries

This commit is contained in:
felipecode 2018-04-11 15:02:49 +02:00
parent 5e1f851f75
commit a92480c431
2 changed files with 7 additions and 11 deletions

View File

@ -282,12 +282,12 @@ class Metrics(object):
w))]
metrics_dictionary['episodes_fully_completed'][w][t] = \
experiment_results_matrix[:, header.index('result')]
experiment_results_matrix[:, header.index('result')].tolist()
metrics_dictionary['episodes_completion'][w][t] = \
(experiment_results_matrix[:, header.index('initial_distance')]
- experiment_results_matrix[:, header.index('final_distance')]) \
/ experiment_results_matrix[:, header.index('initial_distance')]
((experiment_results_matrix[:, header.index('initial_distance')]
- experiment_results_matrix[:, header.index('final_distance')])
/ experiment_results_matrix[:, header.index('initial_distance')]).tolist()
# Now we divide the experiment metrics matrix

View File

@ -1,5 +1,6 @@
import os
import numpy as np
import json
def print_summary(metrics_summary, weathers, path):
"""
@ -14,15 +15,10 @@ def print_summary(metrics_summary, weathers, path):
6: 'Heavy Rain Noon', 8: 'Clear Sunset',
4: 'Cloudy After Rain', 14: 'Soft Rain Sunset'}
# First we write the entire dictionary on the benchmark folder.
fout = os.path.join(path, 'metrics.txt')
fo = open(fout, "w")
with open(os.path.join(path, 'metrics.json'), 'w') as fo:
fo.write(json.dumps(metrics_summary, fo))
for k, v in metrics_summary.items():
fo.write(str(k) + ' >>> ' + str(v) + '\n\n')
fo.close()
# Second we plot the metrics that are already ready by averaging
metrics_to_average = [