Workspace
Abid Ali Awan/

MasterCard Stock Price with LSTM and GRU

0
Beta
Spinner

Tutorial For Recurrent Neural Network (RNN)

Image by author

A recurrent neural network (RNN) is the type of artificial neural network (ANN) that is used in Apple’s Siri and Google’s voice search. RNN remembers past inputs due to an internal memory which is useful for predicting stock prices, generating sentences, transcriptions, and machine translation.

The code is inspired from Siddgarth Yadav Intro to RNN

In this project, we are going to use Kaggle’s MasterCard Stock Data from May-25-2006 to Oct-11-2021 and train the LSTM and GRU model to forecast the stock price.

Data Analysis

Converting the Date column to DateTime format and adding it to index. Dropping irrelevant columns to make the final dataset cleaner.

No missing values, the dataset is clean.

MasterCard card stock prices have been on the high rise since 2016. It had a dip in the first quarter of 2020 but it gained a stable position in the latter half of the year.

Data Preprocessing

Simple train test split function

Normalizing the data using MinMaxScaler

Spliting a univariate sequence into samples

Reshaping X_train for efficient modelling