0% found this document useful (0 votes)
13 views10 pages

Prediction of Stock Price Using Machine Learning Techniques

The paper discusses the use of Long Short-Term Memory (LSTM) and Random Forest machine learning techniques for predicting stock prices, demonstrating that LSTM outperforms traditional models with high accuracy metrics. The study emphasizes the importance of historical data and technical indicators in enhancing prediction accuracy, providing valuable insights for financial analysts and traders. The findings suggest that deep learning methods like LSTM can effectively address the complexities of stock price forecasting.

Uploaded by

Jake
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views10 pages

Prediction of Stock Price Using Machine Learning Techniques

The paper discusses the use of Long Short-Term Memory (LSTM) and Random Forest machine learning techniques for predicting stock prices, demonstrating that LSTM outperforms traditional models with high accuracy metrics. The study emphasizes the importance of historical data and technical indicators in enhancing prediction accuracy, providing valuable insights for financial analysts and traders. The findings suggest that deep learning methods like LSTM can effectively address the complexities of stock price forecasting.

Uploaded by

Jake
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/375153752

Prediction of Stock Price Using Machine Learning Techniques

Conference Paper · September 2023


DOI: 10.1109/ICIDeA59866.2023.10295232

CITATION
S READS

0 92

4 authors, including:

Swarna Prabha Jena


Dhiraj Gupta
Centurion University of Technology and
Management Liverpool Heart and Chest NHS Foundation Trust

26 PUBLICATIONS 18 CITATIONS 272 PUBLICATIONS 6,366 CITATIONS

Bijay Paikaray
Sri Sri University
60 PUBLICATIONS 88 CITATIONS

All content following this page was uploaded by Bijay Paikaray on 22 December 2023.

The user has requested enhancement of the downloaded file.


2023 IEEE 2nd International Conference on Industrial Electronics: Developments & Applications (ICIDeA)

Prediction of Stock Price Using Machine Learning


Techniques
Swarna Prabha Jena
Ankit Kumar Yadav Dhiraj Gupta Bijay Kumar Paikaray
Department of ECE,
Department of CSE, Department of CSE, Faculty of Emerging
Centurion of University of Technologies,
Centurion of University of Centurion of University of
Technology and Sri Sri University,
Technology and Management, Technology and Management,
Management,
Odisha, India Odisha, India Cuttack, India
Odisha, India [email protected]
[email protected] [email protected]
[email protected]
2023 IEEE 2nd International Conference on Industrial Electronics: Developments & Applications (ICIDeA) | 979-8-3503-8197-9/23/$31.00 ©2023 IEEE | DOI:

Abstract—The paper presents a study on stock price


prediction using a Long Short-Term Memory (LSTM) model
and other machine learning techniques like Random Forest 979-8-3503-8197-9/23/$31.00 ©2023 IEEE
(RF). The LSTM model was trained on historical stock price
data and technical indicators to forecast future stock prices
accurately. Evaluation metrics demonstrate the LSTM model's
superior predictive accuracy compared to benchmark models.
The findings highlight the potential of LSTM and machine
learning for stock price prediction, offering implications for
financial analysts and traders. The results show that both RF
and LSTM can predict stock prices reasonably, with LSTM
performing slightly better than RF. Through LSTM, R2 =0.99,
MSE=0.029, RMSE= 0.49 has been calculated. The work
suggests that deep learning methods such as LSTM can be a
promising approach for stock price prediction, especially when
dealing with complex and noisy data.

Keywords—LSTM; PML; Real Time Data; Accuracy; Deep


Learning; Data Filling; Processing; Gates;

I. INTRODUCTION
The ability to accurately predict stock prices has long
been a goal in financial analysis. Accurate stock price
forecasts can provide valuable insights for investors, traders,
and financial institutions, aiding in informed decision-
making and potentially yielding significant investment
returns. In recent years, advanced machine learning
techniques, such as Long Short-Term Memory (LSTM)
models, have opened up new avenues for improving stock
price prediction accuracy [1].
This paper uses LSTM models and machine learning
techniques to forecast stock prices. LSTM models are
recurrent neural network that excels at capturing long-term
dependencies in sequential data [2]. By leveraging historical
stock price data and relevant technical indicators, the LSTM
model can learn complex patterns and trends in the market,
enabling it to make accurate predictions.
The main objective of this research is to develop and
evaluate an LSTM model for stock price prediction. The
study involves training the model on a historical stock price
information dataset, including open, high, low, and close
prices and trading volume. In addition, various technical
indicators are incorporated as features to capture market
dynamics and trends. Rigorous preprocessing and feature
engineering techniques are employed to ensure the quality and
relevance of the data.

