<jupyter_start><jupyter_text>Prophet Baseline NotebookThis 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!<jupyter_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<jupyter_output><empty_output><jupyter_text>Forecasting BTC Price with Fb Prophet<jupyter_code>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");<jupyter_output><empty_output><jupyter_text>Let's predict percentage change!<jupyter_code>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)<jupyter_output><empty_output><jupyter_text>MSE IS 0.000488913299898903<jupyter_code>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");<jupyter_output><empty_output><jupyter_text>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!<jupyter_code>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");<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11994989038521767, 'fraction_numerical': 0.025367992483557783, 'mean_word_length': 7.97191011235955, 'pattern_counts': {'":': 1, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '50354', 'license': 'MIT', 'n_tokens_mistral': 1252, 'n_tokens_neox': 1131, 'n_words': 246, 'path': '05-project-kojack/Prophet_baseline_model.ipynb', 'repo_name': 'igabr/Metis_Projects_Chicago_2017', 'size': '3193'}