Entropy and Information Gain

Imagine building a decision tree to classify emails as spam or not spam. At every step you face the same question: which feature should I test next? And where should I split it? A tree that greedily picks bad splits wastes depth. It also generalizes poorly. One that picks splits which sharply separate classes can achieve near-perfect classification in a handful of levels. The mathematical tool that quantifies "how good is this split" is information gain. It is built on top of entropy, a measure of uncertainty borrowed directly from Claude Shannon's information theory. This idea matters far beyond toy examples. The Decision Trees and Recursive Partitioning algorithms power gradient-boosted models like XGBoost and LightGBM. They also power random forests in production fraud-detection systems, and even medical diagnosis trees. All of these rely on a split-selection criterion at their core. Entropy-based information gain (used in ID3 and C4.5) and Gini impurity (used in CART) are the two dominant choices. Understanding their mathematical relationship — and their subtle differences — explains why certain trees behave the way they do. The big picture is this: a decision tree recursively partitions the feature space. It creates regions that are as "pure" as possible with respect to the target label. Purity needs a numeric score. Entropy (from thermodynamics and information theory) turns out to be a natural way to measure impurity. It is axiomatically justified for a set of labeled examples. Information gain then measures how much a candidate split reduces that impurity. It converts an abstract statistical quantity into a concrete, greedy search heuristic. This article defines entropy and Gini impurity precisely. It derives information gain step by step, and gives working pseudocode for a split-selection routine. It proves why greedy maximization of information gain is a sound (if imperfect) heuristic. It also traces a full worked example by hand. Finally, it flags the classic pitfalls that every practitioner must know before trusting a tree. These include the notorious bias toward high-cardinality features.

Key takeaways
  • Entropy H(Y)=−∑kpklog⁡2pkH(Y) = -\sum_k p_k \log_2 p_k measures the uncertainty (impurity) of a label distribution in bits.
  • Information gain is the reduction in entropy achieved by splitting a dataset on a feature: IG=H(parent)−H(children, weighted)IG = H(\text{parent}) - H(\text{children, weighted}).
  • Gini impurity G=1−∑kpk2G = 1 - \sum_k p_k^2 is a computationally cheaper, differentiable-flavored alternative that behaves similarly to entropy.
  • Split selection is greedy: at each node pick the feature/threshold maximizing information gain (or minimizing weighted impurity), not a globally optimal tree.
  • Raw information gain is biased toward high-cardinality splits; the gain ratio (C4.5) corrects this by normalizing by the split's own entropy.
  • These criteria feed directly into Tree Pruning and Complexity Control, since greedy purity-maximizing splits tend to overfit without a stopping/pruning mechanism.
The core insight

Information gain measures how much a split shrinks the uncertainty in class labels, and greedily maximizing it is how decision trees decide what to ask next.

The idea

Entropy is a measure of the average uncertainty, or "surprise," in a random variable's distribution. For a discrete label YY taking values in {1,…,K}\{1, \dots, K\} with probabilities p1,…,pKp_1, \dots, p_K (estimated from class frequencies in a dataset SS), the Shannon entropy is

H(S)=−∑k=1Kpklog⁡2pk,H(S) = -\sum_{k=1}^{K} p_k \log_2 p_k,

with the convention 0log⁡20=00 \log_2 0 = 0. Entropy is measured in bits when using log⁡2\log_2. It is exactly 00 when one class has probability 11 (perfectly pure, no uncertainty) and it is maximized at log⁡2K\log_2 K when all classes are equally likely (maximum uncertainty). For binary classification (K=2K=2), H(S)∈[0,1]H(S) \in [0, 1], peaking at p=0.5p=0.5.

Information gain (IG) measures how much splitting a dataset SS on a feature (or feature/threshold pair) AA reduces this uncertainty. If the split partitions SS into subsets S1,…,SmS_1, \dots, S_m (e.g., m=2m=2 for a binary threshold split, or m=∣values(A)∣m = |\text{values}(A)| for a categorical split), then

IG(S,A)=H(S)−∑j=1m∣Sj∣∣S∣H(Sj).IG(S, A) = H(S) - \sum_{j=1}^{m} \frac{|S_j|}{|S|} H(S_j).