169
To assess the performance of the LSTM model, a
comprehensive set of evaluation metrics, including mean
absolute error (MAE), mean squared error (MSE), and
root mean squared error (RMSE), are utilized [3].
Comparative analysis is conducted with benchmark
models to gauge the effectiveness and superiority of the
LSTM approach.
The findings of this research have significant
implications for the field of stock price prediction and
the wider financial community. By demonstrating the
potential of LSTM models and machine learning
techniques, this study offers valuable insights for
financial analysts, investors, and traders seeking to
improve their forecasting accuracy and make well-
informed decisions in the stock market.
The subsequent sections of this paper present a
detailed methodology, experimental results, and a
comprehensive discussion of the findings. Furthermore,
recommendations and future research directions are
provided to enhance the performance and applicability of
LSTM models in stock price prediction.
The following is a description of the structure of this
research paper. The section I, is the introduction and
opening section primarily explain the research
background, significance, progress, and primary research
information. The section II, reviews the literature that
includes both the theoretical underpinnings of classic
time series approaches and deep learning methods. The
design of models, data sources, preprocessing
techniques, and strategies for parameter optimization are
all covered in section III and section IV analysis,
modelling following the previous chapter's stages.
Section V, contains the paper's conclusion and
implications.
II. LITERATURE REVIEW
We have studied about 20 papers and came to abstract
the knowledge like [4][5][9]. It stated how to measure
the best parameter preferable for the volume and high
bid segment. Although there are number of methods and
formulas to calculate, the accuracy for real-time data is a
little different, which is mentioned in the. [6][9]. LSTM
is used in many research works but also got to know that
there are so many different ways to use a single model,
which was mentioned there [6][7][8]. They use machine
learning algorithms to predict the stock price in all these
cases we studied. They used different machine-learning
approaches for prediction, like ANN, CNN, LSTM, etc.
And additional accuracy of the result

170
is obtained [9]. It has also been studied that a new kind of of LSTM using series, which include different positions of
LSTM is used, known as Long Short-Term Memory. It gates to predict the data and also used to predict the real-
divides the data into sets of layers, after which starts time data. Therefore, this research work is carried out to
prediction based on some previous data [15]. The study uses improve the accuracy of the stock price.
three types
TABLE I. COMPARISON SHEET OF THE PREVIOUS WORKS AND OUR WORK
Reference Data Source Numerical Data Prediction Techniques Evaluation Metrics
[4] (1997) NYSE Price Template Matching Average Profits
[5] (2013) Yahoo Finance Price, MA, Volume ESN RNN Error Rate
[6] (2014) 1700+ individual Price, 10 financial ratios Random Forest, SVM, NB, Logistic Regression Precision, Recall, F-
stocks score
[7] (2016) Yahoo Finance Stock price data KGEB-CNN Accuracy
[8] (2017) Yahoo Finance Technical data Combines LSTM with CNN Accuracy
[9] (2019) Yahoo Finance OHLCV RNN, LSTM, GRU Log Loss, Accuracy
[10] Tokyo Stock Stock price data SSPM, BiLSTM, CRF Accuracy
(2019) Price Index
[11] Yahoo Finance Stock price data KDTCN, short for Knowledge Driven Temporal Accuracy
(2019) Convolutional Network
[12] Yahoo Finance Stock price data EMD-15TM, an enhanced LSTM with an attention layer RMSE, MAE, R2
(2019)
[13] F1NET News Stock price data and technical LSTM Accuracy
(2020) indicators
[14](2021) NIFTY Daily high-recurrence ARIMA, Facebook's Prophet Algorithm, Support Vector RMSE
exchange Regressor, Long Short-Term Memory, and Gated MAE
Recurrent Unit R2

A. Problems Faced C. Memory: 8GB RAM and 512 ROM


