December 2018
Beginner to intermediate
684 pages
21h 9m
English
In this subsection, we will forecast the S&P 500 Index values (see the univariate_time_series_regression notebook for implementation details).
We obtain data for 2010-2018 from the Federal Reserved Bank's Data Service (FRED—see Chapter 2, Market and Fundamental Data), as follows:
sp500 = web.DataReader('SP500', 'fred', start='2010', end='2019').dropna()sp500.info()DatetimeIndex: 2264 entries, 2010-01-04 to 2018-12-31
Data columns (total 1 columns):
SP500 2264 non-null float64
We process the data by scaling it to the [0, 1] interval using scikit-learn's minmax_scale function, as shown here:
from sklearn.preprocessing import minmax_scalesp500_scaled = sp500.apply(minmax_scale)