Execute the following steps to use the exponential smoothing methods to create forecasts of Google's stock prices.
- Import the libraries:
import pandas as pdimport numpy as npimport yfinance as yffrom datetime import datefrom statsmodels.tsa.holtwinters import (ExponentialSmoothing, SimpleExpSmoothing, Holt)
- Download the adjusted stock prices for Google:
df = yf.download('GOOG', start='2010-01-01', end='2018-12-31', adjusted=True, progress=False)
- Aggregate to monthly frequency:
goog = df.resample('M') \ .last() \ .rename(columns={'Adj Close': 'adj_close'}) \ .adj_close
- Create the training/test split:
train_indices = goog.index.year < 2018goog_train = goog[train_indices]goog_test = goog[~train_indices]test_length ...