The issue that stock price prediction attempts to address
is the difficulty of correctly predicting future stock prices. D. Display Refresh Rate: 165Hz/60Hz
It is significant because stock prices are a crucial gauge of
corporate success and the general state of the financial
markets. Accurate forecasts may aid investors in building
trading strategies, managing risk, and making educated
decisions about buying and selling stocks.
The volatile and unpredictable nature of the stock
market makes stock price prediction difficult. A wide range
of variables, such as the state of the economy, company-
specific information, and investor mood may impact stock
prices. For investors, correctly forecasting future stock
prices can be essential since it can help them spot
profitable investment opportunities and prevent losses.
Additionally, financial organizations and regulators in
charge of keeping an eye on and supervising the financial
markets value accurate stock price forecasts. Accurate
forecasts can assist organizations in identifying possible
threats and taking the required actions to stop or lessen
financial crises. For investors, financial institutions, and
regulators who depend on the operation of the financial
markets, accurate stock price forecast is crucial. This
research process increases knowledge of financial markets
and enhances our ability to make well-informed investing
and risk management decisions by creating better
prediction models and methods.
III. PROPOSED METHODOLOGY
Fig 1: Block Diagram of the Proposed Mythology
The Fig.1 diagram represents the flow chart of the work
carried out in the paper, with three sections. B. Software Required
A. Hardware Required Anaconda: Anaconda is an open-source, free
The hardware involved in the work is highlighted in alternative to Python and R for scientific computing. (Data
detail. science, machine learning applications, big data
processing, predictive analytics, etc.), in order to simplify
A. Processor: AMD Ryzen 5 / Inter Core i5 package management and deployment. With Anaconda, it
B. GPU: Radeon Vega Mobile Gfx 2.10 GHz / is able to install and use packages like NumPy, SciPy, and
NVIDIA GeForce RTX 3 050 matplotlib.

171
Also included is Conda, a package, dependency, and C. Algorithms
environment manager.
Random Forest: Both classification and regression
Jupyter Notebook: Our ability to generate and share applications use a machine-learning technique called
major documents containing live code, mathematics, Random Forest. A number of decision trees are created
images, and text is made possible by the open-source using an ensemble technique, and their projections are
online application Jupyter Notebook.as seen in Fig. 2. It is combined to provide a final forecast. A sample of the
a highly fundamental and conceptual tool that is commonly dataset's features is randomly selected for each decision
used for data analysis, machine learning, and research. The tree, and these characteristics are then utilized to segment
stock price prediction model was constructed after dealing the data into increasingly smaller groups. Up until each
with the data preparation process. The prediction model group has This process is done recursively until either one
was result is obtained or a maximum depth is achieved.
created by combining many machines learning Random Forest has the benefit of lowering overfitting
methods, including and the dataset was used to evaluate since it includes many nodes and sub-nodes, which train with
their effectiveness. Long Short-Term Memory (LSTM) and different features and samples. This also strengthens its
Random Forest were the two algorithms employed. tolerance to noisy or irrelevant dataset components. Since
Random Forest can manage both category and numerical
features, it is suitable for datasets with high dimensionality
and missing values.The fewest samples necessary to divide
each node, the maximum depth of any tree that may go,
and how many trees there are in the forest, as well as other
hyperparameters, may all be changed to enhance the
performance of Random Forest, as shown in Fig. 5. Which
involves comparing several combinations of
hyperparameters on a validation set and selecting the best
combination based on a chosen evaluation measure. The
random forest's operation is shown in Fig. 4. Combinations
of hyperparameters on a validation set and determining the
Fig.2. Interface of Jupyter Notebook. optimal combination based on a selected evaluation
measure may be used to adjust the hyperparameters
explained in Fig. 4 and 5.
Random Forest may be used for various tasks,
including stock price prediction. Random Forest may be
trained to predict future stock prices Using historical data
and other relevant components, such as financial
indicators, news articles, and social media data. Analyzing
the Random Forest can help identify the most important
factors for stock price predictions.
Fig 1: Block Diagram of the Proposed Mythology

D. Long Short-Term Memory (LSTM)


The recurrent neural network (RNN) called Long Short-
Term Memory (LSTM), also known as a recurrent neural
network, is often used for sequential data processing, such
as time series forecasting. LSTM addresses the vanishing
gradient problem, which occurs when the gradient signal
decays exponentially with time, making learning long-term
relationships difficult. The LSTM model's logic gates are
seen in Fig. 6.
The three types of gates regulating the information flow Fig 4: Data Set Operation in Random
in LSTM networks are the input, output, and forget gates. Forest
The input gate regulates the amount of fresh data stored in a
memory cell. Forgetting the gate controls the amount of data
removed from the memory cell, and the output gate
regulates the amount of data read from the memory cell.
Time series data may be utilized with LSTM by
conceptualizing the problem as a supervised learning task in
which the input sequence of historical data is used to
anticipate the output sequence of future values. The input
series may be seen as a sliding window of fixed length, with

Fig 5: Root Node HIPO Structure

