Information Gain Calculator

Information gain is how much a split reduces impurity: the parent node’s entropy minus the size-weighted entropy of its children. Larger is a better split.

Also called: Gain ratio calculator · Decision tree split calculator

  • Last updated
  • Formula tested against reference values

Your numbers

One line per child; the same classes in the same order on every line. The parent is the sum.

Impurity measure

Result

Information gain
—

Calculating…

Parent impurity
—
Weighted child impurity
—
Split information (bits)
—
Gain ratio
—
Parent class counts
—
Full table

How to use this calculator

  1. Enter or choose class counts in each child node.
  2. Enter or choose impurity measure.
  3. The information gain updates as you type. Use Copy result or Share to keep it.

Method

IG = I(parent) − Σ (n_j ÷ n) I(child_j); SplitInfo = −Σ (n_j ÷ n) log₂(n_j ÷ n); GainRatio = IG ÷ SplitInfo

I
impurity: entropy in bits or Gini
n_j
items in child j
n
items in the parent

Worked example

  1. Parent = 9 yes, 5 no: H = 0.940286 bits.
  2. Children: H(2,3) = H(3,2) = 0.970951 and H(4,0) = 0, so weighted = 2 × (5/14) × 0.970951 = 0.693536.
  3. IG = 0.940286 − 0.693536 = 0.24675; split info = 1.577406, gain ratio = 0.156428.

Splitting the classic play-tennis data on Outlook gains 0.247 bits, matching the textbook value of 0.246.

What the result means

Compare candidate splits on the same parent: the highest gain wins. Gain ratio divides by split information to stop attributes with many distinct values (such as IDs) from looking best.

Assumptions and limits

  • Each item falls in exactly one child node.
  • For numeric attributes, you choose the threshold; the calculator scores one split at a time.

Questions

Why can information gain mislead?

Splitting on a unique ID gives every child a pure node and maximum gain, yet predicts nothing. Gain ratio corrects for this.

Is Gini gain the same as information gain?

It is the same idea with Gini impurity in place of entropy, as used by CART.