Florestas de decisões aleatórias em finanças: preparando-se para o inesperado

Random Decision Forests in Finance: Preparing for the Unexpected

Random Forest are powerful classification algorithms that can be trained to help finance experts make better decisions and detect irregularities in the market.

Imagem em destaque

“Does the flapping of a butterfly’s wings in Brazil trigger a tornado in Texas?” This question, posed by Edward Lorenz, would be the basis of what popular science today calls the “Butterfly Effect”. The idea is that small changes can have repercussions with large-scale consequences.

To be more precise, the Butterfly Effect is part of Chaos Theory and can be summarized as the sensitive dependence on initial conditions in which a small change in one state of a deterministic nonlinear system can result in large differences in a later state.

The financial world is plagued by butterfly effects, and perhaps one of the biggest examples was Black Monday, when the Hong Kong market crashed, its index fell rapidly and losses mounted at a breakfast place. Before anyone could comprehend what happened, the consequences were felt across the world.

How about 2007? When the collapse of an admittedly small part of the US mortgage market caused a widespread crisis that was felt around the world. Bailouts, government aid, and different forms of support were needed to restart and normalize the global economy.

Finance is complex as it depends on both economic forces and the psychology of investors. All it takes is one push and the dominoes start to fall. Why does this happen and how can technology help us avoid it?

The fragility of financial systems

Andrew Haldane, executive director of financial stability at the Bank of England, presented an academic paper in which he observed that the financial system had become progressively more complex, but increasingly less diversified. What does this imply?

Imagine financial systems like a building: the more diverse a system is, the more foundations it has to withstand the pressure. The more complex, the larger and more complicated the infrastructure (columns and beams that distribute the weight along with the structure).

Hypothetically, you could have few foundations, but have an infrastructure that distributes the weight and keeps the building standing. Unfortunately, if one of the foundations fails, it would cause a ripple effect throughout the building and regardless of the infrastructure, it would eventually collapse.

In other words, the less diverse our financial system is, the fewer safety nets it has to withstand sudden changes and random shocks. No matter how elegant your building is, you can't build it on thin ice.

An Introduction to Random Forests

Before understanding the forest, we first have to talk about the trees (excuse the pun). Decision trees are powerful machine learning algorithms used for classification. It is a structure similar to a flowchart where each node represents a “test” of an attribute.

Although it may seem complicated, it is actually quite simple. In fact, we unconsciously use decision trees all the time.

For example, if you want to eat tacos but don't want to go very far, you can use a decision tree. First you make a list of all the restaurants you know in the city, then classify them into two categories, those that have tacos on the menu and those that don't.

We then classify those with tacos on their menu as “near” or “far” depending on how close they are to our current location. Then, finally, we classify them once again, this time as “within our budget” or “very expensive”. Finally, we end with a list of nearby taco restaurants that are affordable.

In real life, a single expert, no matter how good he is, can make mistakes, which is why we rely on committees. In a committee, even if one expert makes a mistake, you will have several other differing opinions that will help you make the right choice in the end.

Random Forests are like digital committees, instead of having a single decision tree, we have several trees working in unison, each tree in the forest makes a prediction and, just like in Congress, the votes are tallied. The most voted prediction is the model result. It’s machine learning reinforced by the power of democracy.

Random Forest works because each individual tree has little or no correlation with other trees; what one tree predicts is not linked to what the other trees predict. In human terms, we could say that everyone has different points of view, which in turn ensures that there is no systematic bias.

This algorithm is an elegant solution for making predictions in highly volatile systems and for working with complex problems that can have an almost infinite amount of data points. In other words, the kind of problems we constantly face in finance.

Random forests in finance

Research has shown that random forests outperform almost all other forms of forecasting relating to stock prices, qualitative analysis of stocks and option pricing, and credit spreads . There are two things to note here.

First, there is the fact that traditional forecasting tools rely on linear regressions, which is an extremely powerful algorithm, but only when the relationships you are studying are linear in nature (in other words, no matter how many variables A change , Variable B will continue to change together).

Real-life relationships are often more complex than this, for example human height and weight. There is a linear relationship there (taller people tend to weigh more), but this is true to a point. After that, weight may increase while height stagnates.

What this means is that a linear regression model for predicting height from weight will only work up to a point. Something similar happens with stock prices, although some values ​​predict an increase in stock prices, within certain limits these relationships change.

The other point is that Random Forests forces scientists to redefine their problems in terms of classification analysis. Instead of framing the problem as “If X increases, then how much will Y increase”, we ask “will the value of X change?” This may not seem like much, but you'd be surprised at how even a small rephrase can change our perception of the problem.

With the right data, random forests can help us assess whether a small change in a local market could have huge ramifications on the global economy. And thanks to IoT, AI, cloud computing and data mining technologies, collecting and processing financial data has never been easier.

To be fair, Random Forests are not perfect, like any other algorithm, the model is only as good as the data you train it with. It is a well-known fact that Random Forests are extremely susceptible to small biases. Feed it bad data and you end up with an unreliable model.

Random Forests will not revolutionize the financial world, but they are certainly a powerful tool that can be applied to a multitude of problems, providing new ways of framing issues and predicting market behavior.

Source: BairesDev

Back to the blog

Leave a comment

Comments need to be approved before publication.