9. Sequential Modeling with Recurrent Neural Networks
Activity 9.01: Predicting the Trend of Amazon's Stock Price Using an LSTM with 50 Units (Neurons)
In this activity, we will examine the stock price of Amazon for the last 5 years—from January 1, 2014, to December 31, 2018. In doing so, we will try to predict and forecast the company's future trend for January 2019 using an RNN
and LSTM
. We have the actual values for January 2019, so we can compare our predictions to the actual values later. Follow these steps to complete this activity:
- Import the required libraries:
import numpy as np import matplotlib.pyplot as plt import pandas as pd from tensorflow import random
- Import the dataset using the pandas
read_csv
function and look at the first five rows of the dataset using thehead
method:dataset_training = pd.read_csv('../AMZN_train.csv') dataset_training.head()
The following figure shows the output of the preceding code: