100% found this document useful (1 vote)
133 views

Stock Closing Price Prediction Using Machine Learning SVM Model

Stock market prediction is one of the most important things in financial world as it decides the flow of a company towards profit or loss in future. Prediction of a stock value of a particular entity or a company is a tough and difficult thing to do. Since early 1980 s investing money into the companies by taking some of its stock had become a big thing (trend). After 2000 s some Machine Learning, Artificial Intelligence concepts were introduced to make prediction a stock value.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
133 views

Stock Closing Price Prediction Using Machine Learning SVM Model

Stock market prediction is one of the most important things in financial world as it decides the flow of a company towards profit or loss in future. Prediction of a stock value of a particular entity or a company is a tough and difficult thing to do. Since early 1980 s investing money into the companies by taking some of its stock had become a big thing (trend). After 2000 s some Machine Learning, Artificial Intelligence concepts were introduced to make prediction a stock value.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

8 XI November 2020

https://doi.org/10.22214/ijraset.2020.32154
International Journal for Research in Applied Science & Engineering Technology (IJRASET)
ISSN: 2321-9653; IC Value: 45.98; SJ Impact Factor: 7.429
Volume 8 Issue XI Nov 2020- Available at www.ijraset.com

Stock Closing Price Prediction using Machine


Learning SVM Model
Desai Mitesh Madhusudan
U.G. Student, Department of Information Technology, B. K. Birla college of Arts, Science and Commerce (Autonomous), Kalyan
421 306 , Maharashtra, India

Abstract: Stock market prediction is one of the most important things in financial world as it decides the flow of a company
towards profit or loss in future. Prediction of a stock value of a particular entity or a company is a tough and difficult thing to
do. Since early 1980 s investing money into the companies by taking some of its stock had become a big thing (trend). After 2000
s some Machine Learning, Artificial Intelligence concepts were introduced to make prediction a stock value. There are many
Machine learning models such as Support Vector Machine (SVM) model, Regression model, LSTM model, Artificial Neural
Network (ANN) etc. had used to make predictions by considering previous year data as sample. By far SVM model has shown
most positive results by predicting stock value accurately. Since all this models were tested on little quantity of particular data set,
if we take large amount of data (previous) as input then it will bring more accuracy in prediction. Also by considering Financial
NEWS articles, Social Media trends, Company’s work ethics and taking all this variables as input along with the previous year
data will make it easy for models to predict the value more accurately. SVM-based stock market trend prediction system can find
out a good subset and evaluate stock indicators which provide useful information for investors and produces better
generalization performance over the conventional methods in terms of the hit ratio. In this paper, I proposed how accurately a
SVM model can check the stock closing price of a Tesla Inc. which is a Tech company and Reliance Industries Limited which is
a public company. A SVM Kernel models were trained and tested by using past 1 year (i.e. from Nov 2019 to Nov 2020) stock
data of both the companies.
Keywords: Stock market prediction, Support Vector Machine, Kernel regression, Tesla Inc. (TSLA), Reliance (RELIANCE
LIMITED NSI)

I. INTRODUCTION
The behavior of financial market is a complex, evolutionary, non-linear and dynamical system. Data intensity, non-stationary, noise,
unstructured nature, high chances of uncertainty and hidden relationships are the characteristics of financial forecasting field.
Factors like political events, general economic condition, traders’ expectations affect finance market industry. Therefore, predicting
market valuation is quite difficult. According academic investigation and research, movements in stock prices are not random. They
work in highly non-linear dynamic manner. So any random assumption of future stock prices may be a noisy non-linear process
[16].
The focus of each research project mostly varies in three parts 1. To predict the price change can be near term (i.e. less than min),
short term (i.e. tomorrow or later) and long term (i.e. months later) 2. The predictor can use global news, trend (economic),
particular characteristic of a company, time series analysis of the stock price. 3. The set of stock of particular industry [4].
The target of stock market prediction can be the future stock price or volatility of values or market trend. In prediction there are two
types such as dummy and real time prediction. In dummy, some set of rules are define and predict the future value of shares by
calculating the average. In the real time prediction with the help of Internet we saw price of share of a company.
Generally, they are used in classification problems. In 1960s, SVMs were first introduced but later they got reworked in
1990.Support Vector Machine (SVM) is very specific type of machine learning algorithm which follows capacity control of
decision function, use of kernel function and the distribution of the solution. SVM has been established to estimate a function by
minimizing an upper bound of generalization error, SVM based on a unique theory of the structural risk minimization. Since SVM
is very much resistant to the over fitting problem, it helps to achieve high generalization performance [2].
Paper is organized as follows, Section II covers a literature review or previous work done using SVM model. How a SVM Kernel
model works and its information of 3 basic kernels i.e. linear, polynomial and radial basis function models given in Section III.
Section IV presents experimental results which contains original as well as predicted graph of stock values of Tesla Inc. and
Reliance Industries Limited. Finally, Section V presents conclusions.

