Stock Prediction Using Machine Learning
Stock Prediction Using Machine Learning
Abstract: The Trend of stock price prediction is becoming more popular than ever. Share market is difficult to
predict due to its volatile nature. There are no rules to follow to predict what will happen with the stock in the
future. To predict accurately is a huge challenge since the market trend always keep changing depending on
many factors. The objective is to apply machine learning techniques to predict stocks and maximize the profit.
In this work, we have shown that with the help of artificial intelligence and machine learning, the process of
prediction can be improved. While doing the literature review, we realized that the most effective machine
learning tool for this research include: Artificial Neural Network (ANN), Support Vector Machine (SVM), and
Genetic Algorithms (GA). All categories have common and unique findings and limitations. We collected data
for about 10 years and used Long Short-Term Memory (LSTM) Neural Network-based machine learning
models to analyze and predict the stock price. The Recurrent Neural Network (RNN) is useful to preserve the
time-series features for improving profits. The financial data High and Close are used as input for the model.
Key-Words: - Date Mining, Machine learning, Stock Prediction, Date Cleaning, Data Prediction, Recurrent
Neural Network, Data Normalization, Support Vector Machine (SVM), Genetic Algorithms
Received: June 27, 2021. Revised: October 25, 2021. Accepted: November 28, 2021. Published: December 16, 2021.
Figure 5: LSTM
4.2 Building the LSTM model: Graph 2: Bank of America Stock Prediction
To build the LSTM model we will need to import
Keras library and packages. Keras is basically tenser
flow high-level API for building and training
models. Here we are going to import some libraries.
Next, we are going to initialize RNN. For time Graph 3: McDonald's Stock Prediction
series problems like this we are going to use
regression model. The first step in this is to read the
This LSTM model is composed of a sequential
data which is a sequential data, and we are going to
input layer followed by three LSTM layers and a
assign this to regressor.
dense layer. In the model we are also using dropout.
The dropout is a regularization technique for
After this we are going to move to the next step
reducing overfitting, so it drops out units in neural
that is the most important stage training the model.
networks.
After this we are going to compile the model. there are many factors and problems that should be
Here we are using optimizer. Optimizers are considered before making a prediction.
methods used to change the attributes of the neural
network such as weights and learning rate in order
to reduce the losses. The type of optimizer used can
greatly affect how fast the algorithm converges to
the minimum value. Here we are using Adam
optimizer. The Adam optimizer combines the perk
of two other optimizers ADAgrad and RMSprop.
influence the prediction in order to develop an [8] Thomas Fischer and Christopher Krauss long
efficient product with accuracy of results. We can short-term memory networks for financial
conclude that historical data can be used as powerful market predictions Volume 270, Issue 2, 16
tool that allows us to forecast the movement more October 2018, Pages 654-669
accurately. However, our method might not generate [9] Ming-ChiLee. Using support vector machine
the accurate result in this case for the number of with a hybrid feature selection method to the
reasons mentioned such as any negative or positive stock trend prediction. Volume 36, Issue
news or sudden change in market etc. Machine 8, October 2009, Pages 10896-10904
learning is the best way to recognize patterns and [10] M. Roondiwala, H. Patel and S. Varma,
predict results rather than apply the analysis "Predicting stock prices using LSTM,"
manually on large sets of data. There are some International Journal of Science and Research
drawbacks that need to consider while applying the (IJSR), vol. 6, no. 4, pp. 1754-1756, · April
algorithm to predict the result. Nobody should 2017
blindly rely on these models and invest since there [11] https://analyticsindiamag.com/comparing-
are number of reasons that the prediction can go in arima-model-and-lstm-rnn-model-in-time-
other direction. series-forecasting/
[12] Vaishnavi Gururaj, Shriya V R and Dr.
8. Future Work: Ashwini K, Stock Market Prediction using
The model used in my project has shown very Linear Regression and Support Vector
promising result. From the various results shown Machines Volume 14, Number 8 2019
through graphs and tables in the research can [13] Colah's blog August 27, 2015 Understanding
confirm that my model is capable of tracing the LSTM Networks
evolution of closing prices. For our future work we [14] Hongxiang Fan, Mingliang Jiang, Ligang Xu,
will try to find the best sets for about data length Hua Zhu, Junxiang Cheng,and Jiahu Jiang,
and number of training epochs that better suit our Comparison of Long Short Term Memory
assets and maximize our prediction accuracy. Networks and the Hydrological Modelling
Runoff Simulation
Reference:
[1] Adil Moghar and Mhamed Hamicheb. Stock Author Contributions:
Market Prediction Using LSTM Recurrent Shubha Singh: Graduate Student doing her thesis.
Neural Network, Procedia Computer Science. Her role was doing the research and implementation
Volume 170, 2020, Pages 1168-1173 of this paper. This paper was part of her master
[2] Pramod and Mallikarjuna Shastry.Stock Price thesis.
Prediction Using LSTM. January 2021. Test Sreedevi Gutta: Advisor of Shubha. Dr. Gutta was
Engineering and Management 83 (May-June the advisor of Shubha and provided valuable
2020):5246-5251. comments every week mainly on sections 3 and 4.
[3] Kyoung-jaeKim and IngooHan. prediction of Ahmad Hadaegh: “co-advisor”. Dr. Hadaegh also
stock price index. Volume 19, Issue 2, August directed Shubha in her work providing valuable
2000, Pages 125-132 feedback mainly on sections 4 and 5.
[4] Raghav Nandakumar1, Uttamraj K R2, Vishal
R3, Y V Lokeswari4. Stock Price Prediction Creative Commons Attribution License 4.0
Using Long Short-Term Memory. Volume: 05
Issue: 03 |Mar-2018. International Research
(Attribution 4.0 International, CC BY 4.0)
Journal of Engineering and Technology This article is published under the terms of the Creative
(IRJET) Commons Attribution License 4.0
[5] Shipra Saxena. Introduction to Long Short- https://creativecommons.org/licenses/by/4.0/deed.en_US
Term Memory. March 16, 2021
[6] Mingyue Qiu and Yu Song. Predicting the
Direction of Stock Market Index Movement
Using an Optimized Artificial Neural Network
Model May 19, 2016
[7] M.R. Hassan and B. Nath. Stock market
forecasting using hidden Markov model. 23
January 2006