172
It is for creating static, animated and
Matplotlib
interactive visualizations.
Seaborn It is used for making statistical graphics.
It is a new library for retrieving data
yfinance
from the web
It is for implementing machine learning
Sklearn
models and statistical modeling.
Creating Deep Models & it is also used
Keras
for training of deep learning models.
TensorFlow Used for deep learning applications.
Fig 6: LSTM Logic Gate
LSTM may be trained to characterize the temporal IV. RESULT AND DISCUSSION
dynamics of the data to capture both short- and long-term
A. Visualization
relationships between the input and output sequences. Due
to its ability to handle variable-length input sequences and The result of applying machine learning techniques to
missing values, LSTM is suitable for time series data with predict stock prices is highly dependent on the quality and
varying sampling rates or noisy observations. availability of the data used for training and testing the
models, as shown in Fig 7 to Fig. 10. Historical stock price
E. Structure of LSTM
data, relevant financial indicators, and market sentiment data
Four neural networks, often known as cells, and distinct can be used as input features for the models. The more
memory-building elements make up the chain structure of comprehensive and relevant the input data, the better the
the LSTM. Cells and gates both play a role in memory chances of obtaining accurate predictions.
modification and information retention. There are three
In discussing the results, it is essential to highlight the
gates of the LSTM chain structure.
limitations of stock price prediction using machine learning.
Forget Gate: The forget gate deletes data no longer Numerous factors, including economic indicators,
required for the cell state. The gate's two inputs come before geopolitical events, news, and investor sentiment, influence
the bias is applied: x-t, the input at this moment, and h_t-1, financial markets. These factors are difficult to capture
the output from the cell before it, using weight matrices to accurately in a model, and unexpected events can
multiply. The result is obtained as the binary output of the significantly impact stock prices, rendering the predictions
activation function. If the output of a cell state is 1, less reliable.
information is saved for future use; If it is zero, the data is
Additionally, past performance may not always indicate
gone.
future results, as market conditions and investor behavior
Input gate: The input gate updates the cell state with can change over time. Therefore, it is crucial to interpret the
pertinent data. Beginning with the forget gate, the function predictions as probabilities and not as definitive outcomes.
filters the values that need to be remembered and manages
B. Prediction Console of Web Application
the information using the inputs h_t-1 and x_t. Then a vector
with all potential values is created using the tanh function. The Streamlit module of Python, which helps create
Between h_t-1 and x_t, having a -1 to +1 output range. rapid programs and is suitable for database connectivity, is
Finally, a multiplication of the vector's values and the used to develop the web shown in Fig 11 and Fig. 12. It
controlled values is required to obtain the relevant allows you to choose the stock name and interval for the
information. forecast, displaying the Evaluation of the predictive models
can be performed using various metrics such as mean
Output gate: The output gate must obtain valuable
squared error (MSE), root mean squared error (RMSE),
information. Out from the condition of the cell as it is right
mean absolute error (MAE), and accuracy. These metrics
now. The tanh function is first used on the cell to build a
quantify the performance of the models in terms of the
vector. The data is then filtered by the values to be
deviation between the predicted and actual prices. Fig. 13
remembered using the inputs h_t-1 and x_t. the information
compares the accuracy parameters like RMSE, MSE, MAE
is controlled using the sigmoid function. Finally, the vector's
and R2.
values and the values under control are multiplied and
provided. as input and output to the following cell. V. CONCLUSION
F. Libraries used This paper deals with Stock Price Prediction using the
Throughout the predictive model, several libraries were LSTM and Random Forest techniques, and a web app
necessary and installed the following packages. Each library designed for further analysis. It includes exploring the
or package have its own work. different machine learning and Deep Learning approaches
that solve the stock price prediction problem. In this, the
TABLE II. LIBRARIES AND ITS APPLICATION data collection process and the methods used to analyze the
data are and make predictions. Also explained the logic
Name Application behind these methods and discussed their strengths and
Perform wide variety of mathematical limitations.
Numpy
operations on array.
Pandas It is a Python library for data analysis. The results show that both random forest and LSTM can
predict stock prices reasonably, with LSTM performing
slightly better than random forest. Through LSTM, R2
=0.99, MSE=0.029, RMSE= 0.49 has been calculated. The

173
work suggests that deep learning methods such as LSTM
can be a

174
promising approach for stock price prediction, especially
when dealing with complex and noisy data.

Fig 11: Web App (P1)


Fig 7: Closing Vs MA100(Mean Average Of
100)

Fig 12: Web App (P2)


Fig 8: Closing Vs MA100 & MA200ti

Fig 9: Original Price Vs Predicted Price


(a)