©IJRASET: All Rights are Reserved 379


International Journal for Research in Applied Science & Engineering Technology (IJRASET)
ISSN: 2321-9653; IC Value: 45.98; SJ Impact Factor: 7.429
Volume 8 Issue XI Nov 2020- Available at www.ijraset.com

II. RELATED WORK


In [1], Reddy V.K.S. stated that by using stocks data of various companies or entities from global financial market to predict stock
index changes positively or negatively in future by using Machine Learning (ML) or not . This paper solely focused on Support
Vector Machine (SVM). The author stated that SVM algorithm works on large scale data value which was taken from financial
market throughout the globe. SVM does not over fit. A lot of other Machine Learning (ML) models were used to predict the stock
price but SVM gives the most accurate prediction. In [2] Stock market is one of the most important thing in financial world or
industry. In this paper prediction of Karachi stock market rates by using different Machine learning techniques had done. The
methods or models that had used were Single Layer Perceptron (SLP), Multi-Layer Perceptron (MLP) , Radial Basis Function
(RBF) , Support Vector Machine (SVM) etc. . Some factors that have impact on stock rate performance are Market history, News,
General Public Mood, Commodity Price, interest rate, Foreign Exchange. These factors were applied on parameters such as Gold,
Oil, Silver rates, Social media, News and data had collected accordingly. All of the Machine learning models that had stated above
applied on two different data sets i.e. Training Data Set and Test data Set which is proposed by Mehak et al. In [3], the paper
focused on Stock prediction using LSTM and Regression model. Two different data sets were taken for testing the accuracy of
prediction by both the models. In Regression based model, firstly stock movements were captured then data was added to it and then
a machine learning algorithm is applied to it. After ML algorithm Regression based model was applied to minimize the error. In
LSTM model input had taken and LSTM algorithm was applied for remembering data and results for long run (i.e. Recurrent Neural
Networks RNN). This paper proposed by Parmar et al. In [4], this paper research on prediction of stock value of Nikkei 225 and
Nikkei 400 (Tokyo, Japan stock exchange) indexes by using Machine learning techniques had done. The Machine learning
techniques that had used to predict the stock value are Deep Neural Network (DNN), Back Propagation Neural Network (BPNN),
and Support Vector Machine Regression (SVR). Two data sets were used to test the hypothesis i.e. Training set and Test set. In
training set performance of all prediction measured by Mean Absolute Error and Mean absolute Percentage Error while in testing
phase The performance of all prediction measured by using Coefficient of Determination (R²).This paper proposed by Harahap et al.
Six new variables passed to determine decisions which predicted the next day closing price of the stock of corresponding company.
Neural network, sentimental analysis, SVM was combined into robust prediction model [8]. In [13], to check the forecasting ability
of SVM Huang et al. compared its performance with those of linear discriminant analysis, quadratic discriminant analysis and
Elman Back propagation neural networks. They also proposed a combined model by integrating SVM with other classification
methods. Author stated that SVM is superior to the other individual clarification methods in forecasting weekly movement direction
of NIKKEI 225 index. Due to combined model weakness of one model was balanced by the strengths of another by achieving a
systematic effect. A strong correlation exist between rise/fall of stock prices of a company to the public opinions or emotions about
that company expressed on Twitter through tweets [14].
The work in this paper is divided in three stages. 1) Collecting the historical data set before the target days that has to be predicted.
2) Training the system by using SVM model. 3) Select ‘x’ days in future, of which you have to you have to predict the stock closing
price. The data set is available at Yahoo finance in.csv format [21], [22]. It contains Date, Opening price, Closing price, High, Low,
Adjacent Close and Volume of a company. Thereafter, system is trained by using machine learning SVM model. To train the
system, sklearn library is imported and .csv file containing data set has been uploaded using ‘read_csv’ function. Last 25 days of
that data set are taken as future days and predicted the closing price of it.

