Quant500 Academy

3. What machine learning is, exactly

Level 10: Machine Learning Applied to Trading

There is a much-repeated popular definition: machine learning is the field of computer science that gives computers the ability to learn without being explicitly programmed to do so. It works as a headline, but it is vague: it says neither what learning means nor how to check whether it has really happened.

Machine learning was born during the early development of artificial intelligence and pattern recognition and, like every technology, it grew into an industry hand in hand with business. There is a widely used formal definition, due to Tom M. Mitchell:

"A computer program is said to learn from experience E with respect to some class of tasks T and performance measure P, if its performance at tasks in T, as measured by P, improves with experience E."

The definition says two important things: our program has to learn from data, and it has to improve its performance. Both parts are demandable and checkable.

The classic example is predicting the price of a house: first we feed the algorithm data such as current prices by square meter, number of rooms and so on. From that data the algorithm learns and improves its estimates by reducing prediction errors. We can measure performance by running the algorithm on new input data whose outcome we know and observing the error rate. Our goal will be to bring that error rate down.

Translated into a trading system, the three pieces look like this:

This decomposition is more than an academic exercise. It forces you to fix the metric before training, which is exactly the point at which most self-deception creeps into quantitative trading. And it forces P to be measured on unseen data: if P improves on the very data you learned from, you have proved nothing, because memorizing also drives the in-sample error down.

# Mitchell's definition, written as code
def learns(model, growing_experience, test_task, metric):
    results = []
    for E in growing_experience:             # more and more training data
        model.fit(E["X"], E["y"])
        p = metric(test_task["y"], model.predict(test_task["X"]))
        results.append(p)
    # It learns if P improves as E grows, measured ALWAYS on unseen data
    return results[-1] > results[0], results

If that function returns False, you have a program that processes data, but not a program that learns.

The rest of Quant500

What you are learning, applied to the index every day:

The model portfolio, weekly in your inbox

Every Saturday, its week in one minute: how it went, the best and the worst, and which insiders bought with their own money. Plus, the day the model is rebuilt, which stocks come in and which go out. A simulation, not advice. At most one email a week, no ads, no account; one-click unsubscribe. Made by one person: Pol Gracia.

A model portfolio with simulated results, not a personalized recommendation. Your email is used for this only: privacy.

Behind the Academy and the rest of Quant500 there is one person: Pol Gracia Serrahima.