top of page

Python Stock Market Prediction with LSTM Neural Network Guided Project Part 1, Level 1, 18 min

Updated: Aug 21, 2023

In this Python deep learning project, we set up our LSTM neural network with Tensorflow in an attempt to get rich and predict the stock market. In this project, we use the MACD and RSI indicators as our features to predict today's closing value. The LSTM is a recurrent layer and either the SimpleRNN or GRU can be used in its place. This is a great place to experiment with how different recurrent layers impact the predictions of GOOG stock price available at Kaggle.












Send data science teacher brandyn a message if you have any questions


Data Groups:





Plot this history our of your Tensorflow model's training history in a quick easy way with Pandas.

Free, Instruct, instructional, instructional education,free python learn, seaborn, python, project, data analysis project, pandas, analyze, Tensorflow, architecture, neural network, deep learning
Plot the Hiistory of your Tensorflow model easily with Pandas plot




We start our stock market prediction with deep learning project by building the MACD and RSI indicators common in technical analysis in stock market trading, using Pandas built in functions.

Free, Instruct, instructional, instructional education,free python learn, seaborn, python, project, data analysis project, pandas, analyze, Tensorflow, architecture, neural network, deep learning
Don't worry the MACD and RSI math is left complete



An important consideration is whether our data is stationary or not. When we preprocess our data for financial-type predictions we will need to make our data stationary.

Free, Instruct, instructional, instructional education,free python learn, seaborn, python, project, data analysis project, pandas, analyze, Tensorflow, architecture, neural network, deep learning
Taking the percentage change is a simple way to make the data stationary


In our time series prediction using a Tensorflow deep learning model, we have to consider what will will use to predict itself. An auto-prediction, self-prediction. We have a little more flexibility here than with ARIMA in Statsmodel and but question what lags period we use?

Free, Instruct, instructional, instructional education,free python learn, seaborn, python, project, data analysis project, pandas, analyze, Tensorflow, architecture, neural network, deep learning
Engineer Time Series Features



In stock predictions to understand if our prediction will work tomorrow, we need to do a time series split to create our train and test data.

Free, Instruct, instructional, instructional education,free python learn, seaborn, python, project, data analysis project, pandas, analyze, Tensorflow, architecture, neural network, deep learning
Time Series Train Test Split


Always important for machine learning predictions. We'll use my favorite from Sklearn to standardize our data using StandardScaler.

Free, Instruct, instructional, instructional education,free python learn, seaborn, python, project, data analysis project, pandas, analyze, Tensorflow, architecture, neural network, deep learning
Use StandardScaler in Sklearn to standardize the data


Here we build a simple neural network in Tensorflow and include the LSTM to make our stock market predictions.

Free, Instruct, instructional, instructional education,free python learn, seaborn, python, project, data analysis project, pandas, analyze, Tensorflow, architecture, neural network, deep learning
Build the architecture of your Tensorflow model



bottom of page