Random forest
Supervised · Classification & regression A random forest builds hundreds of decision trees, each trained on a slightly different random sample of the data and features. For a new case, every tree gives its answer and the forest takes a vote (or an average, for numbers). Many imperfect trees together make a strong, stable prediction.
Everyday analogy
Asking 100 friends for a restaurant recommendation instead of trusting one. Individual opinions vary, but the crowd's favourite is usually a safe bet.
Example
Used for: card fraud detection, credit risk, medical diagnosis support, crop yield prediction, predicting equipment failure.
Many trees, one vote
How it works, step by step
- Make many random samples of the training data. Each sample picks rows at random, with repeats allowed (called bootstrapping).
- Train one decision tree on each sample. At every split, each tree only looks at a random subset of features, so the trees end up different from each other.
- For a new case, ask every tree for its answer.
- Classification: the majority vote wins. Regression: average the trees' numbers.
- The share of votes also works as a confidence score, for example 83%.
Worked example
A bank's forest has 100 trees. For a suspicious payment, 83 trees vote "fraud" and 17 vote "genuine". The payment is held and the customer gets an alert to confirm it. One tree alone might have been fooled; 100 rarely are.
✓ Good for
- Usually much more accurate and stable than one tree
- Handles messy data, missing values and many features well
- Shows which features matter most (feature importance)
⚠ Watch out for
- Slower and uses more memory than a single tree
- Harder to explain one individual decision
- Not ideal for very large text or image data, where neural networks do better
Try it yourself
About 10 minAsk a crowd
- Ask 5 friends (or 5 new chats) to guess a number, e.g. a jar of sweets or a city's population.
- Average the guesses.
- Compare the average with the individual guesses.
What you should see: Many average guesses combined are often better than one. That's the idea behind a random forest.
Use any free AI chatbot (ChatGPT, Claude, Gemini or Copilot). Never paste private or confidential information.