Defining Performance Plot

The function below plots the performance of the model over time. This function has been placed such that it is only plotted once our target of 200 points has been reached. You can also place this function to plot the progress after every 100 episodes during training. Sample plot output of the function (after the goal has been achieved) is shown below after the code snippet.

def performance_plot(scores, target_score):
"""Plot the game progress."""
scores_arr = np.array(scores) # convert list to array
scores_arr[np.where(scores_arr > target_score)] = target_score # scores
plt.figure(figsize=(20, 5)) # set figure size to 20 by 5
plt.title('Plot of Score v/s Episode') # title
plt.xlabel('Episodes') # xlabel
plt.ylabel('Scores') # ylabel
plt.plot(scores_arr)
plt.show()
Figure  15.6: Sample plot output of performance_plot function
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.113.55