Stock Prediction
Stock Prediction
Prediction
using LSTM algorithm
V.S.S.Sriannaamalai 2021503564
S.Nithishkumar 2021503530
B.Vignesh 2021503714
Motivation
The accurate prediction of stock prices has a significant role to play in the present
economic world.
However, stocks have an ever-changing nature coupled with a risk factor that always
seems much of a gamble, making it worthwhile for researchers to analyze them with
machine learning algorithms.
In stock prediction,
Proposes a prediction where data can be
system based on highly nonlinear,
Stock Market Prediction Sadia, K. Hiba,
Machine Learning SVM's reliance on
Using Machine Learning 2019 Aditya Sharma,
algorithm Support Vector linear boundaries
Algorithms. Adarrsh Paul
Machine (SVM) and might not capture
Random Forest Classifier complex patterns
effectively.
Logistic regression
A Logistic Regression
assumes a linear
based model using
A new approach of stock Gong, Jibing, relationship between
feature index values and
price prediction based on 2009 and Shengtao the independent
significant time-
logistic regression model. Sun variables and the log-
effectiveness has been
odds of the
proposed
dependent variable.
Literature Survey
Paper Year Author Proposed Work Drawback
Combined the
historical data
SVM performance can be
with the
sensitive to the choice of the
sentiments like
Nayak, kernel and the regularization
Prediction news/tweets of a
Aparna, MM parameter. Selecting
models for company.This
2016 Manohara Pai, appropriate values for these
Indian stock type of dataset,
and Radhika parameters can require
market Decision Tree
M. Pai extensive tuning and cross-
performs better
validation, which can be
than Logistic
computationally expensive.
Regression and
SVM.
Limitations KNN
149
LSTM model is the best proposed model Decision tree
as it can depict the near representation 59
Linear
of predicted values from the actual
Regression
stock price value and has the least
54
RMSE value.
LSTM
21.83
Whereas Linear Regression, Decision
Tree and KNN cannot predict the prices
as accurately as LSTM.
RMSE VALUES
Objective
01. Preprocess the data to handle missing values,
normalize the features, and create appropriate
input sequences for the LSTM model.
Scaling
Slidingwindow
approach Labeling
Splitting of dataset
Input Dataset
Scaling
Scale the features to a range suitable for the activation function of the neural network.
Commonly, the Min-Max scaling method is used to scale the features between 0 and 1.
Scaling ensures that each feature contributes equally to the model's learning process
and prevents features with larger magnitudes from dominating the model.
Sliding window approach labelling
Convert the time series data into input-output pairs suitable for training a sequence
prediction model like LSTM.
In the sliding window approach, you create input sequences (X) and corresponding
output labels (y) by sliding a window of a fixed size over the time series data.
For example, if you're using a window size of 60 time steps, each input sequence
contains the historical values of the selected features for the past 60 time steps,
and the corresponding output label is the value of the target feature at the next
time step.
This process effectively converts the time series data into a supervised learning
problem.
Splitting of dataset
In the training phase, the model gets coached on the data and
then the testing data gets tested on the trained model so that it
can predict the stock price more accurately
Methodologies
LSTM Model
Building model
Compiling model
Evaluating model
.
LSTM
LSTM stands for Long Short Term Memory is a deep
neural network..
01. Input Gate
In LSTM, the hidden layers that generally all neural
network uses are replaced with memory cells, a
series of gates. 02. Forget Gate
These gates decide whether to pass the detailed
information to the next cell or ignore it. There are
three gates in LSTM 03. Output Gate
Memory cells containing gates
MSE is one of the most commonly used loss functions in regression tasks, including
stock price prediction. It calculates the average squared difference between the
predicted values and the true values.
C0mpiling Model
Backpropagation is used to update the weights of the neural network in order to
minimize the loss function. Gradients of the loss with respect to the model's
parameters are computed and used to adjust the weights through gradient descent
optimization algorithms like Adam
Consequently, we have used four layers of the LSTM model in which the first two
layers take the input of 50 set.
The third layer, usually known as the "Dense" layer, serves as the connection between
the second layer and the next Dense layer, which is the output layer
Ultimately, for compiling the model, we consider the two parameters – Adam
optimizer and loss function as mean square error
Evaluation Graph
By using the LSTM model the predicting stock values ( represented using orange colour) are almost
accurately equal to the valid value which is represented using red colour
Contributions
Sriannaamalai - Built and trained the model