III. METHODOLOGY
An SVM is a supervised machine learning model which used classification algorithms representation of different classes in a
hyperplane in multi-dimensional space. The hyperplane will be generated in an iterative manner by SVM to minimize the error. The
goal of SVM is to divide the datasets into classes to find Maximum Marginal Hyperplane (MMH).The important concepts in SVM
are as follows;

A. Hyperplane
Hyperplane that maximize the margin between two classes; it is a decision plane or space which is divided between set of objects
having different classes.

B. Support Vectors
Data points which are closest to the hyper plane are called as support vectors. Separating line will be defined with the help of these
points.

©IJRASET: All Rights are Reserved 380


International Journal for Research in Applied Science & Engineering Technology (IJRASET)
ISSN: 2321-9653; IC Value: 45.98; SJ Impact Factor: 7.429
Volume 8 Issue XI Nov 2020- Available at www.ijraset.com

C. Margin
The gap between two liners on the closest data points of different classes. Large and small margins are considered as good and bad
margins respectively. Margins can be calculated as the perpendicular distance from the lines to the support vectors.

D. SVM Kernels
SVM algorithm was implemented with kernel which transforms an input data into the required form. SVM and uses a technique
called the kernel trick in which kernel takes a low dimensional input and converts it into a higher dimensional space. It makes SVM
more powerful, flexible and accurate. The following are some types of kernels used by SVM which I will be using in the research,

1) Linear Kernel: It used as a dot product between any two observations. The formula of linear kernel is given below-
K(x, y) = sum (x ∗ y) …..(1)
From the above formula, we can see that the product between two vectors say x & y is the sum of the multiplication of each pair of
input values.

2) Polynomial Kernel: Polynomial kernel is reducible form of linear kernel and distinguish curved or nonlinear input space. The
formula for polynomial kernel is-
K(X, Y) = 1+ sum (X ∗ Y) ^ d…… (2)
Here‘d’ is the degree of polynomial, which will be specified manually.

3) Radial Basis Function (RBF) Kernel: RBF kernel used in SVM classification maps input space; it depends on distance between
input and some of the fixed points of a particular data.
K(x, xi) = expo (− sum (x – xi ^ 2))….. (3)
Here, γ (gamma) ranges from 0 to 1.A good default value of gamma is 0.1.
All the data (Date, Open, Close, High, Low, Adjacent Close, Volume) were present in single data set downloaded from Yahoo
finance. In total, there are 252 data point of data sets for both the companies [21], [22]. Data set were divided into training and
testing data with ratio 75:25 for training set and testing set accordingly.

IV. EXPERIMENTAL RESULTS


Historical data of Tesla Inc. and Reliance Ltd. Taken from Yahoo finance. Machine learning SVM model is used to train the data
and predict stock prices of next 25 days in future of both Tesla and Reliance companies. Fig. 1 shows the graph of original stock
value of Tesla Inc. from Nov 2019 to Nov 2020 [21]. Fig. 1a, Fig. 1b and Fig. 1c shows graph of predicted and valid stock prices of
Tesla Inc. which has been predicted using Linear, Polynomial and Radial Basis Function respectively.

Fig. 1 Tesla Inc. Original Fig. 1a Tesla Inc. Linear Kernel Prediction

Fig. 1b Tesla Inc. Polynomial Kernel Prediction Fig. 1c Tesla Inc. RBF Prediction

