You are on page 1of 15

Stock Price

Prediction –
Machine
Learning
Project in
Python
ABSTRACT:-
Stock market trading is an activity in which investors need fast and accurate
information to make effective decisions. Since many stocks are traded on a stock
exchange, numerous factors influence the decision-making process. Moreover, the
behaviour of stock prices is uncertain and hard to predict. For these reasons, stock
price prediction is an important process and a challenging one. This leads to the
research of finding the most effective prediction model that generates the most
accurate prediction with the lowest error percentage. This paper reviews studies
on machine learning techniques and algorithm employed to improve the accuracy
of stock price prediction.

Introduction:-
Predicting how the stock market will perform is one of the most difficult things to do. There are
so many factors involved in the prediction – physical factors vs. psychological, rational and
irrational behavior, etc. All these aspects combine to make share prices volatile and very
difficult to predict with a high degree of accuracy.
Can we use machine learning as a game-changer in this domain? Using features like the latest
announcements about an organization, their quarterly revenue results, etc., machine learning
techniques have the potential to unearth patterns and insights we didn’t see before, and these
can be used to make unerringly accurate predictions.
we will work with historical data about the stock prices of a publicly listed company. We will
implement a mix of machine learning algorithms to predict the future stock price of this
company.
machine learning is all the rage right now, so it is essential to be familiar with some machine
learning models as well. We shall start with the most popular model in time series domain −
Long Short-term Memory model.
LSTM is a class of recurrent neural network. So before we can jump to LSTM, it is essential to
understand neural networks and recurrent neural networks.

Neural Networks
An artificial
neural network is a layered structure of connected neurons, inspired
by biological neural networks. It is not one algorithm but combinations of various
algorithms which allows us to do complex operations on data.
Recurrent Neural Networks
It is a class of neural

networks tailored to deal with temporal data. The neurons of
RNN have a cell state/memory, and input is processed according to this internal
state, which is achieved with the help of loops with in the neural network. There
are recurring module(s) of ‘tanh’ layers in RNNs that allow them to retain
information. However, not for a long time, which is why we need LSTM models.
LSTM

It is special kind of recurrent neural network that is capable of learning long term
dependencies in data. This is achieved because the recurring module of the
model has a combination of four layers interacting with each other.
Stock analysis: fundamental analysis vs. technical analysis
When it comes to stocks, fundamental and technical analyses are at opposite ends of the

market analysis spectrum.


Fundamental Analysis
Fundamental analysis evaluates stocks by attempting to measure their intrinsic value.
Fundamental analysts study everything from the overall economy and industry conditions to
the financial strength and management of individual companies. Earnings, expenses, assets,
and liabilities all come under scrutiny by fundamental analysts.

Technical Analysis
Technical analysis differs from fundamental analysis, in that traders attempt to identify
opportunities by looking at statistical trends, such as movements in a stock's price and
volume. The core assumption is that all known fundamentals are factored into price, thus
there is no need to pay close attention to them. Technical analysts do not attempt to measure
a security's intrinsic value. Instead, they use stock charts to identify patterns and trends that
suggest what a stock will do in the future.
DESCRIPTION OF WORK
Machine learning has
significant applications in the stock price prediction. In this machine
learning project, we will be talking about predicting the returns on stocks. This is a very
complex task and has uncertainties. We will develop this project into two parts:
1.First, we will learn how to predict stock price using the LSTM neural network.
2.Then we will build a dashboard using Plotly dash for stock analysis.

Datasets

To build the stock price prediction model, we will use the NSE TATA GLOBAL dataset. This is a dataset of
Tata Beverages from Tata Global Beverages Limited, National Stock Exchange of India: Tata Global Dataset
To develop the dashboard for stock analysis we will use another stock dataset with multiple stocks like
Apple, Microsoft, Facebook: Stocks Dataset

Stock price prediction using LSTM


1. Imports: 2. Read the dataset:
3. Analyze the closing prices from dataframe:
4. Sort the dataset on date time and filter “Date” and “Close” columns:

5. Normalize the new filtered dataset:


6. Build and train the LSTM model:

7. Take a sample of a dataset to make stock price predictions using the LSTM model:

8. Save the LSTM model:


9. Visualize the predicted stock costs with actual stock costs:
You can observe that LSTM has predicted stocks almost similar to actual stocks.
Several Advantages/Disadvantages of Different models
of Predicting stock prices
VEDANT KOHLI
(2K20/CO/478)

You might also like