VIEW THIS AS

Auto mode follows the Route Engine until you choose a viewpoint.

YOU ARE HERE

ROUTE CHECK

CONNECTED TO

WHAT NEXT

Use the canonical route for this room, or HELP if you are unsure.

How Artificial Intelligence AI Works | How Decision Trees and Random Forests Make Predictions

Did you know? Not every AI model is a giant neural network. Some make predictions by asking a sequence of simple questions: “Is it a weekend?” “Is an event scheduled?” “Was yesterday busy?” The answers lead through branches to a result.

This is the idea behind a decision tree. And when many different trees contribute to a prediction, the method may be a random forest. These are important machine-learning tools, especially for tasks involving rows and columns of structured data.

Quick answer: a decision tree learns useful splitting questions from training examples and routes a new example down the resulting branches. A random forest trains multiple varied trees and combines their predictions to reduce some of the instability of any one tree.

The 30-second explanation

  • Feature: information used for a prediction, such as day of week or rainfall.
  • Split: a question that partitions examples into smaller groups.
  • Root: the first decision point in a tree.
  • Leaf: the terminal node containing a prediction.
  • Overfitting: learning narrow training quirks that fail on new examples.
  • Random forest: an ensemble of trees built with randomness in examples or feature selection.

The word tree describes its branching structure. The word forest describes several trees considered together; it does not mean the data must be about plants or the environment.

Start with a fictional community library

Imagine a made-up community library wants to predict whether tomorrow afternoon will be busy or quiet. For this illustration, the staff define busy as at least 50 visits in an afternoon. The historical table contains day type, whether an event was scheduled and recorded visitor counts.

A small decision tree could learn a toy rule: if a community event is scheduled, predict busy; otherwise, if it is a weekend, predict busy; otherwise, predict quiet. That rule is illustrative, not an empirical finding about real libraries.

A new Monday without an event follows two branches—no event, not a weekend—and reaches a quiet leaf. The tree has made a prediction by applying its learned conditions, not by looking into the future.

Step 1: Define an output you can actually check

The library needs a precise target. The broad question “Will people enjoy tomorrow?” is difficult to label consistently. “Will there be 50 or more recorded visits from noon to closing?” is much clearer.

Even that target depends on reliable counting and consistent opening hours. If one day had a broken visitor counter, the label may be wrong. Training data quality matters just as much as the choice of algorithm.

Decision trees can learn either classification categories—busy or quiet—or numerical predictions, such as an estimated number of visits. Those two tasks require different target definitions and evaluation measures.

Step 2: Learn useful questions from data

During training, an algorithm considers candidate splits. It searches for questions that separate examples into groups that are more consistent in their outcomes according to a chosen criterion.

For classification, a common criterion measures how mixed the labels are, such as Gini impurity or entropy. A useful split may place most busy afternoons in one branch and most quiet afternoons in another.

The algorithm repeats the splitting process for smaller groups until a stopping rule is met. This learning process is different from a programmer personally writing every branch.

Why splitting can help: a small counting example

Suppose a fictional training group contains eight afternoons: four busy and four quiet. The class proportions are 0.5 and 0.5. For Gini impurity, calculate 1 − (0.5² + 0.5²) = 0.50.

Now imagine a candidate split creates two groups of four afternoons. The first has three busy and one quiet; the second has one busy and three quiet. Each group’s Gini impurity is 1 − (0.75² + 0.25²) = 0.375.

The weighted impurity after this balanced split is 0.375, lower than 0.50. In this illustration, the split improves class separation, though the algorithm should compare other possible splits before choosing.

These invented values teach the calculation. They do not show that a particular split will work on a real library’s future visitors.

Step 3: Follow the branches to make a prediction

Once trained, the tree evaluates the relevant questions for a new example. It begins at the root, follows one branch, evaluates another question where applicable and ends at a leaf.

For a classification tree, the leaf can contain class proportions from the training examples reaching it. The application may select the most common class or use the proportions as scores. Those scores should not be assumed perfectly calibrated probabilities.

For regression, a leaf may contain a numerical estimate based on its training examples. In either case, the output is a learned estimate, not a confirmed future event.