The second term is the weighted average entropy of the children, sometimes called the conditional entropy H(Y∣A)H(Y \mid A). Information gain is therefore literally the mutual information between the label YY and the split variable AA: IG(S,A)=H(Y)−H(Y∣A)=I(Y;A)≥0IG(S,A) = H(Y) - H(Y\mid A) = I(Y; A) \ge 0, with equality only when AA is independent of YY within SS. Non-negativity of information gain is not an accident — it follows from the concavity of the entropy function (Jensen's inequality), so a split can never increase expected uncertainty about YY on average.

Gini impurity is an alternative impurity measure used by CART:

G(S)=∑k=1Kpk(1−pk)=1−∑k=1Kpk2.G(S) = \sum_{k=1}^K p_k (1-p_k) = 1 - \sum_{k=1}^K p_k^2.

It can be interpreted as the expected error rate if you labeled a randomly drawn example from SS according to the label distribution itself (i.e., predicting class kk with probability pkp_k and being wrong with probability 1−pk1-p_k). Like entropy, Gini impurity is 00 for a pure node and maximized when classes are balanced. The corresponding split-quality score, the Gini gain, is defined analogously to information gain:

ΔG(S,A)=G(S)−∑j=1m∣Sj∣∣S∣G(Sj).\Delta G(S,A) = G(S) - \sum_{j=1}^m \frac{|S_j|}{|S|} G(S_j).

Both entropy and Gini are special cases of a broader family of impurity functions — concave functions of pp that vanish at the vertices of the probability simplex (pk=1p_k=1 for some kk) and peak at the uniform distribution. This shared shape is exactly why they tend to prefer similar splits in practice, even though their numeric values and derivatives differ.

How it works

Building a tree with an impurity-based criterion is a greedy, recursive procedure. At each node, the algorithm searches over all candidate features and (for continuous features) all candidate thresholds, computes the information gain (or Gini gain) for each candidate split, and commits to the single best one — without ever reconsidering that choice later. This is what makes tree induction fast: it never explores the combinatorially many possible trees, only a sequence of locally optimal decisions. ```text function ENTROPY(S):

# S: multiset of class labels n = |S| if n == 0: return 0 H = 0 for each class k present in S: p_k = count(S, k) / n H -= p_k log2(p_k) return H function GINI(S): n = |S| if n == 0: return 0 G = 1 for each class k present in S: p_k = count(S, k) / n G -= p_k p_k return G function BEST_SPLIT(S, features, criterion=ENTROPY): H_parent = criterion(S) best_gain = -infinity best_split = None for A in features: candidate_thresholds = CANDIDATE_THRESHOLDS(S, A) for t in candidate_thresholds: S_left = { x in S : x[A] <= t } S_right = { x in S : x[A] > t } if |S_left| == 0 or |S_right| == 0: continue # degenerate split, skip weighted = (|S_left| / |S|) criterion(S_left) + (|S_right| / |S|) criterion(S_right) gain = H_parent - weighted if gain > best_gain: best_gain = gain best_split = (A, t, S_left, S_right) return best_split, best_gain function BUILD_TREE(S, features, max_depth, depth=0): if ENTROPY(S) == 0 or depth == max_depth or |features| == 0: return LEAF(majority_class(S)) # base case: pure or exhausted split, gain = BEST_SPLIT(S, features) if split == None or gain <= 0: return LEAF(majority_class(S)) # no useful split found (A, t, S_left, S_right) = split left_child = BUILD_TREE(S_left, features, max_depth, depth+1) right_child = BUILD_TREE(S_right, features, max_depth, depth+1) return NODE(test = (A <= t), left_child, right_child) ``` `CANDIDATE_THRESHOLDS` sorts the distinct values of feature AA observed in SS and considers midpoints between consecutive distinct values where the class label changes — a standard optimization, since the impurity can only improve at a boundary between differently-labeled adjacent points, so it never helps to place a threshold strictly inside a run of same-label points. For a categorical feature, either every subset of categories is tried (small cardinality) or, more commonly, a per-value one-vs-rest split is used. The recursion terminates because each recursive call operates on a strictly smaller subset (`S_left` and `S_right` are proper, non-empty subsets of `S` whenever a split is accepted), and depth is capped, so the tree has finite depth and every branch reaches a base case.

Figure
Entropy along one split: parent node splits into two children with reduced weighted entropy
Parent S 8+ / 8− H(S) = 1.00 bit Feature A ≤ t Feature A > t Left: S_left 7+ / 1− (n=8) H = 0.544 bits Right: S_right 1+ / 7− (n=8) H = 0.544 bits Weighted child entropy 0.5(0.544) + 0.5(0.544) = 0.544 bits IG = 1.00 − 0.544 = 0.456 bits

Complexity & correctness

Time complexity. Let n=∣S∣n = |S| be the number of examples at a node and dd the number of features. Computing entropy or Gini for one candidate split requires a pass over class counts, which can be maintained incrementally: sort the nn values of a continuous feature once (O(nlog⁡n)O(n \log n)), then sweep left-to-right, updating running class counts in O(1)O(1) per boundary and recomputing the two impurities in O(K)O(K) per threshold, where KK is the number of classes. This gives O(nlog⁡n+nK)O(n \log n + nK) per feature per node, so O(d⋅nlog⁡n)O(d \cdot n \log n) per node when sorting dominates (typical for K≪nK \ll n). Across a full tree of depth DD, since the total number of examples summed across all nodes at one depth level is O(n)O(n) (each example lives in exactly one node per level), the total cost is

O(D⋅d⋅nlog⁡n)O(D \cdot d \cdot n \log n)

in the (common) balanced case, and O(n⋅d⋅nlog⁡n)=O(d n2log⁡n)O(n \cdot d \cdot n \log n) = O(d\, n^2 \log n) in the worst case of a maximally unbalanced tree with D=O(n)D = O(n). Sorting can be done once per feature at the root and maintained via indices during partitioning, avoiding repeated full sorts — a standard implementation optimization in libraries like scikit-learn and CART, bringing the typical practical cost close to O(d nlog⁡n)O(d\, n \log n) total amortized in balanced trees. Space complexity is O(n)O(n) per feature to hold sorted indices, plus O(K)O(K) for running counts, so O(nd)O(nd) overall for a naive implementation, or O(n)O(n) if features are processed one at a time and released.

Correctness of the greedy criterion. There is no claim that maximizing information gain at each node yields the globally optimal decision tree (finding the optimal tree of bounded size is NP-hard in general). What can be proven is narrower and more useful: information gain is a sound local measure of split quality, in the sense that 1. IG(S,A)≥0IG(S,A) \ge 0 always. Proof sketch: entropy is a strictly concave function of the probability vector pp. By Jensen's inequality, for any partition of SS into S1,…,SmS_1,\dots,S_m with weights wj=∣Sj∣/∣S∣w_j = |S_j|/|S| and label distributions p(j)p^{(j)} satisfying p=∑jwjp(j)p = \sum_j w_j p^{(j)} (law of total probability),

H(S)=H(∑jwjp(j))≥∑jwjH(p(j))=∑jwjH(Sj),H(S) = H\left(\sum_j w_j p^{(j)}\right) \ge \sum_j w_j H(p^{(j)}) = \sum_j w_j H(S_j),

which rearranges to IG(S,A)=H(S)−∑jwjH(Sj)≥0IG(S,A) = H(S) - \sum_j w_j H(S_j) \ge 0. So splitting can never increase expected uncertainty about YY — a split is informative or, at worst, neutral, never harmful in expectation. 2. IG(S,A)=0IG(S,A) = 0 if and only if AA is (empirically) independent of YY within SS — that is, the class distribution is identical in every child. This matches intuition: a split that doesn't change the label distribution anywhere provides no information. 3. Gini gain satisfies the same two properties, by the identical Jensen's-inequality argument applied to the concave function G(p)=1−∑kpk2G(p) = 1 - \sum_k p_k^2. So the greedy algorithm is correct in the sense that it always makes locally non-harmful, information-theoretically justified choices, and it is a standard, well-studied heuristic for the (NP-hard) combinatorial problem of finding a small, accurate tree — analogous to how greedy heuristics are used for other NP-hard problems where exhaustive search is infeasible. The tradeoff is that greediness with no lookahead can miss splits that only pay off two levels down (the classic XOR problem: neither single feature reduces impurity alone, but their combination perfectly separates the classes). This limitation, and the tendency of unconstrained greedy growth to overfit training noise, motivates the pruning and depth-control techniques covered in Tree Pruning and Complexity Control.

Entropy vs. Gini — a practical note. Both are concave, both vanish at pure nodes, both peak at the uniform distribution — but they are not identical curves. For binary classification with pp the probability of the positive class:

H(p)=−plog⁡2p−(1−p)log⁡2(1−p),G(p)=2p(1−p).H(p) = -p\log_2 p - (1-p)\log_2(1-p), \qquad G(p) = 2p(1-p).

Entropy is somewhat more sensitive near the extremes (it penalizes small impurities more sharply due to the logarithm), while Gini is computationally cheaper (no logarithms) and is what CART uses by default. Empirically, trees built with either criterion tend to agree on splits over 90% of the time in practice; disagreements are rare and rarely matter for final accuracy, though entropy-based gain has the additional bias problem addressed by gain ratio, discussed below.

Worked example

Consider a tiny "Play Tennis" dataset with 14 examples and a binary label (Play = Yes/No), split on the categorical feature Outlook with values Sunny, Overcast, Rain.

OutlookYesNoTotal
Sunny235
Overcast404
Rain325
All (parent)9514

Step 1 — Parent entropy.

pyes=9/14=0.643,pno=5/14=0.357p_{yes} = 9/14 = 0.643, \quad p_{no} = 5/14 = 0.357
H(S)=−0.643log⁡20.643−0.357log⁡20.357=0.940 bitsH(S) = -0.643\log_2 0.643 - 0.357\log_2 0.357 = 0.940 \text{ bits}

Step 2 — Entropy of each child. Sunny (2 Yes, 3 No; p=0.4,0.6p=0.4, 0.6):

H(Sunny)=−0.4log⁡20.4−0.6log⁡20.6=0.971 bitsH(\text{Sunny}) = -0.4\log_2 0.4 - 0.6\log_2 0.6 = 0.971 \text{ bits}

Overcast (4 Yes, 0 No; pure):

H(Overcast)=0 bitsH(\text{Overcast}) = 0 \text{ bits}

Rain (3 Yes, 2 No; p=0.6,0.4p=0.6, 0.4):

H(Rain)=−0.6log⁡20.6−0.4log⁡20.4=0.971 bitsH(\text{Rain}) = -0.6\log_2 0.6 - 0.4\log_2 0.4 = 0.971 \text{ bits}

Step 3 — Weighted child entropy.

H(S∣Outlook)=514(0.971)+414(0)+514(0.971)=0.694 bitsH(S \mid \text{Outlook}) = \frac{5}{14}(0.971) + \frac{4}{14}(0) + \frac{5}{14}(0.971) = 0.694 \text{ bits}

Step 4 — Information gain.

IG(S,Outlook)=0.940−0.694=0.246 bitsIG(S, \text{Outlook}) = 0.940 - 0.694 = 0.246 \text{ bits}

Step 5 — Compare against another candidate feature, say Wind (Weak/Strong):

WindYesNoTotal
Weak628
Strong336
H(Weak)=−0.75log⁡20.75−0.25log⁡20.25=0.811,H(Strong)=1.0H(\text{Weak}) = -0.75\log_2 0.75 - 0.25\log_2 0.25 = 0.811, \quad H(\text{Strong}) = 1.0
H(S∣Wind)=814(0.811)+614(1.0)=0.892H(S\mid \text{Wind}) = \frac{8}{14}(0.811) + \frac{6}{14}(1.0) = 0.892
IG(S,Wind)=0.940−0.892=0.048 bitsIG(S,\text{Wind}) = 0.940 - 0.892 = 0.048 \text{ bits}

Since 0.246>0.0480.246 > 0.048, the algorithm chooses Outlook as the root split, because it produces far more purity reduction — the Overcast branch becomes an immediate pure leaf (all "Yes"), while Wind leaves both children substantially mixed. This matches the classic ID3 worked trace and illustrates exactly why greedy IG-maximization is a reasonable, checkable procedure: at every candidate, you can hand-verify the arithmetic and confirm the algorithm's choice is the one that locally destroys the most uncertainty.

Gini cross-check. Using Gini impurity instead: G(S)=1−(0.6432+0.3572)=0.459G(S) = 1 - (0.643^2 + 0.357^2) = 0.459. For Outlook, G(Sunny)=1−(0.42+0.62)=0.48G(\text{Sunny}) = 1-(0.4^2+0.6^2) = 0.48, G(Overcast)=0G(\text{Overcast}) = 0, G(Rain)=0.48G(\text{Rain}) = 0.48, giving weighted Gini =514(0.48)+0+514(0.48)=0.343= \frac{5}{14}(0.48)+0+\frac{5}{14}(0.48) = 0.343, so ΔG=0.459−0.343=0.116\Delta G = 0.459-0.343=0.116. For Wind: G(Weak)=1−(0.752+0.252)=0.375G(\text{Weak})=1-(0.75^2+0.25^2)=0.375, G(Strong)=1−(0.52+0.52)=0.5G(\text{Strong})=1-(0.5^2+0.5^2)=0.5, weighted =814(0.375)+614(0.5)=0.4286=\frac{8}{14}(0.375)+\frac{6}{14}(0.5)=0.4286, so ΔG=0.459−0.4286=0.0304\Delta G = 0.459-0.4286=0.0304. Gini agrees: Outlook again wins decisively over Wind, confirming the two criteria give the same qualitative split decision here.

Common pitfalls & traps

PitfallWhy it happensFix
High-cardinality biasA feature like "ID number" with nn unique values yields nn pure singleton children, giving artificially maximal information gainUse gain ratio =IG/H(A)= IG / H(A) (C4.5), which penalizes splits with many small, high-entropy children
Confusing entropy unitsUsing ln⁡\ln instead of log⁡2\log_2 changes numeric values (nats vs. bits) though not which split winsBe consistent; report units; ranking of splits is invariant to the log base, only magnitudes change
Zero-probability logComputing pklog⁡2pkp_k \log_2 p_k for pk=0p_k = 0 naively gives NaNExplicitly define 0log⁡20:=00\log_2 0 := 0 (its limit) in code
Treating IG=0 as "no signal ever"A single feature may have IG=0IG=0 marginally but be jointly informative with another (XOR-type interactions)Use ensembles (random forests, boosting) or deeper/interaction-aware trees to recover such structure
Ignoring overfitting from unconstrained gain-chasingAlways splitting until nodes are pure fits noise, especially with many features relative to samplesApply max depth, min-samples-per-leaf, or post-hoc pruning — see Tree Pruning and Complexity Control
Comparing gains across different-sized candidate sets unfairlyComparing a 2-way split's gain to a 10-way split's gain without normalization favors the latterUse gain ratio or restrict to binary splits, as CART does uniformly

Pioneers & history

Origins · 1 minClaude Elwood Shannon and how this was discovered
CE
Claude Elwood Shannon
1916–2001 · Bell Labs, founder of information theory

Shannon's 1948 paper A Mathematical Theory of Communication introduced entropy as the fundamental measure of information content and uncertainty, originally to quantify the capacity of communication channels. Decades later, this exact formula became the backbone of decision tree learning, an application Shannon himself did not design but whose mathematics transferred essentially unchanged.

History
1948
— Claude Shannon defines entropy H=−∑pilog⁡piH = -\sum p_i \log p_i as a measure of information in communication theory.
1963
— Morgan and Sonquist introduce AID, an early automatic tree-splitting procedure using variance reduction.
1979
— J. Ross Quinlan develops ID3, the first widely used decision-tree algorithm using entropy-based information gain.
1984
— Breiman, Friedman, Olshen, and Stone publish CART, introducing Gini impurity and binary-split trees.
1993
— Quinlan releases C4.5, adding gain ratio to correct information gain's high-cardinality bias.

Quinlan's ID3 was built directly on Shannon's entropy formula, treating each feature test as a "question" whose expected information value could be computed exactly the way Shannon computed channel capacity. Breiman and colleagues, working independently in statistics, arrived at Gini impurity via a different route — minimizing expected misclassification cost under a two-class Bayes-error argument — yet the resulting splits so closely resemble entropy-based ones that both criteria remain standard, interchangeable defaults in modern libraries.

Where this matters

Every major tree-based library implements exactly this machinery: scikit-learn's `DecisionTreeClassifier` exposes `criterion='gini'` or `'entropy'` directly as a parameter, and both XGBoost and LightGBM use closely related (though second-order, loss-derivative-based) impurity surrogates when growing each boosting-round tree. Random forests, used in genomics for gene-expression classification and in finance for credit-risk scoring, build hundreds of such trees, each one repeatedly invoking information-gain or Gini-gain computations at every node. Medical decision-support tools favor entropy/Gini-based trees specifically because the splits are human-readable ("if age > 50 and troponin > threshold..."), unlike black-box neural models — auditability is a first-class requirement in clinical and regulatory settings. Feature-selection pipelines also borrow information gain directly (independent of any tree) as a fast univariate filter to rank candidate predictors before more expensive modeling. Finally, this same entropy-reduction logic generalizes to mutual-information feature selection in NLP and to impurity-based feature importance scores reported by every scikit-learn or ranger (R) random forest, making entropy and Gini impurity two of the most-invoked formulas in applied machine learning, even when practitioners never see the word "entropy" in the API they call.

Ask the tutor: How does the entropy-based information gain criterion change when the target variable is continuous, as in regression trees?

Why use log base 2 for entropy instead of natural log?

Log base 2 gives entropy units of bits, matching the original communication-theory motivation where one bit answers one yes/no question optimally. The choice of log base only rescales entropy by a constant factor (log⁡2x=ln⁡x/ln⁡2\log_2 x = \ln x / \ln 2), so it never changes which split maximizes information gain — the ranking of candidate splits is invariant to the base. Some libraries use natural log (giving units of "nats") purely for computational convenience, since natural log avoids an extra division. For teaching and reporting purposes, bits are the traditional and more interpretable choice, since log⁡2K\log_2 K bits corresponds cleanly to needing log⁡2K\log_2 K yes/no questions to identify one of KK equally likely classes.

Is Gini impurity always faster to compute than entropy?

Yes, in practice, because Gini impurity requires only sums of squared probabilities (1−∑pk21 - \sum p_k^2), while entropy requires a logarithm evaluation per class (−∑pklog⁡2pk-\sum p_k \log_2 p_k). Logarithms are typically several times more expensive than multiplication on modern hardware, so for very large datasets or very deep forests with millions of split evaluations, this difference is measurable in wall-clock training time. This computational advantage, not superior statistical performance, is the primary reason CART and many production libraries default to Gini impurity. In terms of split quality, the two criteria are close enough that the choice rarely changes final model accuracy meaningfully.

What is gain ratio, and why does it fix the high-cardinality bias?

Gain ratio, introduced in Quinlan's C4.5, divides information gain by the intrinsic information (entropy) of the split itself: GR(S,A)=IG(S,A)/HA(S)GR(S,A) = IG(S,A) / H_A(S), where HA(S)=−∑j(∣Sj∣/∣S∣)log⁡2(∣Sj∣/∣S∣)H_A(S) = -\sum_j (|S_j|/|S|) \log_2(|S_j|/|S|) treats the partition sizes themselves as a probability distribution. A feature that splits data into many tiny fragments (like a unique ID) has very high HA(S)H_A(S), so dividing by it heavily discounts the raw gain. This normalizes for the "free" gain a feature gets merely from having many possible values, forcing the criterion to reward splits that are informative relative to how finely they fragment the data.

Can information gain be negative?

No — information gain is always non-negative for any partition, a direct consequence of the concavity of the entropy function via Jensen's inequality. Weighted child entropy can never exceed parent entropy in expectation over the induced partition. What can happen is information gain being exactly zero (the split provides no information, all children have the same class distribution as the parent) or the validation-set improvement being negative even though training-set information gain is positive, which signals overfitting rather than a violation of the entropy inequality itself.

How does information gain relate to decision tree pruning?

Because greedy information-gain maximization always finds some positive gain until nodes are pure (barring ties or degenerate splits), an unconstrained tree will keep splitting until every leaf is perfectly pure on the training set — which almost always means overfitting to noise. Pruning techniques, covered under Tree Pruning and Complexity Control, counteract this by either stopping growth early (pre-pruning, e.g., minimum gain thresholds) or growing a full tree and then removing subtrees that do not improve validation performance (post-pruning, e.g., cost-complexity pruning). Information gain tells you what the best split is; pruning tells you when to stop trusting that greedy signal.

Do entropy and Gini impurity generalize beyond classification trees?

Yes. The same entropy formula underlies mutual-information-based feature selection, used to rank predictors independent of any specific model. In regression trees, the analogous impurity measure is variance reduction rather than entropy, since class probabilities do not apply to continuous targets. In clustering and density estimation, entropy quantifies cluster purity or model uncertainty. In deep learning, the cross-entropy loss function used for classification is directly derived from the same Shannon entropy framework, connecting tree-based split criteria and neural network training losses through one shared information-theoretic foundation.

Why do information gain and Gini gain sometimes disagree on the best split?

Although both are concave impurity functions peaking at the uniform distribution, their exact curvature differs: entropy involves logarithms and is more sharply penalizing near extreme probabilities, while Gini is a simple quadratic. For most real datasets the two produce identical or near-identical split rankings, but in edge cases — particularly with highly imbalanced class distributions or specific threshold ties — the differing curvature can tip the ranking of two very close candidate splits. Neither criterion is "more correct"; they are two reasonable concave impurity functions from the same family, and empirical studies generally find negligible difference in final tree accuracy between them.

Before this

Where this leads