<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 LSTM Time Series Example
This tutorial is based on Time Series Forecasting with the Long Short-Term Memory Network in Python by Jason Brownlee.
Part 1 - Data Prep
Before we get into the example, lets look at some visitor data from Yellowstone National park.
Step1:  The park's recreational visits are highly seasonable with the peak season in July.  The park tracks monthly averages from the last four years on it's web site.  A simple approach to predict the next years visitors, is to use these averages.
Step2:  ## Monthly Average Accuracy
Before this example uses Keras to predict visitors, we'll measure the monthly average method's root mean squared error.  While the monthly averages aren't compeletly accurate, this method is very simple and explainable.
<ASSISTANT_TASK:>
Python Code:
# load and plot dataset
from pandas import read_csv
from pandas import datetime
from matplotlib import pyplot
# load dataset
def parser(x):
    return datetime.strptime(x, '%Y-%m-%d')
series = read_csv('../data/yellowstone-visitors.csv', header=0, parse_dates=[0], index_col=0, squeeze=True, date_parser=parser)
# summarize first few rows
print(series.head())
# line plot
series.plot()
pyplot.show()
Explanation: LSTM Time Series Example
This tutorial is based on Time Series Forecasting with the Long Short-Term Memory Network in Python by Jason Brownlee.
Part 1 - Data Prep
Before we get into the example, lets look at some visitor data from Yellowstone National park.
End of explanation
prev_4_years = series[-60:-12]
last_year = series[12:]
pred = prev_4_years.groupby(by=prev_4_years.index.month).mean()
pred.plot()
act = last_year.groupby(by=last_year.index.month).mean()
act.plot()
pyplot.show()
Explanation: The park's recreational visits are highly seasonable with the peak season in July.  The park tracks monthly averages from the last four years on it's web site.  A simple approach to predict the next years visitors, is to use these averages.
End of explanation
from math import sqrt
from sklearn.metrics import mean_squared_error
rmse = sqrt(mean_squared_error(act, pred))
print('Test RMSE: %.3f' % rmse)
Explanation: ## Monthly Average Accuracy
Before this example uses Keras to predict visitors, we'll measure the monthly average method's root mean squared error.  While the monthly averages aren't compeletly accurate, this method is very simple and explainable.
End of explanation
<END_TASK>