Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.14 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3.  
  4.  
  5. def plot_learning_result(values, soften=20, legend=None):
  6.     # TODO popraw srednia kroczaco - pierwsze n liczb nie jest usrednianych
  7.     # https://stackoverflow.com/questions/14313510/how-to-calculate-moving-average-using-numpy
  8.     if legend is not None:
  9.         title_str = "Alpha: {}, Epsilon: {},\n Gamma: {}, Epsilon decay: {}, Alpha decay: {}".format(legend["alpha"],
  10.                                                                                                     legend["epsilon"],
  11.                                                                                                     legend['gamma'],
  12.                                                                                                     legend['epsilon decay'],
  13.                                                                                                      legend['alpha decay'])
  14.     else:
  15.         title_str = "Reward, moving average"
  16.     values_avg = [np.mean(values[i-soften:i]) for i in range(soften, len(values))]
  17.     plt.plot(np.arange(0, len(values_avg)), values_avg)
  18.     plt.title(title_str)
  19.     plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement