<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Simple example of using Facebook's Prophet
We will use public road traffic data to train the model and forecast future road traffic.
Main intention is to show how simple Prophet usage is, forecast itself is very secondary.
First set up the requirements
Step1:  Sample road traffic data in CSV format can be downloaded here (for the sake of this example, dataset is included in the repository).
Load the data parsing dates as required. We also rename columns to ds and y in accordance with the convention used by Prophet.
Step2:  Split data into two sets - one for training and one for testing our model
Step3:  All that is required to do the forecast
Step4:  We can also query our model to show us trend, weekly and yearly components of the forecast
<ASSISTANT_TASK:>
Python Code:
from fbprophet import Prophet
import pandas as pd
%matplotlib notebook
import matplotlib
Explanation: Simple example of using Facebook's Prophet
We will use public road traffic data to train the model and forecast future road traffic.
Main intention is to show how simple Prophet usage is, forecast itself is very secondary.
First set up the requirements:
End of explanation
date_parse = lambda date: pd.datetime.strptime(date, '%Y-%m-%d')
time_series = pd.read_csv("solarhringsumferd-a-talningarsto.csv", header=0, names=['ds', 'y'], usecols=[0, 1],
                          parse_dates=[0], date_parser=date_parse)
Explanation: Sample road traffic data in CSV format can be downloaded here (for the sake of this example, dataset is included in the repository).
Load the data parsing dates as required. We also rename columns to ds and y in accordance with the convention used by Prophet.
End of explanation
training = time_series[time_series['ds'] < '2009-01-01']
testing = time_series[time_series['ds'] > '2009-01-01']
testing.columns = ['ds', 'ytest']
training.plot(x='ds');
Explanation: Split data into two sets - one for training and one for testing our model:
End of explanation
# Train the model.
model = Prophet()
model.fit(training)
# Define period to make forecast for.
future = model.make_future_dataframe(periods=365*2)
# Perform prediction for the defined period.
predicted_full = model.predict(future)
# We only plot date and predicted value.
# Full prediction contains much more data, like confidence intervals, for example.
predicted = predicted_full[['ds', 'yhat']]
# Plot training, testing and predicted values together.
combined = training.merge(testing, on='ds', how='outer')
combined = combined.merge(predicted, on='ds', how='outer')
combined.columns = ['Date', 'Training', 'Testing', 'Predicted']
# Only show the "intersting part" - no point in looking at the past.
combined[combined['Date'] > '2008-01-01'].plot(x='Date');
Explanation: All that is required to do the forecast:
End of explanation
model.plot_components(predicted_full);
Explanation: We can also query our model to show us trend, weekly and yearly components of the forecast:
End of explanation
<END_TASK>