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

SVM Code Stock Prediction

Uploaded by

Ývåň Loïc
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

SVM Code Stock Prediction

Uploaded by

Ývåň Loïc
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

e-ISSN: 2582-5208

International Research Journal of Modernization in Engineering Technology and Science


( Peer-Reviewed, Open Access, Fully Refereed International Journal )
Volume:04/Issue:01/January-2022 Impact Factor- 6.752 www.irjmets.com

STOCK MARKET PREDICTION USING MACHINE LEARNING & PYTHON


Y.Puja*1, Vivek Parghania*2, Dinesh Bhawnani*3
*1Research Scholar, M .Tech. Computer Networks, Bhilai Institute Of Technology,
Durg, Chhattisgarh, India.
*2,3Associate Professor, Department Of Computer Science, Bhilai Institute Of Technology,
Durg, Chhattisgarh, India.
ABSTRACT
In Stock Market Prediction, the point is to foresee the future worth of the monetary loads of an organization.
The new pattern in securities exchange forecast innovations is the utilization of AI which makes expectations
dependent on the upsides of current financial exchange files via preparing on their past qualities. AI itself
utilizes various models to make forecast more straightforward and bona fide. The paper centres around the
utilization of Regression and LSTM based Machine figuring out how to foresee stock qualities. Factors
considered are open, close, low, high and volume.
Keywords: Stock, Stock Market, Machine Learning Algorithms, Python.
I. INTRODUCTION
A right expectation of stocks can prompt colossal benefits for the vender and the dealer. Habitually, it is drawn
out that forecast is turbulent rather than irregular, which implies it tends to be anticipated via cautiously
examining the historical backdrop of separate securities exchange. AI is a productive method for addressing
such cycles. It predicts market esteem near the substantial worth, in this way expanding the precision.
Acquaintance of AI with the area of stock expectation has engaged many explores in light of its effective and
precise estimations [1]. The indispensable piece of AI is the dataset utilized. The dataset ought to be pretty
much as concrete as conceivable on the grounds that a little change in the information can sustain gigantic
changes in the result [2]. In this undertaking, directed AI is utilized on a dataset got from Netflix. This dataset
involves following five factors: open, close, low, high and volume. Open, close, low and high are diverse offered
costs for the stock at independent occasions with almost direct names. The volume is the quantity of offers that
passed starting with one proprietor then onto the next during the time span. The model is then tried on the test
information. Relapse and LSTM models are locked in for this guess independently. Relapse includes limiting
blunder and LSTM [3][4] adds to recollecting the information and results for the since quite a while ago run. At
long last, the charts at the change of costs with the dates (if there should be an occurrence of Regression based
model) and among genuine and anticipated cost (for the LSTM based model) are plotted. The rest of the paper
comprise of the accompanying: Part 2 advances the two models utilized and the techniques utilized in them
exhaustively. Section 3 examines the outcomes delivered with various plots for both the models exhaustively.
Section 4 comprises of end and the last segment includes the references.
II. METHODOLOGY
Financial exchange expectation appears to be a mind boggling issue since there are many elements that still
can't seem to be tended to and it doesn't appear to be measurable from the outset. In any case, by legitimate
utilization of AI strategies, one can relate past information to the current information and train the machine to
gain from it and make fitting presumptions. AI as such has many models yet this paper centres around two
generally significant of them and made the forecasts utilizing them.
REGRESSION BASED MODEL
Regression is utilized for anticipating ceaseless qualities through a few given autonomous qualities. The
undertaking depends on the utilization of straight relapse calculation for foreseeing right qualities by limiting
the mistake work as yielded. Relapse involves a given direct capacity for anticipating persistent qualities:
V=a+bk+error
Where, Vis a ceaseless worth; K addresses known free qualities; and, a, b are coefficients. Work was completed
on csv arrangement of information through panda library and determined the boundary which is to be

www.irjmets.com @International Research Journal of Modernization in Engineering, Technology and Science


[797]
e-ISSN: 2582-5208
International Research Journal of Modernization in Engineering Technology and Science
( Peer-Reviewed, Open Access, Fully Refereed International Journal )
Volume:04/Issue:01/January-2022 Impact Factor- 6.752 www.irjmets.com
anticipated, the cost of the stocks concerning time. The information is separated into various train sets for get
approval to keep away from over fitting. The test set is for the most part kept 20% of the entire dataset. Direct
relapse as given by the above condition is performed on the information and afterward expectations are made,
which are plotted to show the consequences of the financial exchange costs versus time [6].
III. RESULTS
#This programs attempts to predict the price of Netflix stock
#Install the dependencies
import numpy as np
import pandas as pd
from sklearn. tree import Decision Tree Regressor
from sklearn. linear_model import Linear Regression
from sklearn.model_selection import train_test_split
import matplotlib.pyplot as plt
plt.style.use('bmh')
from google.colab import files # Use to load data on Google Colab
uploaded = files.upload() # Use to load data on Google Colab
df = pd.read_csv('NFLX_Stock.csv')
df.head(6)
plt.figure(figsize=(16,8))
plt.title('Netflix', fontsize = 18)
plt.xlabel('Days', fontsize= 18)
plt.ylabel('Close Price USD ($)', fontsize = 18)
plt.plot(df['Close Price'])
plt.show()

