Decision Tree (ID3) Calculator

Read the Theory Guide →

Enter a dataset with categorical features and a two-class label, then build the ID3 tree. The solver shows the entropy and Information Gain behind each split and draws the resulting tree.

What You Can Explore

  • Edit the dataset by changing feature values, class labels, and the rows or features it contains.
  • Build the tree and read the resulting flowchart from the root split down to its class leaves.
  • Follow each iteration's entropy, subset tables, weighted entropy, and Information Gain for the available features.
  • Check the filtered data in later iterations to see exactly which rows reached each branch.
Core Mechanics
▼
  • Entropy Measures the Mess: It quantifies how "mixed up" your data is. A perfectly pure group has an entropy of 00. A 50/50 split is a total mess with an entropy of 11. Lower is always cleaner!
  • Maximize Information Gain: Information Gain (IG) is simply the drop in entropy after a split. At every step, calculate the IG for all remaining features and greedily pick the one that cleans up the data the most.
  • One and Done (No Re-use): Once you split on a feature, cross it off the list for that specific branch. You can never split on the exact same feature twice down the same path.
  • The Stopping Conditions: Stop growing a branch when all remaining examples belong to the exact same class (a pure leaf), or when you completely run out of features to test.
Initializing Workspace...

Understanding Your Result

The tree and calculations are generated from the dataset you entered, not from a fixed example. Each iteration shows how the current subset is evaluated, which feature produces the highest Information Gain, and how that choice becomes the next split.

  • The feature with the highest Information Gain in an iteration is selected as the split for that subset. Compare the listed gains to see why the selected feature was chosen.
  • Each iteration corresponds to a branch that still needs to be split. The Context line identifies that branch, and later iterations show only the rows that reached it.
  • In the Resulting Split preview, a branch with a class label is already pure. A branch marked with a question mark contains mixed classes and is evaluated in a later iteration.
  • An Information Gain of 0 means the feature does not reduce the class uncertainty in the current subset. Compare the gains to see which features actually help separate the classes.

Try These Experiments

Flip One Class Label

Setup: Build the tree from the preloaded dataset, where Age is the root and the Old branch ends directly at the Down class.

Action: Change the class label of the Old, Software, Yes row from Down to Up, then build the tree again.

What to Observe: The Old branch is no longer pure, so it requires another split. Its next iteration evaluates the remaining features, while Age's Information Gain at the root falls from 0.6 to 0.295.

Takeaway: Changing a single class label can turn a pure branch into a mixed subset that needs another split. It can also change the Information Gain of features at the root, which can affect the shape of the resulting tree.

Make Competition Separate the Classes

Setup: Build the preloaded tree first. Age is selected at the root, while the Mid branch requires another iteration.

Action: Change Competition to Yes in the two Old rows where it is currently No, and change Competition to No in the New, Software, Yes row. Then rebuild the tree.

What to Observe: Competition now separates the two classes perfectly. Iteration 1 selects Competition instead of Age, and the resulting tree ends with two pure class branches.

Takeaway: Changing feature values can change which feature provides the most useful split. When one feature separates the classes completely, the resulting tree can become much simpler.

Create an Information Gain Tie

Setup: Build the preloaded tree and move to the Mid branch, where Competition currently provides the best split.

Action: Change Type to Software in the Mid, Hardware, Yes, Down row and to Hardware in the Mid, Software, No, Up row. Then rebuild the tree.

What to Observe: In the Mid iteration, Type and Competition now produce the same Information Gain. The solver selects one of the tied features, and its resulting branches are pure.

Takeaway: Different features can provide equally useful splits on the same subset. When a tie occurs, the selected feature can change the shape of the tree even though the resulting class assignments remain the same.