This post is based “Machine Learning on Quantopian" by Thomas Wiecki and l also presented this modification of Thomas' notebook that uses previous returns as decision variables and a Gaussian Naive Bayes predictor instead of the Ada Boost classifier. This post is also related to the "Naive Bayes High Low Return Prediction Algorithm" post.