Project 5 - Stock Price Prediction in Python
Description
The program uses an artifical Recurrent Nerual Network (RNN) called Long Short Term Memory (LSTM) to predict the closing stock price of a corporation, like Apple Inc. using the past 60 day stock price.
Firstly, we import the library for computation processing. We get the stock quote from the website Yahoo using web.DataReader(), specifying the start date and end date of data extraction. Then we show the dataframe by commaning df, which comprises of 2270 rows (a day for a row), and 6 columns (Hig, Low, Open, Close, Volume, Adjusted Close).

From the above plot, we observe that Appl.Inc keep increasing in stock price, and even accelerate from 2019 to 2021.We only interested in the Close column only, so we create this column and convert the data frame to numpy array.We then get the number of rows to train the model.
we build the LSTM model and compile it. Then we train the model with the batch_zie =1, epoches =1. fter training the data, we test it. We put the data generated by creating two lists for test data. Get all of the rows from index to the rest and all of the columns (in this case it’s only column ‘Close’). We then convert x_test to a numpy array, reshape the data into the shape accepted by the LSTM. Finally, we get the models predicted price values. We do the inverse_transform is to undo scaling. To chck if the model is accurate enough, we get the value of RMSE 3.06, which is pretty good.
