{
    "name": "Information Gain Calculator",
    "url": "https://calculators.geekmidst.com/calculators/information-gain-calculator",
    "markdown": "https://calculators.geekmidst.com/calculators/information-gain-calculator.md",
    "category": "Statistics & probability",
    "description": "Enter the class counts in each child node of a split to get information gain (entropy or Gini), split information and the gain ratio used by C4.5.",
    "summary": "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"
    ],
    "applies_to": "Worldwide",
    "last_updated": "2026-10-29",
    "computation": "Results are computed in the visitor’s browser on the HTML page. This API describes the calculator; it does not compute results.",
    "inputs": [
        {
            "name": "children",
            "label": "Class counts in each child node",
            "type": "textarea",
            "default": "2 3\n4 0\n3 2"
        },
        {
            "name": "criterion",
            "label": "Impurity measure",
            "type": "segmented",
            "default": "entropy",
            "options": {
                "entropy": "Entropy (bits)",
                "gini": "Gini impurity"
            }
        }
    ],
    "outputs": [
        {
            "key": "gain",
            "label": "Information gain",
            "format": "number"
        },
        {
            "key": "parent_impurity",
            "label": "Parent impurity",
            "format": "number"
        },
        {
            "key": "weighted_child",
            "label": "Weighted child impurity",
            "format": "number"
        },
        {
            "key": "split_info",
            "label": "Split information (bits)",
            "format": "number"
        },
        {
            "key": "gain_ratio",
            "label": "Gain ratio",
            "format": "number"
        },
        {
            "key": "parent_counts",
            "label": "Parent class counts",
            "format": "text"
        }
    ],
    "formula": {
        "text": "IG = I(parent) − Σ (n_j ÷ n) I(child_j);  SplitInfo = −Σ (n_j ÷ n) log₂(n_j ÷ n);  GainRatio = IG ÷ SplitInfo",
        "variables": {
            "I": "impurity: entropy in bits or Gini",
            "n_j": "items in child j",
            "n": "items in the parent"
        }
    },
    "worked_example": {
        "inputs": {
            "children": "2 3\n4 0\n3 2",
            "criterion": "entropy"
        },
        "steps": [
            "Parent = 9 yes, 5 no: H = 0.940286 bits.",
            "Children: H(2,3) = H(3,2) = 0.970951 and H(4,0) = 0, so weighted = 2 × (5/14) × 0.970951 = 0.693536.",
            "IG = 0.940286 − 0.693536 = 0.24675; split info = 1.577406, gain ratio = 0.156428."
        ],
        "result": "Splitting the classic play-tennis data on Outlook gains 0.247 bits, matching the textbook value of 0.246."
    },
    "interpretation": "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": [
        "Each item falls in exactly one child node."
    ],
    "limitations": [
        "For numeric attributes, you choose the threshold; the calculator scores one split at a time."
    ],
    "rules": null,
    "faqs": [
        {
            "question": "Why can information gain mislead?",
            "answer": "Splitting on a unique ID gives every child a pure node and maximum gain, yet predicts nothing. Gain ratio corrects for this."
        },
        {
            "question": "Is Gini gain the same as information gain?",
            "answer": "It is the same idea with Gini impurity in place of entropy, as used by CART."
        }
    ],
    "sources": [],
    "related": [
        {
            "name": "Shannon Entropy Calculator",
            "url": "https://calculators.geekmidst.com/calculators/entropy-shannon-calculator"
        },
        {
            "name": "Gini Impurity Calculator",
            "url": "https://calculators.geekmidst.com/calculators/gini-impurity-calculator"
        },
        {
            "name": "KL Divergence Calculator",
            "url": "https://calculators.geekmidst.com/calculators/kl-divergence-calculator"
        }
    ],
    "disclaimer": null,
    "publisher": "GM¹X CalcVerse"
}