Created
January 4, 2020 23:42
-
-
Save kperry2215/c6c5012c2ba287054067aed2c4326d8d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def plot_results(mean_predicted_values, confidence_interval_predicted_values, time_series): | |
""" | |
This function plots actual time series data against SARIMA model-predicted values. | |
We include the confidence interval for the predictions. | |
Args: | |
mean_predicted_values: Series of float values. The model-predicted values. | |
confidence_interval_predicted_values: Pandas dataframe, containing the lower and | |
upper confidence intervals. | |
time_series: Series of float values. Actual time series values that we want to graph | |
Outputs: | |
None. Plot of the time series values, as well as the predicted values and associated | |
confidence interval. | |
""" | |
ax = time_series.plot(label='Observed') | |
mean_predicted_values.plot(ax=ax, label = 'Forecast', alpha=.7, figsize=(14, 4)) | |
ax.fill_between(confidence_interval_predicted_values.index, | |
confidence_interval_predicted_values.iloc[:, 0], | |
confidence_interval_predicted_values.iloc[:, 1], color='k', alpha=.2) | |
ax.set_xlabel('Date Index') | |
ax.set_ylabel('Value') | |
plt.legend() | |
plt.show() | |
### EXECUTE IN MAIN FUNCTION ### | |
#Plot the predictions against the real data | |
plot_results(mean_predicted_values, | |
confidence_interval_predicted_values, | |
df['Geothermal_net_generation'][400:]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment