0% found this document useful (0 votes)
2 views

Prediction_in_Stock_Price_Using_of_Python_and_Machine_Learning

The document discusses a study presented at the 2021 ICRITO conference, focusing on stock price prediction using Machine Learning techniques, specifically LSTM and Python. It highlights the challenges in forecasting stock prices due to various influencing factors and proposes a systematic approach to improve prediction accuracy. The study emphasizes the importance of data preprocessing and model training to achieve reliable stock price forecasts.

Uploaded by

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

Prediction_in_Stock_Price_Using_of_Python_and_Machine_Learning

The document discusses a study presented at the 2021 ICRITO conference, focusing on stock price prediction using Machine Learning techniques, specifically LSTM and Python. It highlights the challenges in forecasting stock prices due to various influencing factors and proposes a systematic approach to improve prediction accuracy. The study emphasizes the importance of data preprocessing and model training to achieve reliable stock price forecasts.

Uploaded by

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

2021 9th International Conference on Reliability, Infocom Technologies and Optimization (Trends and Future Directions) (ICRITO)

Amity University, Noida, India. Sep 3-4, 2021

Prediction in Stock Price Using of Python and


2021 9th International Conference on Reliability, Infocom Technologies and Optimization (Trends and Future Directions) (ICRITO) | 978-1-6654-1703-7/21/$31.00 ©2021 IEEE | DOI: 10.1109/ICRITO51393.2021.9596513

Machine Learning
Anchal Vij 1 , Komal Saxena2 Ajay Rana3
AIIT, Amity University Uttar Pradesh, Noida, India
[email protected], [email protected], [email protected]

Abstract-In the finance industry, the stock price prediction speculation that if the marketplace is an effective market,
is one of the greatest notable implementations. Price forecast is at that point the stock cost will trail an arbitrary work design.
a demonstration of trying to ascertain the future estimation of Furthermore, a fixed expectation system is likewise
stock. This paper clarifies the forecast of a stock closing price unrealistic if the market is effective on the base of that
utilizing Machine Learning. The dedicated and analytic or the financial specialists will before long find such methodologies
time arrangement inspection is utilized by most of the and those fruitful estimating rules will prompt fall to pieces
stockbrokers to creating the stock price forecasting. The [7].
programming language is utilized to foresee the stock price
prediction utilizing machine learning is Python. Machine II. LITERATURE REVIEW
learning itself utilizes various techniques to make estimation
simpler and genuine. In this report, we recommend a Machine Stock price prediction is quite possibly the main subjects
Learning (ML) approach that is destined to be prepared from to be explored in scholarly and monetary investigates. In any
the accessible stock's information and gain insight and case, a method utilizing machine learning techniques will
afterward utilizes this gained information for a precise forecast give a more exact, precise and simpler approach to settle such
of the stock values. In this set, this investigation utilizes a ML issues identified with stock prices and market costs.
procedure called LSTM to envisage stock values. The objective
of the model is to forecast the stock prices and finding out the
To make a perdition of stock price, several methods and
instabilities in the stock value based on the last sixty days techniques are being employed. The type of technique
closing prices of the stock. usually depends on the user and doesn’t much affects the
prediction. The most used technique as observed was SVM
Keywords: Finance, Stock price, Prediction, LSTM, Machine model. The use of SVM is all-inclusive as it joins pre-
learning., Python preparing of the monetary stock info set, use of different
element designing methods, joined with a redid profound
I. INTRODUCTION deep learning-based framework for stock value pattern
Stock markets are one of the vital parts of the economy forecast. Conducting far-reaching assessments regularly
of a nation. As a matter of fact, it's the chief route for applying machine learning techniques and concluding the
establishments to raise money. The financial specialists as stock prices. The technique accomplishes in general high
and the common citizens are likewise discovering it as a exactness for stock price pattern. With the itemized plan and
venture apparatus. As the securities exchange impacts assessment of forecast term lengths, highlight designing, and
individual and public economy vigorously, foreseeing the information pre-processing strategies, this work adds to the
future predictions of the financial exchange is an essential stock examination network mutually in the monetary and
undertaking while at the same time making the right choice specialized fields [2-3].
whether to purchase or sell the offer. Be that as it may, it was Stock price prediction is of great value to financial
make an effort to predict the stock value patterns proficiently specialists; nonetheless, the stock price is driven by
on the grounds that numerous elements, for example, unpredictable factors, for example, microblogs and news that
financial aspects, governmental issues, climate and so on make it challenging to anticipate prices on merely the
were choosing boundaries [6]. verifiable information. The gigantic instability underlines the
Financial time arrangement changes vigorously and need to viably access the work of outside variables in the
specifically. Such time arrangement is clearly hard to stock forecast. Securities exchanges can be anticipated
anticipate for the reason that the issue is nonlinear, non- utilizing AI calculations on data confined in online
fixed and has a lot of noise [4]. Stock cost is a sort of time broadcasting and monetary news, as this information can
arrangement in the economic area. The way to foresee stock transformation speculators' conduct. In the mentioned
pattern, later on, has gotten quite possibly the most import method, the calculations are made via online media and
issues by utilizing information on the basis of mining monetary news information to find the effect of this
methods. Notwithstanding, the forecast is troublesome from information on securities exchange expectation precision for
the standard of the productive market ten resulting days. For refining execution and nature of
forecasts, highlight choice and spam tweets decrease is

978-1-6654-1703-7/21/$31.00 ©2021 IEEE 1


Authorized licensed use limited to: Chaitanya Bharathi Institute of Tech - HYDERABAD. Downloaded on April 17,2025 at 05:55:48 UTC from IEEE Xplore. Restrictions apply.
performed on the informational collections. Additionally, III. THE PROPOSED SYSTEM
performing analyses to discover such securities exchanges
that are hard to anticipate and which are more affected by
web-based media and monetary news. We contrast the
aftereffects of various calculations to locate a reliable
classifier. At long last, for accomplishing greatest
prediction exactness, deep learning is utilized and a few
classifiers are ensembled [4].
Another technique is the use ANN and Rf Methods
which we have been applied for foreseeing the following
day shutting down figures of stock.
The related and existing work in this area use traditional
procedures like linear regression, RWT, MACD and also
using some linear models like ARMA, ARIMA, for
predicting stock prices [5].
The expanding interest for a precise forecast model
brought about broad exploration commitment in models.
Therefore, there are different measurable and intelligent
strategies existing in writing which are broadly utilized for
the prediction that incorporates Fuzzy Logic, ARMA, Fig. 1. Proposed system
GARCH, ANN. In the following strategies, ANN is the
most fit strategy and discovered to be more proficient in A. Data set Collected: -
dealing with nonlinearity; then again, the conventional
ARMA and GARCH procedures do not have this ability 1) First we need to import all the libraries which are
and consequently can't yield huge forecasting exactness in essential for the training of the model. Collect the stock
a boisterous climate. As a widespread inexact ANN has statement for the organization 'Alphabet Inc.' utilizing the
been adopted effectively in different examination zones organizations ticker (GOOGL) from 1st January 2012 to
like value of stock will be determining, cash conversion May 10th, 2021 from X Finance-Yahoo.
scale gauging, power value anticipating and wind speed (url: https//in.finance.yahoo.com/quote/GOOGL?p=GOO GLE
estimating, and so on. Further hybrid prediction procedures &.tsrc=fin-srch).
have been created by analysts with various mixes by using The Dataset is comprised of total is 2261 rows * 6
the speculation capacity of ANN that incorporates ANN- columns.
ANFIS, ARIMA based GARCH-ANN based ANN and has
been applied for NSE Market of stock value determining, a) Trained and Split the Data: - Make another
wind speed anticipating, gold value estimating, and so on. information outline with just the end cost and convert it to
The FNN is notable in the current writing that has broad an array. At this point, we state a variable to accumulation
applications in various fields. Quite possibly the most the measurement of the training informational data. We
famous neural - network called SLFN has extensive need the preparation informational collection to contain an
applications in relapse and characterization and utilizes amount of the information. Make a training informational
notable training calculations like backpropagation (BP) and data collection that encompasses the previous sixty-day
RLS for tuning its boundaries. The issue lies with the BP closing value that we need to use to anticipate the sixty-
calculation where it could be caught in local minima and one -day closing value of the stock. So, the principal
may knowledge the ill effects of moderate combination. In
segment in the 'x/_train' informational collection will
correlation, the RLS calculation is quicker than BP yet
encompass values from the informational collection from
includes more computational multifaceted nature. In these
calculations, the obscure boundaries are tuned iteratively in index (0-59) (sixty values complete) and the subsequent
the learning cycle [13][14][15]. These relevant articles have section will comprise values from the informational from
discussed about different Models in different Research index 1 to index (sixty values) and more of the same. The
Papers Arch Model [16]in this GARCH [17-18] 'y/_train' informational collection will contain the sixty-
autoregressive Conditional. ARMA Model (Moving first value situated at index sixty for its the main section
Average Model [19,20] Arima Model [21] VAM Model and the sixty-second value situated at index 61 of the
[22]in this they used ANN Model [23]. informational collection for its subsequent value and it goes
along in the same manner.
b) Convert the Autonomous Data & Prepare the
LSTM Model :- Then we convert the autonomous train
informational collection 'x_train' and subordinate
informational index 'y_train' to numpy clusters so they can

x_train, y_train = np.array(x_train), np.arr

2
Authorized licensed use limited to: Chaitanya Bharathi Institute of Tech - HYDERABAD. Downloaded on April 17,2025 at 05:55:48 UTC from IEEE Xplore. Restrictions apply.
be utilized for preparing the LSTM model. Restructure the C. Predication of the Model to Provide the estimated Cost
information to be three dimensional have taken in the We need to test the model some more and get the
structure [No. of tests, No. of time steps, and number of expected shutting esteem assessment of Alphabet Inc. for
May 10, 20201(10/05/2021). Thus, we should get the
features]. The LSTM model is expecting a three-
assertion, alter the data to a cluster that comprises only the
dimensional informational set. x_train = np.reshape end cost. Now, we will get the latest sixty-day shutting
(x_train, (x_train.shape[0],x_train.shape[1],1))Accumulat esteems and scale the information to be assessed some place
e the LSTM model to have 2-LSTM layers with Fifty in the scope of 0 and 1 comprehensive. From here on out,
neurons and 2 Dense layers, one with Twenty -five neurons we will make an unfilled rundown and add the past sixty-
and the other with one neuron. Organize the model day esteems to it, and subsequently alter it to a NumPy
exploiting the mean squared error (MSE) Adam optimizer. exhibit and rebuild it so we can incorporate the figures into
the model. To wrap things up, we will enter the information
and the loss function
into the model and get the anticipated price.
c) Train the Model Utilizing Training Informational Fig. 5. Shows the real stock price
Sets. Batch size is indisputably the quantity of prepared
models present in a solitary gathering and epoch is the
quantity of redundancies when an entire enlightening set is
passed forward and in invert through the neural
association.
The dataset collected shown below in fig.6

Fig. 2. Showing the loss of data in training.

IV. RESULTS AND DISCUSSIONS


A. LSTM Model should be trained and tested

Testing LSTM Mode Set: Make a test informational