©IJRASET: All Rights are Reserved 381


International Journal for Research in Applied Science & Engineering Technology (IJRASET)
ISSN: 2321-9653; IC Value: 45.98; SJ Impact Factor: 7.429
Volume 8 Issue XI Nov 2020- Available at www.ijraset.com

Fig. 2 shows, original graph of stock prices of Reliance Ltd. Since Nov 2019 to Nov 2020 [22]. Fig. 2a, Fig. 2b and Fig. 2c shows
graph of predicted and valid stock prices of Reliance Industries Ltd. which has been predicted using Linear, Polynomial and Radial
Basis Function respectively.

Fig. 2 Reliance NS Original Fig. 2a Reliance NS Linear Kernel Prediction

Fig. 2b Reliance NS Polynomial Kernel Prediction Fig. 2c Reliance NS RBF Kernel Prediction

V. CONCLUSION
All the SVR kernel methods perform differently on different data points. Radial Basis Function (RBF) SVR kernel is the best
method for both Tesla Inc. and Reliance ltd. RBF predicted the stock closing prices closest comparing to the original values of same
days. Since Tesla Inc. is a Tech company most of the time its stock price depends on the decisions of on board chief, but by using
SVM regression model traders can predict stock price of the company up to a great extent. On other side, Reliance is a public
company, so its stock price may vary according to the people’s view about the company. In future, by taking people’s view into
consideration and putting it through models while training the system one can increase predictability of the model.

VI. ACKNOWLEDGENT
The author would like to acknowledge and thank to Prof. Swapna Augustine Nikale, Department of Information Technology, B. K.
Birla College (Autonomous), Kalyan for the support and guidance.

REFERENCES
[1] Reddy, V. K. (2018). Stock Market Prediction Using Machine Learning. International Research Journal of Engineering and Technology (IRJET), Vol. 5.
[2] TY - BOOK AU - Usmani Mehak AU - Adil Syed AU - Raza Kamran AU - Ali, Syed Saad PY - 2016/08/01 SP - 322 EP - 327 T1 - Stock market
prediction using machine learning techniques DOI - 10.1109/ICCOINS.2016.7783235
[3] Parmar, I., Agarwal, N., Saxena, S., Arora, R., Gupta, S., Dhiman, H., & Chouhan, L. (2018b). Stock Market Prediction Using Machine Learning. 2018 First
International Conference on Secure Cyber Computing and Communication (ICSCCC), NA. https://doi.org/10.1109/icsccc.2018.8703332
[4] Harahap, L. A., Lipikorn, R., & Kitamoto, A. (2020b). Nikkei Stock Market Price Index Prediction Using Machine Learning. Journal of Physics: Conference
Series, 1566, 012043. https://doi.org/10.1088/1742-6596/1566/1/012043
[5] Vijh, M., Chandola, D., Tikkiwal, V. A., & Kumar, A. (2020). Stock Closing Price Prediction using Machine Learning Techniques. Procedia Computer
Science, 167, 599–606. https://doi.org/10.1016/j.procs.2020.03.326
[6] KOMPELLA, S. U. B. H. A. D. R. A., & CHILUKURI, K. A. L. Y. A. N. A. C. H. A. K. R. A. V. A. R. T. H. Y. (2019). STOCK MARKET PREDICTION
USING MACHINE LEARNING METHODS. INTERNATIONAL JOURNAL OF COMPUTER ENGINEERING AND TECHNOLOGY, 10(3), NA.
https://doi.org/10.34218/ijcet.10.3.2019.003
[7] Pathak, A., & Shetty, N. P. (2018). Indian Stock Market Prediction Using Machine Learning and Sentiment Analysis. Advances in Intelligent Systems and
Computing, 711, 595–603. https://doi.org/10.1007/978-981-10-8055-5_53
[8] Moghaddam, A. H., Moghaddam, M. H., & Esfandyari, M. (2016). Stock market index prediction using artificial neural network. Journal of Economics,
Finance and Administrative Science, 21(41), 89–93. https://doi.org/10.1016/j.jefas.2016.07.002

