Different machine learning algorithms are discussed in this literature review. These algorithms can be used for predicting the stock market. The prediction of the stock market is one of the challenging tasks that must have to be handled.In this paper, it is discussed how the machine learning algorithms can be used for predicting the stock value. Different attributes are identified that can be used for training the algorithm for this purpose. Some of the other factors are also discussed that can have an effect on the stock value.
Introduction
I. INTRODUCTION
The stock market is the place where the buyers and sellers come for the purpose of buying the stocks and selling the stocks of a company. With the passage of time, more and more people are getting interested in the stock market. The
increasing interest of the people makes this topic more important for the research. Machine learning provides different predictive algorithms that can be very helpful in this domain. Different sectors are using the machine learning
for their improvement. The use of machine learning enables the computers to learn without the involvement of any external program.Recurrent neural networks (RNN) have proved one of the most powerful models for processing sequential data.Long Short-Term memory is one of the most successful RNNs architectures. LSTM
RNN, capable of learning long-term dependencies. They were introduced by Hochreiter & Schmidhuber (1997), and were refined and popularised by many people in following work.1 They work tremendously well on a large variety of problems, and are now widely used. The paper that we have presented modelled and predicted the stock returns of Apple and 5 other major tech companies using LSTM. We are in the ever growing generation on financial literacy and the never ending scope on the stock market. Although people have been using pen paper and the traditional mathematical manner to predict stock movement. So after looking at the other few models and methods available we decided to take a dive into this field and have a solution that can predict the movement of stocks for an individual .
II. METHODOLOGY
A. Proposed Systems
The prediction methods can be mainly categorised into two ,statistical methods and artificial intelligence methods. Statistical methods consist of logistic regression model, ARCH model, etc. Artificial intelligence methods includes multi-layer
perceptron, convolutional neural network, Back propagation network,single-layer LSTM, recurrent neural network, etc. They used a Long short-term memory network (LSTM).
B. Long Short Term Memory
Long Short Term Memory networks – usually just called “LSTMs” – are a special kind of RNN, capable of learning long-term dependencies. They were introduced by Hochreiter & Schmidhuber (1997), and were refined and popularised by many people in following work.1 They work tremendously well on a large variety of problems, and are now widely used.
C. Working of LSTM
LSTM is a special network that has three gates in its structures. these gates are placed in an LSTM unit, called as input gate, forgetting gate and output gate.AS the information enters the LSTM’s network, it can be selected by rules defined . Only the information that follows the algorithm will be left, and the information that does not follow the algorithm will be forgotten through the forgetting gate. The experimental data in this paper are the actual historical data downloaded from the Internet. Three data sets were used in the experiments. It is needed to find an optimization algorithm that requires less resources and has faster convergence speed. The System that we propose has several steps that lead to model generation . The steps involved are as follows .
Stage 1: Raw Data: In this stage, the historical stock data is collected from the internet and this historical data is used for the prediction of future stock prices.
Stage 2: Data Preprocessing: The pre-processing stage involves
a. Data discretization: Part of data reduction but with particular importance, especially for numerical data
b. Data transformation: Normalisation.
c. Data cleaning: Fill in missing values.
d. Data integration: Integration of data files. After the dataset is transformed into a clean dataset, the dataset is divided into training and testing sets so as to evaluate. Here, the training values are taken as the more recent values. Testing data is kept as 5-10 percent of the total dataset
3. Stage 3: Training Neural Network: In this stage, the data is fed to the neural network and trained the prediction is done by assigning random biases and weights. Our LSTM model is composed of a sequential input layer followed by 2 LSTM layers and 4 dense layer with ReLU activation and then finally a dense output layer.
4. Stage 5: Output Generation: In this layer, the output value generated by the output layer is compared to the target value from the dataset . The error or the difference between the target and the obtained output value is minimized by using back propagation algorithm which adjusts the weights and the biases of the network
D. Advantages of LSTM
The advantage of the Long Short-Term Memory (LSTM) network over other recurrent networks back in 1997 came from an improved method of back propagating the error. Hochreiter and Schmidhuber called it “constant error back propagation”
One of the main advantages of LSTM is its capacity to read intermediary context. Each unit of cll remembers data for a
long / short period without unambiguously utilising the activation function.
An important fact is that any cell state is repeated only with the release of the forget gate, which varies between range of 0
to 1. That’s to say, the gateway for forgetting in the LSTM cell is responsible for both the hardware and the function of
the cell state activation. LSTMs were developed to deal with the vanishing gradient problem that can be encountered when training traditional RNNs.
E. Analysis
In our system for analysis we have used the root mean squared error method . The error of the difference between the target and predicted value is minimized by the RMSE value . The use of RMSE is highly common. It makes an excellent general purpose error metric . Compared to the similar Mean Absolute Error, RMSE amplifies and severely punishes large errors.
III. DATASET
The dataset that we have used is of 5 tech giants in the NASDAQ market . The dataset used are of Apple ,Amazon , Google , Microsoft and Tesla .The different columns or as we refer to them as features are as followed
Here the values are as followed :-
Date: Date of which prices are listed.
Open: Opening price of stock on that date .
High: Highest value of the stock on that date.
Low: Lowest prices of the stock on that date .
Close: The closing price of the stock
Adj, Close: Adjusted close is the price of the stock after dividends and other related manipulation .
Volume: Volume of stock traded on that day .
The main model was created using the dataset for Apple
IV. PROPOSED SYSTEM
A. System Components
V. EDA AND DATA PRE-PROCESSING
A. Data Cleaning
The dataset is not in the right format to use directly with the model hence data preprocessing is required . In our model we did a few steps as followed :
Dropping the null rows
VI. DEFINING CUSTOM LEARNING RATE
A. Code
We created a scheduler function that takes in the number of epochs and sets a custom learning rate and then we passed on the Learning rate scheduler function of keras via the tensorflow module . The code for the scheduler is as follows .
VII. MODEL CREATION
A. Splitting the dataset
For model creation we split the data for training and testing based on the period / date the stock price was recorded . We defined a function that splits the dataset . The function divided the dataset in training and testing and further into the training dependent and independent variables. We then split the data based on time as this is a time series based problem .
B. Fitting the Model
The model that we created was compiled using the Adam optimizer that we imported from Keras . The loss function used for mse and the metric for evaluation that we used is RMSE as defined above that was also used from the keras metric function of keras .
We fit the model using the training split of the dataset by passing the dependent and the independent variables . We passed the testing dataset in the validation dataset and passed the callback function that we made defining the learning rate scheduler .
VII. EXPERIMENTAL ANALYSIS
A. Loss and Error
We recorded the loss and error that we realised came down as the number of epoch kept increasing . The loss and error is as follows for the model we created .
B. Prediction Of The Future Price Using Testing Dataset
We used the the predict function of the model that was created compiled and fitted using the training dataset and we passed on the testing dataset to find the prediction . The predicted and the target value was plotted and the results are as shown below.
Conclusion
The popularity of stock market trading is growing rapidly between the domestic and international marker , which is encouraging researchers to find new methods for prediction using new techniques and using more and more of the historical dataset with time as it goes on increasing .
The forecasting technique is not only helping the researchers but it also helps investors and any individual dealing with the stock market. In order to help predict the stock indices, a forecasting model with good accuracy is required.
In our work, we have used one of the most precise forecasting technologies using Recurrent Neural Network and LSTM unit which will help investors, analysts or any person interested in investing in the stock market by providing them a good knowledge of the future situation of the stock market of domestic and international markets .
References
[1] Prediction of Stock Market Using Recurrent Neural Network - Sadman Bin Islam; Mohammad Mahabubul Hasan; Mohammad Monirujjaman Khan - 27-30 Oct. 2021.
[2] Stock market prediction using LSTM Recurrent Neural Network - Adil Moghar, Mahmed Hamiche -April 6-9, 2020 .
[3] Comparison of Predictive Algorithms: Backpropagation, SVM,LSTM and Kalman Filter for Stock Market - Divit Karmiani ,Ruman Kazi,Ameya Nambisan, Aastha Shah, Vijaya Kamble.
[4] Predicting Stock Market Price: A Logical Strategy using Deep Learning - Milon Biswas; Atanu Shome; Md. Ashraful Islam; Arafat Jahan Nova; Shamim Ahmed - 3-4 April 2021 .
[5] Deep Learning-Based Stock Price Prediction Using LSTM and Bi-Directional LSTM Model - Md. Arif Istiake Sunny; Mirza Mohd Shahriar Maswood; Abdullah G. Alharbi - 24-26 Oct. 2020