Learn practical skills, build real-world projects, and advance your career
# Description: This program used ANN called LSTM. We will use this to predict the closing price of a corporation (Apple Inc.)
# import the libraries
import math
import pandas_datareader as web
import numpy as np
import pandas as pd
from sklearn.preprocessing import MinMaxScaler
from keras.models import Sequential
from keras.layers import Dense, LSTM
import matplotlib.pyplot as plt
plt.style.use("fivethirtyeight")
/usr/local/lib/python3.6/dist-packages/pandas_datareader/compat/__init__.py:7: FutureWarning: pandas.util.testing is deprecated. Use the functions in the public API at pandas.testing instead. from pandas.util.testing import assert_frame_equal
# Get the stock quote
df = web.DataReader('AAPL', data_source='yahoo', start='2012-01-01', end="2019-12-7")
#show the data
df
# number of rows as columns
df.shape
(1996, 6)
# visualize the closing price history
plt.figure(figsize=(16,8))
plt.title("Close Price History")
plt.plot(df['Close'])
plt.xlabel('Date', fontsize=18)
plt.ylabel('Close Price USD$', fontsize=18)
plt.show()
Notebook Image