### Stock Market Predictions with Markov Chains and Python

### Introduction

Lets create a multi-feature binary classification model. This is based on Pranab Gosh excellent post titled Customer Conversion Prediction with Markov Chain and well implement it based on his pseudo code in Python. MORE: Blog or code: http://www.viralml.com/video-content.html?fm=yt&v=sdp49vTanSk Signup for my newsletter and more: http://www.viralml.com Connect on Twitter: https://twitter.com/amunategui Check out my book on Amazon The Little Book of Fundamental Market Indicators https://amzn.to/2DERG3d Pranabs post: https://pkghosh.wordpress.com/2015/07/06/customer-conversion-prediction-with-markov-chain-classifier/ Stock data: https://finance.yahoo.com/quote/%5EGSPC?p=^GSPC Transcript Lets run some Stock Market predictions with Markov Chains and Python I am basing this video from a great post by Pranab Gosh titled Customer Conversion Prediction with Markov Chain Classifier He lays out his approach using easy to understand pseudo-code so I recommend reading to understand the theory of the approach He is applying it obviously to customer conversion data but that data isnt as easy to get a stock market data. Also, this is just my interpretation of his pseudo code as there are many ways of slicing and dicing this. But what I like about his approach is that his clever way of doing binary classification with by creating two transition matrices - a positive one and a negative one. Lets dig in. Markov Chains A Markov Chain offers a probabilistic way of predicting the likelihood of an event based on prior behavior or prior events. If you look at the drawing of Andrey Markov my son did, we surrounded him with dollar chains, each dollar is an event, and Welcome to ViralML, my name is Manuel Amuantegui and am the author of Monetizing ML and other books that you can find on Amazon. First-Order Transition Matrix A transition matrix is the probability matrix from the Markov Chain. In its simplest form, you read it by choosing the current event on the y-axis and look for the probability of the next event off the x-axis. In the below image from Wikipedia, you see that the highest probability for the next note after A is C#. In our case, we will analyze each event pair in a sequence and catalog the market behavior. We then tally all the matching moves and create two data sets for volume action, one for up moves and another for down moves. New stock market events are then broken down into sequential pairs and tallied for both positive and negative outcomes - biggest moves win (there is a little more to this in the code, but thats it in a nutshell). CATEGORY:DataScience HASCODE:Predict-Stock-Market-With-Markov-Chains-and-Python.html SPECIALFRAME:True

### Code

If there is code for this video, please refer to YouTube notes

### Show Notes

(pardon typos and formatting -these are the notes I use to make the videos)

Lets create a multi-feature binary classification model. This is based on Pranab Gosh excellent post titled Customer Conversion Prediction with Markov Chain and well implement it based on his pseudo code in Python. MORE: Blog or code: http://www.viralml.com/video-content.html?fm=yt&v=sdp49vTanSk Signup for my newsletter and more: http://www.viralml.com Connect on Twitter: https://twitter.com/amunategui Check out my book on Amazon The Little Book of Fundamental Market Indicators https://amzn.to/2DERG3d Pranabs post: https://pkghosh.wordpress.com/2015/07/06/customer-conversion-prediction-with-markov-chain-classifier/ Stock data: https://finance.yahoo.com/quote/%5EGSPC?p=^GSPC Transcript Lets run some Stock Market predictions with Markov Chains and Python I am basing this video from a great post by Pranab Gosh titled Customer Conversion Prediction with Markov Chain Classifier He lays out his approach using easy to understand pseudo-code so I recommend reading to understand the theory of the approach He is applying it obviously to customer conversion data but that data isnt as easy to get a stock market data. Also, this is just my interpretation of his pseudo code as there are many ways of slicing and dicing this. But what I like about his approach is that his clever way of doing binary classification with by creating two transition matrices - a positive one and a negative one. Lets dig in. Markov Chains A Markov Chain offers a probabilistic way of predicting the likelihood of an event based on prior behavior or prior events. If you look at the drawing of Andrey Markov my son did, we surrounded him with dollar chains, each dollar is an event, and Welcome to ViralML, my name is Manuel Amuantegui and am the author of Monetizing ML and other books that you can find on Amazon. First-Order Transition Matrix A transition matrix is the probability matrix from the Markov Chain. In its simplest form, you read it by choosing the current event on the y-axis and look for the probability of the next event off the x-axis. In the below image from Wikipedia, you see that the highest probability for the next note after A is C#. In our case, we will analyze each event pair in a sequence and catalog the market behavior. We then tally all the matching moves and create two data sets for volume action, one for up moves and another for down moves. New stock market events are then broken down into sequential pairs and tallied for both positive and negative outcomes - biggest moves win (there is a little more to this in the code, but thats it in a nutshell). CATEGORY:DataScience HASCODE:Predict-Stock-Market-With-Markov-Chains-and-Python.html SPECIALFRAME:True