Guest User

Untitled

a guest
Jan 17th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. # Set up the plot
  2. fig, ax = plt.subplots(1, 1)
  3.  
  4. # Plot the actual values
  5. ax.plot(train['ds'], train['y'], 'ko-', linewidth = 1.4, alpha = 0.8, ms = 1.8, label = 'Observations')
  6. ax.plot(test['ds'], test['y'], 'ko-', linewidth = 1.4, alpha = 0.8, ms = 1.8, label = 'Observations')
  7.  
  8. # Plot the predicted values
  9. ax.plot(future['ds'], future['yhat'], 'navy', linewidth = 2.4, label = 'Predicted');
  10.  
  11. # Plot the uncertainty interval as ribbon
  12. ax.fill_between(future['ds'].dt.to_pydatetime(), future['yhat_upper'], future['yhat_lower'], alpha = 0.6,
  13. facecolor = 'gold', edgecolor = 'k', linewidth = 1.4, label = 'Confidence Interval')
  14.  
  15. # Put a vertical line at the start of predictions
  16. plt.vlines(x=min(test['ds']).date(), ymin=min(future['yhat_lower']), ymax=max(future['yhat_upper']), colors = 'r',
  17. linestyles='dashed', label = 'Prediction Start')
  18.  
  19. # Plot formatting
  20. plt.legend(loc = 2, prop={'size': 8}); plt.xlabel('Date'); plt.ylabel('Price $');
  21. plt.grid(linewidth=0.6, alpha = 0.6)
  22.  
  23. plt.title('{} Model Evaluation from {} to {}.'.format(self.symbol,
  24. start_date.date(), end_date.date()));
  25. plt.show();
  26.  
  27. ax.fill_between(future['ds'].dt.to_pydatetime(), future['yhat_upper'], future['yhat_lower'], alpha = 0.6,
Add Comment
Please, Sign In to add comment