4.1 How a machine learns
Machine learning means the computer learns from examples. The basic idea is simple.
Three ingredients
| Part | Explanation | Trading example |
|---|---|---|
| Features | The information the model is given | RSI, distance to the moving average, volume, weekday |
| Label | What the model has to learn to predict | Did the price rise over the next five days? Yes or no |
| Training | The model adjusts itself to hit the label as well as possible | Thousands of historical examples |
After training, the model can give an estimate for new situations: “In situations like this one, the price rose 54% of the time.”
Common types of model
- Linear regression: Simple and easy to understand.
- Decision trees and “random forests”: Many yes/no questions. Popular in finance.
- Neural networks: Powerful, but they need a lot of data and are easily overfitted.
54% is not 100%
Even a good model only gives probabilities – and often only slightly better than a coin toss. In trading that can be enough, but only if the profits are large enough to cover the costs and the risk is well managed.
Want to try it yourself?
With Python and free libraries such as scikit-learn you can build a simple model in an afternoon – and a language model can write the code for you. Use it as a learning exercise, not as a money machine.
From the textbooks: three ways to fit the same data
Every textbook on machine learning makes the same point with a picture like this. A model that is too simple misses the pattern. A model that is too flexible memorises every wobble in the data, including the random ones, and fails on anything new. Financial data is mostly noise. In trading, the danger is therefore almost always on the flexible side.
Key takeaways
- Machine learning consists of features, labels and training on historical examples.
- The model gives probabilities – often only slightly better than a coin toss.
- Simple models are easier to understand and are less often overfitted.
65% of retail investor accounts lose money when trading CFDs with this provider.