<jupyter_start><jupyter_text>Average method: the forecasts of all future values are equal to the average (or “mean”) of the historical data.Naïve method: we simply set all forecasts to be the value of the last observation. This method works remarkably well for many economic and financial time series.Drift method: This is equivalent to drawing a line between the first and last observations, and extrapolating it into the future.  API Load<jupyter_code>import requests
wiki_page = 'Jeopardy!'
start = '20150101'
end = '20190524'
r = requests.get('https://wikimedia.org/api/rest_v1/metrics/pageviews/per-article/en.wikipedia/all-access/all-agents/{}/daily/{}/{}'
                 .format(wiki_page,start,end))
json_dump = r.json()['items']
df = pd.DataFrame(json_dump)
df = df[['timestamp','views']]
df['timestamp'] = pd.to_datetime(df['timestamp'],format="%Y%m%d%H")
df.head()
df = df.set_index('timestamp')<jupyter_output><empty_output><jupyter_text>Quick View<jupyter_code>df.plot(figsize=(16,9))
df = df.reindex(pd.date_range(start='2015-07-01',end='2020-05-24'))<jupyter_output><empty_output><jupyter_text>Average method:<jupyter_code>df['mean'] = df['views'].mean()
df.plot(figsize=(16,9))<jupyter_output><empty_output><jupyter_text>Naïve method:<jupyter_code>df['naive'] = df['views'].shift(1).ffill()
df.head()
df.plot(figsize=(16,9))<jupyter_output><empty_output><jupyter_text>Prophet<jupyter_code>df.head()
df = df.reset_index().rename(columns ={'index':'ds','views':'y'})
from fbprophet import Prophet
model = Prophet()
model.fit(df)
future = model.make_future_dataframe(periods=365)
forecast = model.predict(future)
model.plot(forecast)
model.plot_components(forecast)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1567251461988304, 'fraction_numerical': 0.026900584795321637, 'mean_word_length': 7.597989949748744, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 1, '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': '164653', 'license': 'MIT', 'n_tokens_mistral': 636, 'n_tokens_neox': 594, 'n_words': 114, 'path': 'module1-making-forecasts/assignment_making_forecasts.ipynb', 'repo_name': 'RidleyLeisy/DS-Unit-2-Regression-1', 'size': '1710'}