©IJRASET: All Rights are Reserved 382


International Journal for Research in Applied Science & Engineering Technology (IJRASET)
ISSN: 2321-9653; IC Value: 45.98; SJ Impact Factor: 7.429
Volume 8 Issue XI Nov 2020- Available at www.ijraset.com

[9] M, H., E.A., G., Menon, V. K., & K.P., S. (2018). NSE Stock Market Prediction Using Deep-Learning Models. Procedia Computer Science, 132, 1351–1362.
https://doi.org/10.1016/j.procs.2018.05.050
[10] Nelson, D. M. Q., Pereira, A. C. M., & de Oliveira, R. A. (2017). Stock market’s price movement prediction with LSTM neural networks. 2017 International
Joint Conference on Neural Networks (IJCNN), 1419–1426. https://doi.org/10.1109/ijcnn.2017.7966019
[11] Abe, M., & Nakayama, H. (2018). Deep Learning for Forecasting Stock Returns in the Cross-Section. Advances in Knowledge Discovery and Data Mining,
273–284. https://doi.org/10.1007/978-3-319-93034-3_22
[12] Strader, Troy J.; Rozycki, John J.; ROOT, THOMAS H.; and Huang, Yu-Hsiang (John) (2020) "Machine Learning Stock Market Prediction Studies: Review
and Research Directions," Journal of International Technology and Information Management: Vol. 28 : Iss. 4 , Article 3. Available at:
https://scholarworks.lib.csusb.edu/jitim/vol28/iss4/3
[13] Huang, W., Nakamori, Y., & Wang, S.-Y. (2005). Forecasting stock market movement direction with support vector machine. Computers & Operations
Research, 32(10), 2513–2522. https://doi.org/10.1016/j.cor.2004.03.016
[14] Pagolu, V. S., Reddy, K. N., Panda, G., & Majhi, B. (2016). Sentiment analysis of Twitter data for predicting stock market movements. 2016 International
Conference on Signal Processing, Communication, Power and Embedded System (SCOPES). https://doi.org/10.1109/scopes.2016.7955659
[15] Chen, L., Qiao, Z., Wang, M., Wang, C., Du, R., & Stanley, H. E. (2018). Which Artificial Intelligence Algorithm Better Predicts the Chinese Stock Market?
IEEE Access, 6, 48625–48633. https://doi.org/10.1109/access.2018.2859809
[16] S. Punitha & M. Jeyakarthic (2020). An Effective Stock Market Prediction Model using Genetic Algorithm with Support Vector Machine. 2020 ADALYA
JOURNAL.
[17] Nti, I. K., Adekoya, A. F., & Weyori, B. A. (2020). Efficient Stock-Market Prediction Using Ensemble Support Vector Machine. Open Computer Science,
10(1), 153–163. https://doi.org/10.1515/comp-2020-0199
[18] Chen, Y., & Hao, Y. (2017). A feature weighted support vector machine and K-nearest neighbor algorithm for stock market indices prediction. Expert Systems
with Applications, 80, 340–355. https://doi.org/10.1016/j.eswa.2017.02.044
[19] Kashyap, S. (2019). Estimating Efficiency of Support Vector Machine Based Model in Prediction of The Direction of Future Stock Price During Different
Trends of Market. International Journal of Computer Sciences and Engineering, 7(4), 259–262. https://doi.org/10.26438/ijcse/v7i4.259262
[20] Elijah Joseph. (2019). Forecast on Close Stock Market Prediction using Support Vector Machine (SVM). International Journal of Engineering Research And,
V8(02), 01. https://doi.org/10.17577/ijertv8is020031
[21] Tesla Inc. data set: https://in.finance.yahoo.com/quote/TSLA?p=TSLA&.tsrc=fin-srch
[22] Reliance Industries Limited: https://in.finance.yahoo.com/quote/RELIANCE.NS?p=RELIANCE.NS&.tsrc=fin-srch

©IJRASET: All Rights are Reserved 383

You might also like