**Introduction**

Predicting stock prices is an uncertain task using machine learning. There are a lot of tools used for stock market prediction. The stock market is considered to be dynamic and complex. An accurate forecast of future prices may lead to a higher profit yield for investors through stock investments. Investors will pick stocks that may give a higher return as per the predictions.

Over the years, various __machine learning__ algorithms have been used in stock market prediction. Still, with the increased amount of data and expectation of more accurate forecasts, deep learning models are being used nowadays, proving their advantage over traditional machine learning methods in terms of accuracy and speed of prediction.

Traditionally, most machine learning models use some observations as input, but there is no time dimension in the dataset. Time-series forecasting models can predict future values based on past observed values. We widely use Time-series forecasting for non-stationary data. Non-stationary data are the data whose statistical values, i.e., the mean and standard deviation, are not constant but instead, these metrics vary over time.

These non-stationary input data (used to input these models) are usually called time-series. Some examples of time series include the temperature values over time, stock price over time, price of house overtime, etc. So, the input is a signal defined by observations taken sequentially in time.

This article will discuss the LSTM Network, one of the popular deep learning techniques used in stock price prediction. In this article, we will fetch the historical data of stock automatically using python libraries and fit the LSTM model on this data to predict the future prices of the store.

**LSTM**

Long short-term memory is an artificial recurrent neural network (RNN) architecture used in deep learning. Unlike standard feedforward neural networks, Long short-term Memory has feedback connections. It can process single data points (e.g., images) and entire data sequences (such as speech or video inputs).

LSTM models can store information over some time. They have a memory capacity.

This characteristic is beneficial when we deal with Time-Series or Sequential Data. When using an LSTM model, we can decide what information will be stored and discarded. We do that using the "gates."

LSTM has three gates:

**The input gate:**This gate adds information to the cell state,**The forget gate:**It removes the knowledge that the model no longer requires,**The output gate:**This gate at LSTM selects the information shown as output.

However, some variants of the LSTM model, such as Gated Recurrent Units (GRUs), don't have an output gate. Long short-term memory networks are popularly used on time-series data for classification and making predictions. Its popularity in time-series applications is that there can be several lags of unknown duration between important events in a time series.