EDIT: More recent version here.
I've seen a number of posts here involving machine learning. Although machine learning probably seems complicated at first, it is actually easy to work with. I wanted to try to create a simple algorithm and post to introduce people to the concept who aren't familiar.
The goal of machine learning is to create an accurate model based off of past data then use that model to predict future events. There are mainly two types of machine learning used in quantitative finance:
- Regression is used to predict a continuous value, like predict a price will rise $0.46.
- Classification is used to predict a category, like just predict a price will rise.
This example uses classification.
A model needs to be created based off of past independent and dependent variables, then that model can be used to try to predict future changes in the price. There are 10 independent variables, or input variables in this algorithm. They are whether a price increased or decreased on the 10 bars before a selected bar. The dependent variable, or the output variable is whether a price increased or decreased on that selected bar. Once there are enough data points, a model can be created to try to predict future prices.
You can find more information about machine learning and the module used, sklearn, here.
I'd also like to thank Alex for inspiring this and Thomas for helping me. Feel free to copy and use the code, and let me know if you have any questions or ideas!