Step 4: Why one tree can become too specific

A tree with many deep branches can memorise peculiar examples. Perhaps every recorded busy Tuesday happened during a particular month, so the model builds an elaborate rule around that accident.

On new days, such a rule may be unreliable. This is overfitting. Developers can limit tree depth, require enough examples before making a split or use other stopping and pruning strategies.

Simpler trees can be easier to inspect, but simplicity alone does not guarantee correctness. They still need realistic testing with appropriate train-and-test boundaries.

Step 5: Build several different trees

A random forest creates multiple decision trees with controlled variation. Typical implementations draw different bootstrap samples of training examples and consider randomly selected subsets of features when building splits.

Imagine three fictional trees predicting whether a library afternoon will be busy. One predicts busy; two predict quiet. A majority-vote explanation gives quiet as the combined class. Real implementations may instead average class-probability estimates before selecting a label, so the exact procedure depends on the software.

The point is that the forest is not forced to follow one fragile set of branches. If individual tree errors differ, combining predictions can reduce variance and improve generalisation.

A forest can be more stable than one tree, but more trees are not proof that the underlying data or labels are good.

Step 6: Know what a random forest cannot fix

Suppose all the historical library data were recorded on school days. A random forest could contain hundreds of diverse trees yet still have little evidence about public-holiday demand.

Similarly, if every tree uses an incorrect target or a leaked future feature, averaging their predictions does not restore reliability. The method can reduce one source of instability but cannot guarantee fairness, accurate labels or valid evaluation.

Complexity also matters. A large forest may be less straightforward to interpret than one shallow decision tree, even though individual trees are readable.

Step 7: Test the model on the real task

A useful comparison includes a simple baseline, one decision tree and a random forest trained from the same appropriate development information. Evaluate on genuinely separate cases that resemble the intended future workload.

For forecasting future library demand, test with later chronological periods rather than randomly allowing later information into earlier predictions. For predicting a known class, examine precision, recall and error patterns when relevant.

If a forest improves average accuracy but fails on holidays, the result is incomplete. A system should examine the slices of performance that matter to the people who will use it.

Do tree questions explain why something happened?

A decision path can reveal which feature values caused the model to choose a particular leaf. This is useful transparency: you can inspect the software’s rule.

However, that is not proof that the features caused the real-world event. The model might associate weekends with library attendance without establishing what made an individual decide to visit.

Likewise, feature-importance scores from tree ensembles describe aspects of predictive behaviour under the chosen calculation; they should not be treated automatically as causal effects.

Try it: draw your own decision tree

Draw a fictional reading-club rule. At the top write, “Is the event scheduled?” If yes, lead to “likely busy.” If no, ask, “Is it the weekend?” Route yes to “likely busy” and no to “likely quiet.”

Now invent six days with observed attendance and check how the simple tree performs. Which examples does it miss? What if a Saturday event is cancelled? Do not add special-case branches until you have evidence.

You have demonstrated a tree’s branching logic, though a real trained tree chooses splits by optimising a criterion over data rather than by copying your hand-written rule.

Frequently asked questions

Is a decision tree considered artificial intelligence?

It is a common machine-learning method, and machine learning is part of the broader AI field. Not all AI uses deep neural networks.

What is the difference between a tree and a random forest?

A tree makes predictions through one hierarchy of splits. A random forest combines predictions from many varied trees.

Why add randomness to a forest?

It encourages trees to differ so that averaging or voting can reduce some unstable, correlated errors.

Are random forests always better than neural networks?

No. Suitability depends on the task, data type, constraints and independent evaluation.

Can a decision tree prove causation?

No. Its splits reveal learned predictive associations, not automatically why something happens in the world.

Your one-minute takeaway

  • Decision trees learn branching questions and make predictions at their leaves.
  • Random forests combine varied trees, often improving stability on structured data.
  • Reliable predictions still require sound labels, leakage-free tests and careful interpretation.

Trusted guides and related AI chapters

Discover more from eduKate Singapore

Subscribe now to keep reading and get access to the full archive.

Continue reading