df = df[['Close Price']]
df.head(4)
#Create a variable to predict 'x' days out into the future
future_days = 25

www.irjmets.com @International Research Journal of Modernization in Engineering, Technology and Science


[798]
e-ISSN: 2582-5208
International Research Journal of Modernization in Engineering Technology and Science
( Peer-Reviewed, Open Access, Fully Refereed International Journal )
Volume:04/Issue:01/January-2022 Impact Factor- 6.752 www.irjmets.com
#Create a new column (the target or dependent variable) shifted 'x' units/days up
df['Prediction'] = df[['Close Price']].shift(-future_days)
#print the data
df.tail(4)
X = np.array(df.drop(['Prediction'], 1))[:-future_days]
print(X)
y = np.array(df['Prediction'])[:-future_days]
print(y)
x_train, x_test, y_train, y_test = train_test_split(X, y, test_size = 0.25)
#Create the decision tree regressor model
tree = DecisionTreeRegressor().fit(x_train, y_train)
#Create the linear regression model
lr = LinearRegression().fit(x_train, y_train)
#Get the feature data,
#AKA all the rows from the original data set except the last 'x' days
x_future = df.drop(['Prediction'], 1)[:-future_days]
#Get the last 'x' rows
x_future = x_future.tail(future_days)
#Convert the data set into a numpy array
x_future = np.array(x_future)
x_future
#Show the model tree prediction
tree_prediction = tree.predict(x_future)
print( tree_prediction )
print()
#Show the model linear regression prediction
lr_prediction = lr.predict(x_future)
print(lr_prediction)
Visualize and compare the predicted values with the actual or valid values.
#Visualize the data
predictions = tree_prediction
#Plot the data
valid = df[X.shape[0]:]
valid['Predictions'] = predictions #Create a new column called 'Predictions' that will hold the predicted prices
plt.figure(figsize=(16,8))
plt.title('Model')
plt.xlabel('Days',fontsize=18)
plt.ylabel('Close Price USD ($)',fontsize=18)
plt.plot(df['Close Price'])
plt.plot(valid[['Close Price','Predictions']])
plt.legend(['Train', 'Val', 'Prediction' ], loc='lower right')
plt.show()

www.irjmets.com @International Research Journal of Modernization in Engineering, Technology and Science


[799]
e-ISSN: 2582-5208
International Research Journal of Modernization in Engineering Technology and Science
( Peer-Reviewed, Open Access, Fully Refereed International Journal )
Volume:04/Issue:01/January-2022 Impact Factor- 6.752 www.irjmets.com

#Visualize the data


predictions = lr_prediction
#Plot the data
valid = df[X.shape[0]:]
valid['Predictions'] = predictions #Create a new column called 'Predictions' that will hold the predicted prices
plt.figure(figsize=(16,8))
plt.title('Model')
plt.xlabel('Days',fontsize=18)
plt.ylabel('Close Price USD ($)',fontsize=18)
plt.plot(df['Close Price'])
plt.plot(valid[['Close Price','Predictions']])
plt.legend(['Train', 'Val', 'Prediction' ], loc='lower right')
plt.show()

www.irjmets.com @International Research Journal of Modernization in Engineering, Technology and Science


[800]
e-ISSN: 2582-5208
International Research Journal of Modernization in Engineering Technology and Science
( Peer-Reviewed, Open Access, Fully Refereed International Journal )
Volume:04/Issue:01/January-2022 Impact Factor- 6.752 www.irjmets.com
IV. CONCLUSION
Two methods have been used in this paper: Regression, on the Netflix dataset. Both the methods have shown an
improvement in the exactness of expectations, subsequently yielding positive outcomes. Utilization of as of late
presented AI methods in the forecast of stocks have yielded promising outcomes and in this way denoted the
utilization of them in beneficial trade plans. It has prompted the end that it is feasible to foresee securities
exchange with more exactness and productivity utilizing AI strategies. Later on, the securities exchange
expectation framework can be additionally improved by using a lot greater dataset than the one being used as
of now. This would assist with expanding the exactness of our forecast models. Besides, different models of
Machine Learning could likewise be read up to check for the exactness rate came about by them.
V. REFERENCES
[1] Vijh, M., Chandola, D., Tikkiwal, V. A., & Kumar, A. (2020). Stock closing price prediction using machine
learning techniques. Procedia Computer Science, 167, 599-606.
[2] Parmar, I., Agarwal, N., Saxena, S., Arora, R., Gupta, S., Dhiman, H., & Chouhan, L. (2018, December).
Stock market prediction using machine learning. In 2018 First International Conference on Secure
Cyber Computing and Communication (ICSCCC) (pp. 574-576). IEEE.
[3] Reddy, V. K. S. (2018). Stock market prediction using machine learning. International Research Journal
of Engineering and Technology (IRJET), 5(10), 1033-1035.
[4] Tiwari, S., Bharadwaj, A., & Gupta, S. (2017, December). Stock price prediction using data analytics.
In 2017 International Conference on Advances in Computing, Communication and Control (ICAC3) (pp.
1-5). IEEE.
[5] Vignesh, C. K. (2020). Applying machine learning models in stock market prediction. EPRA
International Journal of Research & Development (IJRD), 395-398.

www.irjmets.com @International Research Journal of Modernization in Engineering, Technology and Science


[801]

You might also like