set. At this point modification the free test informational
set 'x_test' to a numpy cluster thus it tends to be utilized for
testing the LSTM model. Restructure the information to be
three dimensional in the structure [No. of tests, No. of time
steps, and No of features]. This should be done on the Fig. 6. The dataset collected.
grounds that the LSTM model is expecting a 3-dimensional
informational collection. Now get the anticipated figures
from the model utilizing the test information.
B. RMSE Calculated to extract the Model
Calculate (RMSE) which means, that is a decent degree
of how Perfect the model is. An estimation of would
demonstrate that this type of models anticipated prices
coordinate the real prices from the test informational set
correctly. It reduced the figure the improved the model will
be performing. Be that as it may, as a rule, it is ideal to
utilize different measurements also to really get the
knowledge of how well the model is performing. Fig. 7. Graph showing the information collected.

The formula applied is root mean square error which is


equal to the square root of the trained values into the
predictions subtracted by the y dependent data multiplied
by two.

Fig. 3. Shows the value calculated of root mean square error.

Predicted price is calculated by using the scaler inverse Fig. 8. Training Dataset in form of array.
values.

Fig. 4. Shows the value projected by the model.

3
Authorized licensed use limited to: Chaitanya Bharathi Institute of Tech - HYDERABAD. Downloaded on April 17,2025 at 05:55:48 UTC from IEEE Xplore. Restrictions apply.
[8] Jaeheon Chun, Jaejoon Ahn, Youngmin Kim & Sukjun Lee (2020)
Using Deep Learning to Develop a Stock Price Prediction Model
Based on Individual Investor Emotions, Journal ofBehavioral
Finance, DOI: 10.1080/154275sixty.2020.1821686.
[9] Sharma.N and Juneja A. "Combining of random forest estimates
using LSboost for stock market index prediction," 2017 2nd
International Conference for Convergence in Technology (I2CT),
Mumbai, 2017, pp. 1199-1202, doi: 10.1109/I2CT.2017.8226316.
[10] Wang. Zhaoxia, Seng-Beng Ho, Zhiping Lin, "Stock Market
Prediction Analysis by Incorporating Social and News Opinion and
Sentiment", Data Mining Workshops (ICDMW) 2018 IEEE
International Conference on, pp. 1375-1380, 2018.
[11] Engle. R. F “Autoregressive conditional heteroscedasticity with
Fig. 9. The actual data as compared to the values predicted by the estimates of the variance of United Kingdom inflation,”
model. Econometrical, vol. 50, no. 4, pp. 987–1008, 1982.
[12] Bollerslev.T “Generalized autoregressive conditional
heteroskedasticity,” Journal of Econometrics, vol. 31, no. 3, pp.
307–327, 1986.
[13] Girish G. P, “Spot electricity price forecasting in Indian electricity
market using autoregressive-GARCH models”, Energy Strategy
Reviews, vol. 11-12, pp. 52–57, 2016.
[14] P. Burlando, R. Rosso, L. G. Cadavid, and J. D. Salas, “Forecasting
of short-term rainfall using ARMA models,” Journal of Hydrology,
vol. 144, no. 1-4, pp. 193– 211, 1993.
[15] Contreras.J, Espínola. R, Nogales.V, Conejo. A.J, “ARIMA models
to predict next-day electricity prices”, IEEE Transactions on
Power Systems, vol. 18, no. 3, pp. 1014–1020, 2003.
[16] Geurts. M, G. E. P. Box,G. M. Jenkins, “Book review: time series
analysis: forecasting and control”, Journal of Marketing Research,
vol. 14, no. 2, p. 269, 1977.
[17] P.F. Pai, Lin C.S, “A hybrid ARIMA and support vector machines
model in stock price forecasting”, Omega, vol. 33, no. 6, pp.
497–505, 2005.
[18] Wang. J.Z. Wang J. J, Z Zhang G, Guo S.P. “Forecasting stock
Fig. 10. Shows all the valid predicted prices. indices with back propagation neural network”, Expert Systems with
Applications, vol. 8, no. 11, pp. 14346–14355, 2011.
V. CONCLUSION [19] C.T Lin. Yeh H.Y, “Empirical of the Taiwan stock index option price
forecasting model - applied artificial neural network”, Applied
We have used LSTM method to Prepare the model and Economics, vol. 41, no. 15, pp. 1965–1972, 2009.
forecast the stock value for google Inc in this research [20] K.j, Kim, I. Han, “Genetic algorithms approach to feature
article. The proposed model produces the highest level of discretization in artificial neural networks for the prediction of stock
price index”, Expert Systems with Applications, vol. 19, no. 2, pp.
performance with relation to the root Least squared error. 125–132, 2000.
To verify the effectiveness of the model we have used more
[21] S. Manu, Y, D Chen, Sohn, K. Shimada, K. Hirasawa, “Stock price
than thousand Alphabet stock. prediction using neural networks with RasID- GA,” IEEJ Transactions
on Electrical and Electronic Engineering”, vol. 4, no. 3, pp. 392–403,
REFERENCES 2009.
[1] Kranthi.V Stock Market Prediction Using Machine Learning. [22] H. Ince and T. B. Trafalis, “Short term forecasting with support
10.13140/RG.2.2.12300.77448. (2018). vector machines and application to stock price prediction”,
[2] Chouhan, Lokesh & Agarwal, Navanshu & Parmar, Ishita & International Journal of General Systems, vol. 37, no. 6, pp. 677–687,
Saxena, Sheirsh & Arora, Ridam & Gupta, Shikhin & Dhiman, 2008.
Himanshu. Stock Market Prediction Using Machine Learning. [23] Sai Y, Zhang F. T, Zhang T. “Research of Chinese stock index
10.1109/ICSCCC.2018.8703332. (2018). futures regression prediction based on support vector machines”,
[3] Shen.J. Shafiq, M.O. Short-term stock market price trend prediction Chinese Journal of Management Science, vol. 3, pp. 35–39, 2013.
using a comprehensive deep learning system. J Big Data 7, 66 [24] Liu.Y “Novel volatility forecasting using deep learning-long short-
(2020). https://doi.org/10.1186/s40537-020-00333-6. term memory recurrent neural networks”, Expert Systems with
[4] Khan, W., Ghazanfar, M.A., Azam, M.A. et al. “Stock market Applications, vol. 132, pp. 99–109, 2019.
prediction using machine learning classifiers and social media, [25] Y. Baek & H. Y. Kim, Mod Aug Net: “A new forecasting framework
news. J Ambient Intell Human Compute”. (2020). for stock market index value with an overfitting prevention LSTM
https://doi.org/10.1007/s12652-020- 01839-w. module and a prediction LSTM module”, Expert Systems with
[5] Vijh .M, Chandola. D, Tikkiwal V.Anand, Kumar. A, Stock Closing Applications, vol. 113, pp. 457–480, 2018.
Price Prediction using Machine Learning Techniques, Procedia
Computer Science, Volume 167, 2020, Pages 599-sixty6, ISSN
1877-0509, https://doi.org/10.1016/j.procs.2020.03.326.
[6] Billah M., Waheed S. & Hanifa A. "Stock market prediction using
an improved training algorithm of neural network," 2016 2nd
International Conference on Electrical, Computer &
Telecommunication Engineering (ICECTE), Rajshahi, 2016, pp. 1-
4, doi: 10.1109/ICECTE.2016.7879611.
[7] Zhao. L. & L. Wang, "Price Trend Prediction of Stock Market
Using Outlier Data Mining Algorithm," 2015 IEEE Fifth
International Conference on Big Data and Cloud Computing,
Dalian, 2015, pp. 93-98, doi: 10.1109/BDCloud.2015.19.

4
Authorized licensed use limited to: Chaitanya Bharathi Institute of Tech - HYDERABAD. Downloaded on April 17,2025 at 05:55:48 UTC from IEEE Xplore. Restrictions apply.

You might also like