Fig 10: Train & Valid Price Vs Predicted Price

(b)

175
[6] Li, X., Xie, H., Chen, L., Wang, J.,& Deng, X. (2014). News impact
on stock price return via sentiment analysis. Knowledge-Based
Systems, 69, 14–23
[7] Ding, Xiao, et al. "Knowledge-driven event embedding for stock
prediction." Proceedings of Coling 2016, the 26th International
Conference on computational linguistics: Technical papers. 2016
[8] Vargas, Manuel R., Beatriz SLP De Lima, and Alexandre G.
Evsukoff. "Deep learning for stock market prediction from financial
news articles." 2017 IEEE international conference on computational
intelligence and virtual environments for measurement systems and
applications (CIVEMSA). IEEE, 2017.
[9] Eapen, J., Bein, D., & Verma, A. (2019, January 7-9). Novel deep
learning model with CNN and bi-directional LSTM for improved
stock market index prediction. 2019 IEEE 9th Annual Computing and
(c) Communication Workshop and Conference (CCWC) IEEE, 0264–
0270.
[10] Long, J., Chen, Z., He, W., Wu, T., & Ren, J. (2020). An integrated
framework of deep learning and knowledge graph for prediction of
stock price trend: An application in Chinese stock exchange
market. Applied Soft Computing, 91, 106205.
[11] Deng, Shangkun, et al. "A gradient boosting decision tree approach
for insider trading identification: An empirical model evaluation of
China stock market." Applied Soft Computing 83 (2019): 105652.
[12] Jin, Zhigang, Yang Yang, and Yuhong Liu. "Stock closing price
prediction based on sentiment analysis and LSTM." Neural
Computing and Applications 32 (2020): 9713-9729.
[13] Li, Xiaodong, Pangjing Wu, and Wenpeng Wang. "Incorporating
stock prices and news sentiments for stock market prediction: A case
(d) of Hong Kong." Information Processing & Management 57.5 (2020):
102212.
Fig 13: Graphical Comparison of Two Models for (a)MSE, [14] Bhaskar Mondal, Om Patra, Ashutosh Satapathy, Soumya Ranjan
(b)MAE, (c)RMSE (d)R2 Behera. "A Comparative Study on Financial Market Forecasting
Using AI: A Case Study on NIFTY. " Springer, Singapore (2021) :vol
1286.
[15] Bhaskar Mondal,Asimkiran Dandapat."Machine learning and deep
REFERENCES learning based stock market prediction considering Covid-19 as a
feature".IEEE (2023).
[1] Hiransha, M., et al. "NSE stock market prediction using deep-learning [16] Jena, S.P., Chakravarty, S., Sahoo, S.P., Nayak, S., Pradhan, S.K. and
models." Procedia computer science 132 (2018): 1351-1362. Paikaray, B.K. 'Automatic leaf diseases detection and classification of
[2] Hota, Jagruti, Sujata Chakravarty, Bijay K. Paikaray, and cucumber leaves using internet of things and machine learning
Harshvardhan Bhoyar. (2022) "Stock Market Prediction Using models', Int. J. Web and Grid Services, Vol. 19, No. 3, pp.350–388,
Machine Learning Techniques." ceur-ws.org, Vol-3283, Pp. 86. (2023).
[3] Dai, Z. F., Dong, X. D., Kang, J., & Hong, L. (2020b). Forecasting [17] Mohapatra, S., Satpathy, S., & Paikaray, B. K. A machine learning
stock market returns: New Technical indicators and two-step approach to assist prediction of Alzheimer's disease with
economic constraint method. The North American Journal of convolutional neural network. International Journal of Bioinformatics
Economics and Finance, 53, 101216. Research and Applications, 19(2), 141-150, (2023).
[4] Hochreiter, S., & Schmidhuber, J. (1997). Long short-term [18] Jena, S. P., Paikaray, B. K., Pramanik, J., Thapa, R., & Samal, A. K.
memory. Neural Computation, 9(8), 1735–1780. Classifications on wine informatics using PCA, LDA, and supervised
[5] Mikolov, T., Chen, K., Corrado, G., & Dean, J. (2013). Efficient machine learning techniques. International Journal of Work
estimation of word representations in vector space. arXiv preprint Innovation, 4(1), 58-73, (2023).
arXiv:1301.3781

174
Authorized licensed use limited to: NATIONAL INSTITUTE OF TECHNOLOGY ROURKELA. Downloaded on December 12,2023 at 03:55:38 UTC from IEEE Xplore.
Restrictions apply.
View publication stats

You might also like