Let's see how we can use RNNs to predict time series data:
- Create a new Python file and import the following packages (the full code is given in the LSTMstock.py file that is provided for you). The first part of the file was tackled in the previous recipe, Analyzing stock market data. We report it only for the completeness of the algorithm:
import numpy as npimport pandas as pdimport matplotlib.pyplot as pltfrom random import seedseed(0)Data = pd.read_csv('AMZN.csv',header=0, usecols=['Date', 'Close'],parse_dates=True,index_col='Date')
- It is good practice to rescale the data before training an LSTM algorithm. With rescaling, data units are eliminated, allowing you to compare data from different locations easily. In this ...