<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Prophet Baseline Notebook
This notebook contains the code used to predict the price of bitcoin just using FB prophet.
You can think of this as a sort of baseline model!
Step1:  Forecasting BTC Price with Fb Prophet
Step2:  Let's predict percentage change!
Step3:  MSE IS 0.000488913299898903
Step4:  we do terribly at predicting percent change! However, we know that percent change should be applied to the price of the previous day. Let's do that!
Note that the MSE is very close to 0 - we have quite an accurate Model!
<ASSISTANT_TASK:>
Python Code:
from fbprophet import Prophet
from sklearn.metrics import r2_score
%run helper_functions.py
%autosave 120
%matplotlib inline
%run prophet_helper.py
%run prophet_baseline_btc.py
plt.style.use('fivethirtyeight')
plt.rcParams["figure.figsize"] = (15,10)
plt.rcParams["xtick.labelsize"] = 16
plt.rcParams["ytick.labelsize"] = 16
plt.rcParams["axes.labelsize"] = 20
plt.rcParams['legend.fontsize'] = 20
plt.style.use('fivethirtyeight')
pd.set_option('display.max_colwidth', -1)
import numpy as np
import math
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error
from sklearn.metrics import r2_score
Explanation: Prophet Baseline Notebook
This notebook contains the code used to predict the price of bitcoin just using FB prophet.
You can think of this as a sort of baseline model!
End of explanation
df = unpickle_object("blockchain_info_df.pkl")
df.head()
df_btc = pd.DataFrame(df['mkt_price'])
true, pred = prophet_baseline_BTC(df_btc, 30, "mkt_price")
r2_score(true, pred) #we see that our baseline model just predicts 44% of the variation when predicting price
plt.plot(pred)
plt.plot(true)
plt.legend(["Prediction", 'Actual'], loc='upper left')
plt.xlabel("Prediction #")
plt.ylabel("Price")
plt.title("TS FB Prophet Baseline - Price Prediction");
Explanation: Forecasting BTC Price with Fb Prophet
End of explanation
df_btc_pct = df_btc.pct_change()
df_btc_pct.rename(columns={"mkt_price": "percent_change"}, inplace=True)
df_btc_pct = df_btc_pct.iloc[1:, :]
print(df_btc_pct.shape)
df_btc_pct.head()
true_pct, pred_pct = prophet_baseline_BTC(df_btc_pct, 30, "percent_change")
r2_score(true_pct, pred_pct)
Explanation: Let's predict percentage change!
End of explanation
plt.plot(pred_pct)
plt.plot(true_pct)
plt.legend(["Prediction", 'Actual'], loc='upper left')
plt.xlabel("Prediction #")
plt.ylabel("Price")
plt.title("TS FB Prophet Baseline - Price Prediction");
Explanation: MSE IS 0.000488913299898903
End of explanation
prices_to_be_multiplied = df.loc[pd.date_range(start="2017-01-23", end="2017-02-21"), "mkt_price"]
forecast_price_lst = []
for index, price in enumerate(prices_to_be_multiplied):
    predicted_percent_change = 1+float(pred_pct[index])
    forecasted_price = (predicted_percent_change)*price
    forecast_price_lst.append(forecasted_price)
ground_truth_prices = df.loc[pd.date_range(start="2017-01-24", end="2017-02-22"), "mkt_price"]
ground_truth_prices = list(ground_truth_prices)
r2_score(ground_truth_prices, forecast_price_lst) # such an incredible result! This is what we have to beat with my nested TS model
plt.plot(forecast_price_lst)
plt.plot(ground_truth_prices)
plt.legend(["Prediction", 'Actual'], loc='upper left')
plt.xlabel("Prediction #")
plt.ylabel("Price")
plt.title("TS FB Prophet Baseline - Price Prediction");
Explanation: we do terribly at predicting percent change! However, we know that percent change should be applied to the price of the previous day. Let's do that!
Note that the MSE is very close to 0 - we have quite an accurate Model!
End of explanation
<END_TASK>