Step-by-step tutorial using machine learning to trade

Step-by-step tutorial using machine learning to trade

21 July 2014, 18:00
Justin Cahoon
0
1 843

A Step-by-Step Guide to Using a Naïve Bayes Classifier to Predict the Direction of an Asset in R.

Now that we have an understanding of the basic concepts of using machine-learning algorithms in your strategy (you can find the first part of the series here), we’ll go through a basic example of how to use a Naïve Bayes classifier to predict the direction of Apple stock. First, we will gather a basic understanding of how a Naïve Bayes classifier works, then we will step through a very simple example using the day of the week to predict whether the day’s price will close up or down, and finally we will build a more sophisticated model adding a technical indicator.

What is a Naïve Bayes classifier?

A Naïve Bayes classifier tries to find the probability that A will happen given that B has already occurred, commonly denoted by P(A | B) (the probability of A given B).

For our case, we are basically asking “what is the probability that today’s price will increase given that today is Wednesday?” The Naïve Bayes looks at both the overall probability that today’s price will increase, i.e. the number of days the price has closed up over the total number of days, and the probability that today’s price will increase given that today is Wednesday, i.e. on how many previous Wednesdays did the price close up? 

You can find the full article here

Share it with friends: