Entropy Decision Tree Calculator

This entropy calculator for decision trees works out the entropy of a node and the information gain of a split from your class counts.

One count per class, separated by commas.

Same classes in the same order. Each class must add up to the parent count.

Checks on your data

  • Few samples, so the entropy estimates are noisy and a tree may overfit.
  • Information gain favours splits with many small branches. The gain ratio corrects for this.
  • Compare the gain of several candidate splits and choose the largest. That is how the ID3 algorithm builds a tree. Open the entropy calculator →

Results

Entropy of the parent node
0.940286
in bits
Weighted entropy of the children
0.892159
Information gain
0.048127
parent entropy minus weighted child entropy
Gain ratio
0.0488486
Split information
0.985228
Gini impurity: parent → children
0.45918 → 0.42857
Gini gain 0.030612
Total samples
14
Entropy of the parent and each child node (bits)
00.51Parent: 0.940286Parent0.94Child 1: 0.811278Child 10.811Child 2: 1Child 21
Node summary
NodeClass countsSamplesEntropyGini
Parent9, 5140.940290.45918
Child 16, 280.811280.375
Child 23, 3610.5
Show step-by-step solution
  1. Parent counts 9, 5 give entropy H = −Σ p·log₂ p = 0.940286 bits.
  2. Child 1 (6, 2; 8 samples): H = 0.811278, weight 8/14 = 0.5714.
  3. Child 2 (3, 3; 6 samples): H = 1, weight 6/14 = 0.4286.
  4. Weighted child entropy = 0.892159.
  5. Information gain = 0.940286 − 0.892159 = 0.048127 bits.
EntropyH = −Σ p log₂ p
Information gainH(parent) − Σ (nᵢ/N) H(childᵢ)
Pure nodeEntropy 0

What Is Entropy Calculator for Decision Trees?

A decision tree picks each split to make the child nodes as pure as possible. Entropy measures how mixed a node is, and information gain is the drop in entropy from the parent to the weighted average of its children.

Enter the class counts at the parent node, then one line of class counts for each child. The calculator returns the parent and child entropies, the information gain, the gain ratio, the split information and the Gini impurity before and after the split, with a table for each node.

Compare several candidate splits and choose the one with the largest gain. That is how the ID3 algorithm grows a tree, and the gain ratio in C4.5 corrects the bias toward splits with many branches.

How to Use the Entropy Calculator for Decision Trees Calculator

  1. Enter the class counts at the parent node.
  2. Enter the class counts for each child, one line per child.
  3. Compare information gain, gain ratio and Gini between candidate splits.

Entropy Calculator for Decision Trees Formula

Entropy

H=−∑ipilog⁡2piH=-\sum_i p_i\log_2 p_i

Information gain

IG=H(parent)−∑jnjNH(childj)IG=H(\text{parent})-\sum_j\frac{n_j}{N}H(\text{child}_j)

Gini impurity

G=1−∑ipi2G=1-\sum_i p_i^2

Entropy Calculator for Decision Trees Variables Explained

SymbolMeaningNotes
HEntropy in bits0 means a pure node
pᵢProportion of class i at the node
IGInformation gain of a splitParent entropy minus weighted child entropy
GiniGini impurity, 1 − Σp²

Entropy Calculator for Decision Trees Worked Example

With the example values loaded in the calculator above, the steps are:

  1. Parent counts 9, 5 give entropy H = −Σ p·log₂ p = 0.940286 bits.
  2. Child 1 (6, 2; 8 samples): H = 0.811278, weight 8/14 = 0.5714.
  3. Child 2 (3, 3; 6 samples): H = 1, weight 6/14 = 0.4286.
  4. Weighted child entropy = 0.892159.
  5. Information gain = 0.940286 − 0.892159 = 0.048127 bits.

Result: Entropy of the parent node = 0.940286; Weighted entropy of the children = 0.892159; Information gain = 0.048127.

Worked example: 9 yes and 5 no, split into (6, 2) and (3, 3)

Parent entropy = −(9/14)log₂(9/14) − (5/14)log₂(5/14) = 0.9403 bits. Child 1 has entropy 0.8113 and child 2 has entropy 1.0.

Weighted child entropy = (8/14) × 0.8113 + (6/14) × 1.0 = 0.8922. Information gain = 0.9403 − 0.8922 = 0.0481 bits.

Entropy versus Gini

Both measure impurity and usually choose the same split. Entropy uses logarithms and has a maximum of 1 bit for two equal classes. Gini is quicker to compute and has a maximum of 0.5 for two classes.

Where Entropy Calculator for Decision Trees Is Used

Machine learning coursework

Check ID3 and C4.5 split calculations by hand.

Choosing a split

Compare candidate attributes by information gain.

Understanding impurity

See how entropy and Gini rank the same split.

Common Entropy Calculator for Decision Trees Mistakes to Avoid

  • A pure node, with only one class, has entropy 0.
  • Use the same order of classes in the parent and every child.

Entropy Calculator for Decision Trees Terms and Definitions

Information gain
The reduction in entropy achieved by a split.
Gain ratio
Information gain divided by the split information, which penalises splits with many branches.

Entropy Calculator for Decision Trees FAQs

How do you calculate entropy for a decision tree?

Compute −Σ p·log₂ p over the class proportions at the node.

What is information gain?

The parent entropy minus the weighted average entropy of the child nodes after a split.

What entropy value means a pure node?

0, when every sample belongs to one class.

What is the maximum entropy for two classes?

1 bit, when the classes are equally likely.

Which is better, entropy or Gini?

They usually pick the same splits. Gini is slightly faster; entropy is the basis of ID3 and C4.5.

Why use gain ratio?

Plain information gain favours attributes with many values. Gain ratio divides by split information to reduce that bias.

Related calculators

Last updated 2026-11-09. See our disclaimer.