<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet href="/static/feed.xsl" type="text/xsl" ?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:quartz="https://quartz.jzhao.xyz/ns">
  <script xmlns="http://www.w3.org/1999/xhtml" src="/static/scripts/xslt-polyfill-214fd525.js"></script>
  <title>/wiki / decision-tree</title>
  <subtitle>Recent notes in /wiki / decision-tree on Animesh Mishra</subtitle>
  <link href="https://animishraa05.github.io/wiki/decision-tree" />
  <link rel="alternate" type="text/html" href="https://animishraa05.github.io/wiki/decision-tree" />
  <category term="wiki/decision-tree" />
  <id>https://animishraa05.github.io/wiki/decision-tree</id>
  <updated>2026-09-02T00:00:00.000Z</updated>
  <contributor>
    <name>Animesh Mishra</name>
    <email>animesh.mishra818@gmail.com</email>
  </contributor>
  <logo>https://animishraa05.github.io/icon.png</logo>
  <icon>https://animishraa05.github.io/icon.png</icon>
  <generator>Quartz v4.6.0 -- quartz.jzhao.xyz</generator>
  <rights type="html">&amp;amp;copy; 2026 Animesh Mishra</rights>
  
  <entry>
    <title>Decision Tree -- Map of Content</title>
    <link href="https://animishraa05.github.io/wiki/decision-tree/" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/decision-tree/.md" />
    <summary> Map of Content for Decision Tree — 21 concepts. Start here to navigate decision-tree.</summary>
    <published>2026-09-02T00:00:00.000Z</published>
    <updated>2026-09-02T00:00:00.000Z</updated>
    <publishedTime>Sep 02, 2026</publishedTime>
    <updatedTime>Sep 02, 2026</updatedTime>
    <category term="meta" label="meta" />
<category term="decision-tree" label="decision-tree" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;blockquote&gt;
&lt;p dir=&quot;auto&quot;&gt;Map of Content for &lt;strong&gt;Decision Tree&lt;/strong&gt; — 21 concepts. Start here to navigate decision-tree.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;core-concepts&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Concepts&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-concepts&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;a href=&quot;../../attribute-selection-measures&quot; class=&quot;internal alias&quot; data-slug=&quot;attribute-selection-measures&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Attribute Selection Measures&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../decision-tree-flexibility&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-flexibility&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Flexibility&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../decision-tree-interpretability&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-interpretability&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Interpretability&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../decision-tree-prediction&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-prediction&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Prediction&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../decision-tree-preprocessing&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-preprocessing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Preprocessing&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../decision-tree-splitting&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-splitting&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Splitting&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../decision-tree-stopping-conditions&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-stopping-conditions&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Stopping Conditions&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../decision-tree-structure&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-structure&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Structure&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../entropy-calculation&quot; class=&quot;internal alias&quot; data-slug=&quot;entropy-calculation&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Entropy Calculation&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../entropy&quot; class=&quot;internal alias&quot; data-slug=&quot;entropy&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Entropy&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../entropy-vs-gini&quot; class=&quot;internal&quot; data-slug=&quot;entropy-vs-gini&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;entropy-vs-gini&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../gini-index&quot; class=&quot;internal alias&quot; data-slug=&quot;gini-index&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Gini Index&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../gini-index-properties&quot; class=&quot;internal alias&quot; data-slug=&quot;gini-index-properties&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Gini Index Properties&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../id3-algorithm&quot; class=&quot;internal alias&quot; data-slug=&quot;id3-algorithm&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;ID3 Algorithm&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../information-gain-calculation&quot; class=&quot;internal alias&quot; data-slug=&quot;information-gain-calculation&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Information Gain Calculation&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../information-gain&quot; class=&quot;internal alias&quot; data-slug=&quot;information-gain&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Information Gain&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../internal-node&quot; class=&quot;internal alias&quot; data-slug=&quot;internal-node&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Internal Node&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../leaf-node&quot; class=&quot;internal alias&quot; data-slug=&quot;leaf-node&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Leaf Node&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../node-purity&quot; class=&quot;internal alias&quot; data-slug=&quot;node-purity&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Node Purity&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../recursive-tree-building&quot; class=&quot;internal alias&quot; data-slug=&quot;recursive-tree-building&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Recursive Tree Building&lt;/a&gt; — concept&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../root-node&quot; class=&quot;internal alias&quot; data-slug=&quot;root-node&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Root Node&lt;/a&gt; — concept&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;mechanisms--how-things-work&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Mechanisms &amp;#x26; How Things Work&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#mechanisms--how-things-work&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;em&gt;Pages that explain processes/flows.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&quot;comparisons--tradeoffs&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Comparisons &amp;#x26; Tradeoffs&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#comparisons--tradeoffs&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;em&gt;(No synthesis yet — create via ingest or query —save)&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;suggested-reading-order&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Suggested Reading Order&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#suggested-reading-order&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Browse Core Concepts above — start with most-linked page&lt;/li&gt;
&lt;li&gt;Follow Connections sections for dense graph traversal&lt;/li&gt;
&lt;/ol&gt;</content>
  </entry><entry>
    <title>attribute-selection-measures</title>
    <link href="https://animishraa05.github.io/wiki/decision-tree/attribute-selection-measures" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/decision-tree/attribute-selection-measures.md" />
    <summary>The Problem At every node in a decision tree, multiple attributes are candidates for splitting.</summary>
    <published>2026-05-06T00:00:00.000Z</published>
    <updated>2026-05-06T00:00:00.000Z</updated>
    <publishedTime>May 06, 2026</publishedTime>
    <updatedTime>May 06, 2026</updatedTime>
    <category term="ml" label="ml" />
<category term="decision-trees" label="decision-trees" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;At every node in a decision tree, multiple attributes are candidates for splitting. Choosing the wrong attribute creates impure child nodes, leading to a deeper, less accurate, and less interpretable tree. A systematic evaluation framework is needed.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Attribute Selection Measures are mathematical criteria used to evaluate and rank candidate attributes at each node, determining which attribute best separates the data into pure subsets. The two most popular measures are Information Gain (based on entropy reduction) and Gini Index (based on impurity probability).&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;The selection process at each node:&lt;/p&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Enumerate candidates&lt;/strong&gt;: List all available attributes (features) not yet used on the current path&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Score each attribute&lt;/strong&gt;: Apply the chosen measure (Information Gain or Gini Index) to evaluate each attribute&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Compare scores&lt;/strong&gt;: Rank attributes by their scores — highest IG or lowest Gini wins&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Select the best&lt;/strong&gt;: Assign the winning attribute to the current node&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Create branches&lt;/strong&gt;: Split the data based on the selected attribute’s values&lt;/li&gt;
&lt;/ol&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;strong&gt;Information Gain approach:&lt;/strong&gt;&lt;/p&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Calculates how much uncertainty decreases after the split&lt;/li&gt;
&lt;li&gt;Chooses the attribute with the highest IG&lt;/li&gt;
&lt;li&gt;Example: If splitting on “Outlook” reduces uncertainty from 0.95 to 0.3, IG = 0.65&lt;/li&gt;
&lt;/ul&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;strong&gt;Gini Index approach:&lt;/strong&gt;&lt;/p&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Calculates the impurity of child nodes after the split&lt;/li&gt;
&lt;li&gt;Chooses the attribute with the lowest weighted Gini&lt;/li&gt;
&lt;li&gt;Example: If splitting on “Income” produces children with Gini 0.1 and 0.2, weighted average = 0.15&lt;/li&gt;
&lt;/ul&gt;
&lt;p dir=&quot;auto&quot;&gt;The source explicitly identifies these as “the two popular attribute selection measures used” in decision tree construction.&lt;/p&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: attribute_selection Pages: 1 --&gt;
&lt;svg width=&quot;251pt&quot; height=&quot;402pt&quot; viewBox=&quot;0.00 0.00 251.00 402.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 397.6)&quot;&gt;
&lt;title&gt;attribute_selection&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-397.6 246.75,-397.6 246.75,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- candidates --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;candidates&lt;/title&gt;
&lt;polygon fill=&quot;#e8e8e8&quot; stroke=&quot;black&quot; points=&quot;206.41,-393.6 36.34,-393.6 36.34,-356.8 206.41,-356.8 206.41,-393.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;121.38&quot; y=&quot;-378.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Candidate Attributes&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;121.38&quot; y=&quot;-364.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;[Income, Age, Purchases, ...]&lt;/text&gt;
&lt;/g&gt;
&lt;!-- measure --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;measure&lt;/title&gt;
&lt;polygon fill=&quot;#cce5ff&quot; stroke=&quot;black&quot; points=&quot;195.74,-320.8 47.01,-320.8 47.01,-284 195.74,-284 195.74,-320.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;121.38&quot; y=&quot;-306&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Apply Selection Measure&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;121.38&quot; y=&quot;-291.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;(IG or Gini)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- candidates&amp;#45;&amp;gt;measure --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;candidates-&gt;measure&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M121.38,-356.33C121.38,-349.07 121.38,-340.48 121.38,-332.37&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;124.88,-332.53 121.38,-322.53 117.88,-332.53 124.88,-332.53&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- scores --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;scores&lt;/title&gt;
&lt;polygon fill=&quot;#e8d5f5&quot; stroke=&quot;black&quot; points=&quot;187.57,-248 55.18,-248 55.18,-182.4 187.57,-182.4 187.57,-248&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;121.38&quot; y=&quot;-233.2&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Scores:&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;121.38&quot; y=&quot;-218.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Income → IG=0.65&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;121.38&quot; y=&quot;-204.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Age → IG=0.42&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;121.38&quot; y=&quot;-190&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Purchases → IG=0.31&lt;/text&gt;
&lt;/g&gt;
&lt;!-- measure&amp;#45;&amp;gt;scores --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;measure-&gt;scores&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M121.38,-283.75C121.38,-276.71 121.38,-268.27 121.38,-259.78&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;124.88,-259.81 121.38,-249.81 117.88,-259.81 124.88,-259.81&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- best --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;best&lt;/title&gt;
&lt;polygon fill=&quot;#ffd700&quot; stroke=&quot;black&quot; points=&quot;121.38,-146.4 0,-109.6 121.38,-72.8 242.75,-109.6 121.38,-146.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;121.38&quot; y=&quot;-113.2&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Best Attribute&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;121.38&quot; y=&quot;-98.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Income (highest IG)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- scores&amp;#45;&amp;gt;best --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;scores-&gt;best&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M121.38,-181.99C121.38,-174.4 121.38,-166.15 121.38,-158.05&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;124.88,-158.28 121.38,-148.28 117.88,-158.28 124.88,-158.28&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- split --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;split&lt;/title&gt;
&lt;polygon fill=&quot;#d4edda&quot; stroke=&quot;black&quot; points=&quot;170.73,-36.8 72.02,-36.8 72.02,0 170.73,0 170.73,-36.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;121.38&quot; y=&quot;-22&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Split on Income&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;121.38&quot; y=&quot;-7.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;at this node&lt;/text&gt;
&lt;/g&gt;
&lt;!-- best&amp;#45;&amp;gt;split --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;best-&gt;split&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M121.38,-72.32C121.38,-64.34 121.38,-56 121.38,-48.35&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;124.88,-48.59 121.38,-38.59 117.88,-48.59 124.88,-48.59&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Greedy&lt;/strong&gt;: Evaluates one attribute at a time without considering future interactions&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Deterministic&lt;/strong&gt;: Same data and measure always produce the same ranking&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Measure-dependent&lt;/strong&gt;: Results differ between IG and Gini, though often similar in practice&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Local optimization&lt;/strong&gt;: Best for the current node, not necessarily for the overall tree&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;semantic-network&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Semantic Network&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#semantic-network&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: semantic_Attribute_Selection_Measures Pages: 1 --&gt;
&lt;svg width=&quot;195pt&quot; height=&quot;170pt&quot; viewBox=&quot;0.00 0.00 195.00 170.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 165.63)&quot;&gt;
&lt;title&gt;semantic_Attribute_Selection_Measures&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-165.63 191.33,-165.63 191.33,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- THIS --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;THIS&lt;/title&gt;
&lt;ellipse fill=&quot;#ffd700&quot; stroke=&quot;black&quot; stroke-width=&quot;2&quot; cx=&quot;82.84&quot; cy=&quot;-86.21&quot; rx=&quot;82.84&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;82.84&quot; y=&quot;-82.31&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;13.00&quot;&gt;Attribute Selection &lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL1 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL1&lt;/title&gt;
&lt;ellipse fill=&quot;#f0f0f0&quot; stroke=&quot;black&quot; cx=&quot;126.74&quot; cy=&quot;-143.63&quot; rx=&quot;60.59&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;126.74&quot; y=&quot;-140.33&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Related Concept&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL1 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M96.73,-104.37C101.96,-111.21 107.89,-118.97 113.09,-125.77&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;85.87&quot; y=&quot;-119.27&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;related&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL2 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL2&lt;/title&gt;
&lt;ellipse fill=&quot;#d4edda&quot; stroke=&quot;black&quot; cx=&quot;58.89&quot; cy=&quot;-18&quot; rx=&quot;41.67&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;58.89&quot; y=&quot;-14.7&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Builds Into&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL2 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M76.42,-67.93C72.93,-57.98 68.63,-45.73 65.16,-35.86&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;100.54&quot; y=&quot;-39.29&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;builds into&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../information-gain&quot; class=&quot;internal alias&quot; data-slug=&quot;information-gain&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Information Gain&lt;/a&gt; — primary attribute selection measure&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../gini-index&quot; class=&quot;internal alias&quot; data-slug=&quot;gini-index&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Gini Index&lt;/a&gt; — alternative attribute selection measure&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../decision-tree-splitting&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-splitting&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Splitting&lt;/a&gt; — determines which attribute to split on&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../root-node&quot; class=&quot;internal alias&quot; data-slug=&quot;root-node&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Root Node&lt;/a&gt; — root is selected via attribute selection&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../internal-node&quot; class=&quot;internal alias&quot; data-slug=&quot;internal-node&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Internal Node&lt;/a&gt; — each internal node uses attribute selection&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../entropy&quot; class=&quot;internal alias&quot; data-slug=&quot;entropy&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Entropy&lt;/a&gt; — entropy is the foundation of Information Gain&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../recursive-tree-building&quot; class=&quot;internal alias&quot; data-slug=&quot;recursive-tree-building&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Recursive Tree Building&lt;/a&gt; — attribute selection happens at every recursive step&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;ID3 bias&lt;/strong&gt;: Information Gain favors attributes with many distinct values (like IDs)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Ties are common&lt;/strong&gt;: Multiple attributes may score equally; tie-breaking affects tree structure&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Measure choice matters&lt;/strong&gt;: Some datasets respond better to Gini, others to IG — no universal winner&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No interaction detection&lt;/strong&gt;: Cannot detect that two weak attributes together would be strong&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>decision-tree-flexibility</title>
    <link href="https://animishraa05.github.io/wiki/decision-tree/decision-tree-flexibility" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/decision-tree/decision-tree-flexibility.md" />
    <summary>The Problem Machine learning workflows often require different models for different tasks — one algorithm for classification, another for regression, different handling for different data types.</summary>
    <published>2026-05-06T00:00:00.000Z</published>
    <updated>2026-05-06T00:00:00.000Z</updated>
    <publishedTime>May 06, 2026</publishedTime>
    <updatedTime>May 06, 2026</updatedTime>
    <category term="ml" label="ml" />
<category term="decision-trees" label="decision-trees" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Machine learning workflows often require different models for different tasks — one algorithm for classification, another for regression, different handling for different data types. Maintaining expertise in multiple algorithms is costly, and switching between them adds complexity to the pipeline.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Decision trees are flexible because the same algorithmic framework supports both classification (predicting discrete class labels) and regression (predicting continuous values), handles mixed feature types, and adapts to diverse problem domains without structural changes.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;The flexibility manifests in three dimensions:&lt;/p&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;strong&gt;Task flexibility&lt;/strong&gt;: The same tree structure works for both:&lt;/p&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Classification&lt;/strong&gt;: Leaf nodes store class labels; splits maximize class purity&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Regression&lt;/strong&gt;: Leaf nodes store mean values; splits minimize variance within nodes&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;strong&gt;Data type flexibility&lt;/strong&gt;: Trees handle:&lt;/p&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Numerical features&lt;/strong&gt;: Split using threshold comparisons (e.g., “Age &gt; 30”)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Categorical features&lt;/strong&gt;: Split using value matching (e.g., “Outlook = Sunny”)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Mixed features&lt;/strong&gt;: Numerical and categorical features coexist in the same tree&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;strong&gt;Domain flexibility&lt;/strong&gt;: Trees are used across:&lt;/p&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Customer prediction&lt;/strong&gt;: Income, age, purchase history → buy/no buy&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Weather decisions&lt;/strong&gt;: Outlook, humidity, wind → activity selection&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Medical diagnosis&lt;/strong&gt;: Symptoms, test results → disease classification&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Business rules&lt;/strong&gt;: Revenue, region, segment → strategy recommendation&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p dir=&quot;auto&quot;&gt;The source cites “flexibility” as one of the three main reasons decision trees are “widely used” — alongside interpretability and low preprocessing needs.&lt;/p&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: decision_tree_flexibility Pages: 1 --&gt;
&lt;svg width=&quot;397pt&quot; height=&quot;128pt&quot; viewBox=&quot;0.00 0.00 397.00 128.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 124)&quot;&gt;
&lt;title&gt;decision_tree_flexibility&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-124 393.49,-124 393.49,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- tree --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;tree&lt;/title&gt;
&lt;polygon fill=&quot;#ffd700&quot; stroke=&quot;black&quot; points=&quot;228.83,-120 128.47,-120 128.47,-84 228.83,-84 228.83,-120&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;178.65&quot; y=&quot;-105.3&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Decision Tree&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;178.65&quot; y=&quot;-92.1&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;(Same algorithm)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- class --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;class&lt;/title&gt;
&lt;polygon fill=&quot;#d4edda&quot; stroke=&quot;black&quot; points=&quot;101.3,-36 0,-36 0,0 101.3,0 101.3,-36&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;50.65&quot; y=&quot;-21.3&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Classification&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;50.65&quot; y=&quot;-8.1&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Leaf = class label&lt;/text&gt;
&lt;/g&gt;
&lt;!-- tree&amp;#45;&amp;gt;class --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;tree-&gt;class&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M151.51,-83.61C132.84,-71.65 107.83,-55.63 87.38,-42.53&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;89.34,-39.63 79.03,-37.18 85.57,-45.52 89.34,-39.63&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;135.66&quot; y=&quot;-57&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;task 1&lt;/text&gt;
&lt;/g&gt;
&lt;!-- reg --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;reg&lt;/title&gt;
&lt;polygon fill=&quot;#cce5ff&quot; stroke=&quot;black&quot; points=&quot;237.86,-36 119.44,-36 119.44,0 237.86,0 237.86,-36&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;178.65&quot; y=&quot;-21.3&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Regression&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;178.65&quot; y=&quot;-8.1&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Leaf = numeric value&lt;/text&gt;
&lt;/g&gt;
&lt;!-- tree&amp;#45;&amp;gt;reg --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;tree-&gt;reg&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M178.65,-83.61C178.65,-73.17 178.65,-59.64 178.65,-47.66&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;182.15,-47.88 178.65,-37.88 175.15,-47.88 182.15,-47.88&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;191.99&quot; y=&quot;-57&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;task 2&lt;/text&gt;
&lt;/g&gt;
&lt;!-- mixed --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;mixed&lt;/title&gt;
&lt;polygon fill=&quot;#e8d5f5&quot; stroke=&quot;black&quot; points=&quot;389.49,-36 255.81,-36 255.81,0 389.49,0 389.49,-36&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;322.65&quot; y=&quot;-21.3&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Mixed features&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;322.65&quot; y=&quot;-8.1&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Numerical + Categorical&lt;/text&gt;
&lt;/g&gt;
&lt;!-- tree&amp;#45;&amp;gt;mixed --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;tree-&gt;mixed&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M209.19,-83.61C230.48,-71.49 259.1,-55.19 282.27,-42&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;283.88,-45.1 290.84,-37.11 280.42,-39.02 283.88,-45.1&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;273.17&quot; y=&quot;-57&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;data 3&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Unified framework&lt;/strong&gt;: One algorithm for classification and regression tasks&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No task-specific modification&lt;/strong&gt;: The same code handles both tasks; only the leaf output differs&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Feature-agnostic&lt;/strong&gt;: Works with any combination of numerical and categorical features&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Domain-independent&lt;/strong&gt;: Applicable to any problem where decisions can be expressed as rules&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;semantic-network&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Semantic Network&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#semantic-network&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: semantic_Decision_Tree_Flexibility Pages: 1 --&gt;
&lt;svg width=&quot;202pt&quot; height=&quot;170pt&quot; viewBox=&quot;0.00 0.00 202.00 170.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 165.63)&quot;&gt;
&lt;title&gt;semantic_Decision_Tree_Flexibility&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-165.63 197.53,-165.63 197.53,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- THIS --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;THIS&lt;/title&gt;
&lt;ellipse fill=&quot;#ffd700&quot; stroke=&quot;black&quot; stroke-width=&quot;2&quot; cx=&quot;89.05&quot; cy=&quot;-86.21&quot; rx=&quot;89.05&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;89.05&quot; y=&quot;-82.31&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;13.00&quot;&gt;Decision Tree Flexib&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL1 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL1&lt;/title&gt;
&lt;ellipse fill=&quot;#f0f0f0&quot; stroke=&quot;black&quot; cx=&quot;132.94&quot; cy=&quot;-143.63&quot; rx=&quot;60.59&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;132.94&quot; y=&quot;-140.33&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Related Concept&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL1 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M102.93,-104.37C108.16,-111.21 114.09,-118.97 119.29,-125.77&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;92.07&quot; y=&quot;-119.27&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;related&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL2 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL2&lt;/title&gt;
&lt;ellipse fill=&quot;#d4edda&quot; stroke=&quot;black&quot; cx=&quot;65.09&quot; cy=&quot;-18&quot; rx=&quot;41.67&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;65.09&quot; y=&quot;-14.7&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Builds Into&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL2 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M82.63,-67.93C79.13,-57.98 74.83,-45.73 71.36,-35.86&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;106.75&quot; y=&quot;-39.29&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;builds into&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../classification&quot; class=&quot;internal alias&quot; data-slug=&quot;classification&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Classification&lt;/a&gt; — trees solve classification tasks&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../regression&quot; class=&quot;internal alias&quot; data-slug=&quot;regression&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Regression&lt;/a&gt; — trees solve regression tasks&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../decision-tree-preprocessing&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-preprocessing&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Preprocessing&lt;/a&gt; — low preprocessing contributes to flexibility&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../supervised-learning&quot; class=&quot;internal alias&quot; data-slug=&quot;supervised-learning&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Supervised Learning&lt;/a&gt; — flexibility makes trees broadly applicable in supervised learning&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../decision-tree-interpretability&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-interpretability&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Interpretability&lt;/a&gt; — both are practical advantages&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../decision-tree-structure&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-structure&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Structure&lt;/a&gt; — the same structure supports both tasks&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Not optimal for all tasks&lt;/strong&gt;: While flexible, trees may underperform specialized methods (e.g., CNNs for images)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Regression trees produce step functions&lt;/strong&gt;: Predictions are piecewise constant, not smooth&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Classification requires discrete classes&lt;/strong&gt;: Trees cannot natively handle multi-label classification&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Flexibility ≠ performance&lt;/strong&gt;: Being able to handle many tasks doesn’t mean being best at any one&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>decision-tree-interpretability</title>
    <link href="https://animishraa05.github.io/wiki/decision-tree/decision-tree-interpretability" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/decision-tree/decision-tree-interpretability.md" />
    <summary>The Problem Most machine learning models — neural networks, ensemble methods, kernel machines — operate as black boxes.</summary>
    <published>2026-05-06T00:00:00.000Z</published>
    <updated>2026-05-06T00:00:00.000Z</updated>
    <publishedTime>May 06, 2026</publishedTime>
    <updatedTime>May 06, 2026</updatedTime>
    <category term="ml" label="ml" />
<category term="decision-trees" label="decision-trees" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Most machine learning models — neural networks, ensemble methods, kernel machines — operate as black boxes. Their internal mechanisms are opaque, making it impossible to explain &lt;em&gt;why&lt;/em&gt; a specific prediction was made. In regulated industries (healthcare, finance, legal), this lack of transparency is a dealbreaker.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Decision trees are inherently interpretable because their prediction process mirrors human decision-making: a sequence of clear if-then rules. Every prediction can be traced as a path from root to leaf, producing an explanation that anyone — regardless of technical background — can understand and verify.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Interpretability comes from the tree’s structure:&lt;/p&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Each node is a question&lt;/strong&gt;: “Is income &gt; $50,000?” — a yes/no question anyone can answer&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Each path is a rule&lt;/strong&gt;: Following the path Income &gt; 50K → Age &gt; 30 → Purchases &gt; 0 → “Purchase” translates directly to: “IF income &gt; 50K AND age &gt; 30 AND previous purchases &gt; 0, THEN predict Purchase”&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No hidden transformations&lt;/strong&gt;: Unlike neural networks that apply opaque matrix multiplications, trees apply transparent logical tests&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Feature importance is visible&lt;/strong&gt;: Attributes near the root are the most important predictors; attributes never used are irrelevant&lt;/li&gt;
&lt;/ol&gt;
&lt;p dir=&quot;auto&quot;&gt;This interpretability is one of the reasons cited in the source for why “decision trees are widely used” — alongside flexibility and low preprocessing needs.&lt;/p&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: interpretability Pages: 1 --&gt;
&lt;svg width=&quot;217pt&quot; height=&quot;309pt&quot; viewBox=&quot;0.00 0.00 217.00 309.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 304.65)&quot;&gt;
&lt;title&gt;interpretability&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-304.65 212.54,-304.65 212.54,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- tree --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;tree&lt;/title&gt;
&lt;polygon fill=&quot;#ffd700&quot; stroke=&quot;black&quot; points=&quot;182.58,-300.65 25.96,-300.65 25.96,-264.65 182.58,-264.65 182.58,-300.65&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;104.27&quot; y=&quot;-285.95&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Decision Tree&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;104.27&quot; y=&quot;-272.75&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;(Structure is the explanation)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- path --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;path&lt;/title&gt;
&lt;polygon fill=&quot;#cce5ff&quot; stroke=&quot;black&quot; points=&quot;180.44,-216.65 28.1,-216.65 28.1,-180.65 180.44,-180.65 180.44,-216.65&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;104.27&quot; y=&quot;-201.95&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Prediction Path&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;104.27&quot; y=&quot;-188.75&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Root → Internal → ... → Leaf&lt;/text&gt;
&lt;/g&gt;
&lt;!-- tree&amp;#45;&amp;gt;path --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;tree-&gt;path&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M104.27,-264.26C104.27,-253.82 104.27,-240.29 104.27,-228.31&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;107.77,-228.53 104.27,-218.53 100.77,-228.53 107.77,-228.53&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;124.84&quot; y=&quot;-237.65&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;traced as&lt;/text&gt;
&lt;/g&gt;
&lt;!-- rule --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;rule&lt;/title&gt;
&lt;polygon fill=&quot;#d4edda&quot; stroke=&quot;black&quot; points=&quot;185.33,-132.65 23.21,-132.65 23.21,-96.65 185.33,-96.65 185.33,-132.65&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;104.27&quot; y=&quot;-117.95&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;If-Then Rule&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;104.27&quot; y=&quot;-104.75&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;IF conditions THEN prediction&lt;/text&gt;
&lt;/g&gt;
&lt;!-- path&amp;#45;&amp;gt;rule --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;path-&gt;rule&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M104.27,-180.26C104.27,-169.82 104.27,-156.29 104.27,-144.31&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;107.77,-144.53 104.27,-134.53 100.77,-144.53 107.77,-144.53&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;131.79&quot; y=&quot;-153.65&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;translated to&lt;/text&gt;
&lt;/g&gt;
&lt;!-- human --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;human&lt;/title&gt;
&lt;ellipse fill=&quot;#e8d5f5&quot; stroke=&quot;black&quot; cx=&quot;104.27&quot; cy=&quot;-24.32&quot; rx=&quot;104.27&quot; ry=&quot;24.32&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;104.27&quot; y=&quot;-27.62&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Human Understanding&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;104.27&quot; y=&quot;-14.42&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;No ML knowledge required&lt;/text&gt;
&lt;/g&gt;
&lt;!-- rule&amp;#45;&amp;gt;human --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;rule-&gt;human&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M104.27,-96.2C104.27,-85.99 104.27,-72.73 104.27,-60.44&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;107.77,-60.61 104.27,-50.61 100.77,-60.61 107.77,-60.61&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;135.96&quot; y=&quot;-69.65&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;understood by&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;White-box model&lt;/strong&gt;: Internal logic is fully visible and inspectable&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Rule extraction&lt;/strong&gt;: Every path from root to leaf is a complete if-then classification rule&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Feature importance&lt;/strong&gt;: Root-proximal attributes are globally important; leaf-proximal are locally specific&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No post-hoc explanation needed&lt;/strong&gt;: The model explains itself inherently, unlike LIME or SHAP for black boxes&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;semantic-network&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Semantic Network&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#semantic-network&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: semantic_Decision_Tree_Interpretability Pages: 1 --&gt;
&lt;svg width=&quot;201pt&quot; height=&quot;170pt&quot; viewBox=&quot;0.00 0.00 201.00 170.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 165.63)&quot;&gt;
&lt;title&gt;semantic_Decision_Tree_Interpretability&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-165.63 196.58,-165.63 196.58,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- THIS --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;THIS&lt;/title&gt;
&lt;ellipse fill=&quot;#ffd700&quot; stroke=&quot;black&quot; stroke-width=&quot;2&quot; cx=&quot;88.1&quot; cy=&quot;-86.21&quot; rx=&quot;88.1&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;88.1&quot; y=&quot;-82.31&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;13.00&quot;&gt;Decision Tree Interp&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL1 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL1&lt;/title&gt;
&lt;ellipse fill=&quot;#f0f0f0&quot; stroke=&quot;black&quot; cx=&quot;131.99&quot; cy=&quot;-143.63&quot; rx=&quot;60.59&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;131.99&quot; y=&quot;-140.33&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Related Concept&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL1 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M101.98,-104.37C107.21,-111.21 113.14,-118.97 118.34,-125.77&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;91.12&quot; y=&quot;-119.27&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;related&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL2 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL2&lt;/title&gt;
&lt;ellipse fill=&quot;#d4edda&quot; stroke=&quot;black&quot; cx=&quot;64.14&quot; cy=&quot;-18&quot; rx=&quot;41.67&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;64.14&quot; y=&quot;-14.7&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Builds Into&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL2 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M81.68,-67.93C78.18,-57.98 73.88,-45.73 70.41,-35.86&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;105.8&quot; y=&quot;-39.29&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;builds into&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../decision-tree-structure&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-structure&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Structure&lt;/a&gt; — the structure provides the interpretability&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../decision-tree-prediction&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-prediction&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Prediction&lt;/a&gt; — the prediction path is the explanation&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../neural-networks&quot; class=&quot;internal alias&quot; data-slug=&quot;neural-networks&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Neural Networks&lt;/a&gt; — neural networks are black boxes; trees are white boxes&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../supervised-learning&quot; class=&quot;internal alias&quot; data-slug=&quot;supervised-learning&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Supervised Learning&lt;/a&gt; — interpretability is a desirable property of supervised models&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../root-node&quot; class=&quot;internal alias&quot; data-slug=&quot;root-node&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Root Node&lt;/a&gt; — root attribute is the most important feature globally&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../classification&quot; class=&quot;internal alias&quot; data-slug=&quot;classification&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Classification&lt;/a&gt; — interpretability is valuable for classification decisions&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Deep trees lose interpretability&lt;/strong&gt;: A tree with 50 levels is no longer human-traceable&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Post-pruning helps&lt;/strong&gt;: Reducing tree depth after training improves interpretability at the cost of accuracy&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Feature interactions hidden&lt;/strong&gt;: While individual paths are clear, the global pattern across all paths may not be obvious&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Not always honest&lt;/strong&gt;: An interpretable model can still be wrong; interpretability ≠ correctness&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>decision-tree-prediction</title>
    <link href="https://animishraa05.github.io/wiki/decision-tree/decision-tree-prediction" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/decision-tree/decision-tree-prediction.md" />
    <summary>The Problem After a decision tree has been built, it needs to make predictions on new, unseen data.</summary>
    <published>2026-05-06T00:00:00.000Z</published>
    <updated>2026-05-06T00:00:00.000Z</updated>
    <publishedTime>May 06, 2026</publishedTime>
    <updatedTime>May 06, 2026</updatedTime>
    <category term="ml" label="ml" />
<category term="decision-trees" label="decision-trees" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;After a decision tree has been built, it needs to make predictions on new, unseen data. The mechanism for using the tree structure to classify a new instance must be simple, deterministic, and efficient.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Decision tree prediction follows a single path from the root to a leaf by evaluating each node’s attribute test on the instance’s feature values. The prediction stored at the reached leaf node is returned as the tree’s output.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;The prediction process is a sequential traversal:&lt;/p&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Start at the root node&lt;/strong&gt;: Begin with the new instance at the top of the tree&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Evaluate the node’s test&lt;/strong&gt;: Check the instance’s feature value against the node’s condition&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Follow the matching branch&lt;/strong&gt;: Move to the child node corresponding to the test outcome&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Repeat&lt;/strong&gt;: Continue evaluating tests and following branches until a leaf node is reached&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Return the leaf’s prediction&lt;/strong&gt;: The class label (classification) or value (regression) stored at the leaf is the prediction&lt;/li&gt;
&lt;/ol&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;strong&gt;Source example walkthrough:&lt;/strong&gt;
Predict whether a customer will buy a product:&lt;/p&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Instance: Income = $60,000, Age = 35, Previous Purchases = 2&lt;/li&gt;
&lt;li&gt;Step 1: Root node asks “Income &gt; $50,000?” → Yes → follow Yes branch&lt;/li&gt;
&lt;li&gt;Step 2: Internal node asks “Age &gt; 30?” → Yes (35 &gt; 30) → follow Yes branch&lt;/li&gt;
&lt;li&gt;Step 3: Internal node asks “Previous Purchases &gt; 0?” → Yes (2 &gt; 0) → follow Yes branch&lt;/li&gt;
&lt;li&gt;Step 4: Leaf node → Prediction: &lt;strong&gt;“Purchase”&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p dir=&quot;auto&quot;&gt;This process is O(depth) — the prediction time grows linearly with tree depth, not with training data size.&lt;/p&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: decision_tree_prediction Pages: 1 --&gt;
&lt;svg width=&quot;304pt&quot; height=&quot;398pt&quot; viewBox=&quot;0.00 0.00 304.00 398.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 394.44)&quot;&gt;
&lt;title&gt;decision_tree_prediction&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-394.44 299.76,-394.44 299.76,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- instance --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;instance&lt;/title&gt;
&lt;ellipse fill=&quot;#e8e8e8&quot; stroke=&quot;black&quot; cx=&quot;147.88&quot; cy=&quot;-364.42&quot; rx=&quot;147.88&quot; ry=&quot;26.02&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;147.88&quot; y=&quot;-368.02&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;New Instance&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;147.88&quot; y=&quot;-353.62&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Income=60K, Age=35, Purchases=2&lt;/text&gt;
&lt;/g&gt;
&lt;!-- root --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;root&lt;/title&gt;
&lt;polygon fill=&quot;#ffd700&quot; stroke=&quot;black&quot; points=&quot;196.4,-290.4 99.35,-290.4 99.35,-253.6 196.4,-253.6 196.4,-290.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;147.88&quot; y=&quot;-275.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Income &gt; 50K?&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;147.88&quot; y=&quot;-261.2&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Yes →&lt;/text&gt;
&lt;/g&gt;
&lt;!-- instance&amp;#45;&amp;gt;root --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;instance-&gt;root&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M147.88,-338.23C147.88,-327.06 147.88,-313.85 147.88,-302.25&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;151.38,-302.4 147.88,-292.4 144.38,-302.4 151.38,-302.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;157.6&quot; y=&quot;-311.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;start&lt;/text&gt;
&lt;/g&gt;
&lt;!-- age --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;age&lt;/title&gt;
&lt;polygon fill=&quot;#cce5ff&quot; stroke=&quot;black&quot; points=&quot;183.4,-205.6 112.35,-205.6 112.35,-168.8 183.4,-168.8 183.4,-205.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;147.88&quot; y=&quot;-190.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Age &gt; 30?&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;147.88&quot; y=&quot;-176.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Yes →&lt;/text&gt;
&lt;/g&gt;
&lt;!-- root&amp;#45;&amp;gt;age --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;root-&gt;age&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M147.88,-253.44C147.88,-242.97 147.88,-229.42 147.88,-217.38&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;151.38,-217.53 147.88,-207.53 144.38,-217.53 151.38,-217.53&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;156.49&quot; y=&quot;-226.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;Yes&lt;/text&gt;
&lt;/g&gt;
&lt;!-- purch --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;purch&lt;/title&gt;
&lt;polygon fill=&quot;#cce5ff&quot; stroke=&quot;black&quot; points=&quot;197.74,-120.8 98.02,-120.8 98.02,-84 197.74,-84 197.74,-120.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;147.88&quot; y=&quot;-106&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Purchases &gt; 0?&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;147.88&quot; y=&quot;-91.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Yes →&lt;/text&gt;
&lt;/g&gt;
&lt;!-- age&amp;#45;&amp;gt;purch --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;age-&gt;purch&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M147.88,-168.64C147.88,-158.17 147.88,-144.62 147.88,-132.58&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;151.38,-132.73 147.88,-122.73 144.38,-132.73 151.38,-132.73&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;156.49&quot; y=&quot;-141.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;Yes&lt;/text&gt;
&lt;/g&gt;
&lt;!-- leaf --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;leaf&lt;/title&gt;
&lt;polygon fill=&quot;#d4edda&quot; stroke=&quot;black&quot; points=&quot;147.88,-36 18.97,-18 147.88,0 276.78,-18 147.88,-36&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;147.88&quot; y=&quot;-14.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Prediction: PURCHASE&lt;/text&gt;
&lt;/g&gt;
&lt;!-- purch&amp;#45;&amp;gt;leaf --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;purch-&gt;leaf&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M147.88,-83.52C147.88,-73.01 147.88,-59.49 147.88,-47.54&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;151.38,-47.79 147.88,-37.79 144.38,-47.79 151.38,-47.79&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;156.49&quot; y=&quot;-57&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;Yes&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Deterministic&lt;/strong&gt;: The same instance always follows the same path to the same leaf&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Fast&lt;/strong&gt;: O(depth) time — typically O(log n) for balanced trees&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No data needed&lt;/strong&gt;: Prediction doesn’t require the training dataset, only the tree structure&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Interpretable&lt;/strong&gt;: The full decision path can be printed as an if-then rule&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;semantic-network&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Semantic Network&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#semantic-network&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: semantic_Decision_Tree_Prediction Pages: 1 --&gt;
&lt;svg width=&quot;203pt&quot; height=&quot;170pt&quot; viewBox=&quot;0.00 0.00 203.00 170.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 165.63)&quot;&gt;
&lt;title&gt;semantic_Decision_Tree_Prediction&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-165.63 198.97,-165.63 198.97,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- THIS --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;THIS&lt;/title&gt;
&lt;ellipse fill=&quot;#ffd700&quot; stroke=&quot;black&quot; stroke-width=&quot;2&quot; cx=&quot;90.48&quot; cy=&quot;-86.21&quot; rx=&quot;90.48&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;90.48&quot; y=&quot;-82.31&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;13.00&quot;&gt;Decision Tree Predic&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL1 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL1&lt;/title&gt;
&lt;ellipse fill=&quot;#f0f0f0&quot; stroke=&quot;black&quot; cx=&quot;134.38&quot; cy=&quot;-143.63&quot; rx=&quot;60.59&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;134.38&quot; y=&quot;-140.33&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Related Concept&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL1 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M104.37,-104.37C109.6,-111.21 115.53,-118.97 120.73,-125.77&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;131.59&quot; y=&quot;-119.27&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;related&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL2 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL2&lt;/title&gt;
&lt;ellipse fill=&quot;#d4edda&quot; stroke=&quot;black&quot; cx=&quot;66.53&quot; cy=&quot;-18&quot; rx=&quot;41.67&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;66.53&quot; y=&quot;-14.7&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Builds Into&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL2 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M84.06,-67.93C80.57,-57.98 76.27,-45.73 72.8,-35.86&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;108.18&quot; y=&quot;-39.29&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;builds into&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../decision-tree-structure&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-structure&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Structure&lt;/a&gt; — prediction uses the tree’s nodes and branches&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../root-node&quot; class=&quot;internal alias&quot; data-slug=&quot;root-node&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Root Node&lt;/a&gt; — prediction always starts at the root&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../internal-node&quot; class=&quot;internal alias&quot; data-slug=&quot;internal-node&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Internal Node&lt;/a&gt; — internal nodes guide the traversal&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../leaf-node&quot; class=&quot;internal alias&quot; data-slug=&quot;leaf-node&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Leaf Node&lt;/a&gt; — leaf nodes provide the final prediction&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../classification&quot; class=&quot;internal alias&quot; data-slug=&quot;classification&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Classification&lt;/a&gt; — prediction outputs class labels&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../regression&quot; class=&quot;internal alias&quot; data-slug=&quot;regression&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Regression&lt;/a&gt; — prediction outputs continuous values&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../decision-tree-interpretability&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-interpretability&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Interpretability&lt;/a&gt; — the prediction path is human-readable&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Missing features&lt;/strong&gt;: If the instance lacks a feature tested by an internal node, prediction cannot proceed without handling&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tree depth&lt;/strong&gt;: Very deep trees require many comparisons per prediction, slowing inference&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contradictory paths&lt;/strong&gt;: Two similar instances may reach different leaves if they differ on a single critical feature&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No confidence score&lt;/strong&gt;: The basic prediction returns a class, not a probability (unless leaf stores class distribution)&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>decision-tree-preprocessing</title>
    <link href="https://animishraa05.github.io/wiki/decision-tree/decision-tree-preprocessing" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/decision-tree/decision-tree-preprocessing.md" />
    <summary>The Problem Most machine learning algorithms require extensive data preparation: numerical features must be scaled to the same range, categorical features must be encoded, missing values must be imputed, and outliers must be handled.</summary>
    <published>2026-05-06T00:00:00.000Z</published>
    <updated>2026-05-06T00:00:00.000Z</updated>
    <publishedTime>May 06, 2026</publishedTime>
    <updatedTime>May 06, 2026</updatedTime>
    <category term="ml" label="ml" />
<category term="decision-trees" label="decision-trees" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Most machine learning algorithms require extensive data preparation: numerical features must be scaled to the same range, categorical features must be encoded, missing values must be imputed, and outliers must be handled. This preprocessing pipeline is time-consuming, error-prone, and can significantly impact model performance if done incorrectly.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Decision trees require minimal preprocessing because they make decisions based on feature thresholds rather than distance calculations or weighted sums. They naturally handle mixed data types (categorical and numerical), are invariant to feature scaling, and can handle missing values through surrogate splits.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Why decision trees don’t need common preprocessing steps:&lt;/p&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;strong&gt;No feature scaling needed&lt;/strong&gt;: Since trees compare values to thresholds (e.g., “Income &gt; 50K”), the absolute scale doesn’t matter. Doubling all income values would simply shift the threshold — the split logic remains identical.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;strong&gt;Natural categorical handling&lt;/strong&gt;: Categorical attributes are split by creating one branch per category value. No one-hot encoding or label encoding is required.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;strong&gt;Monotonic transformations are irrelevant&lt;/strong&gt;: Applying log, sqrt, or any monotonic function to a feature doesn’t change which threshold-based splits are possible — the relative ordering is preserved.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;strong&gt;Outlier tolerance&lt;/strong&gt;: A single extreme value doesn’t distort the tree’s behavior the way it would in distance-based methods like k-NN or SVM.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p dir=&quot;auto&quot;&gt;The source explicitly lists “low preprocessing needs” as one of the reasons why “decision trees are widely used” — alongside interpretability and flexibility.&lt;/p&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;figure data-rehype-pretty-code-figure=&quot;&quot;&gt;&lt;pre style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e&quot; tabindex=&quot;0&quot; data-language=&quot;dot&quot; data-theme=&quot;github-light github-dark&quot; class=&quot;notranslate&quot;&gt;&lt;span class=&quot;clipboard-button&quot; type=&quot;button&quot; aria-label=&quot;copy source&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 -8 24 24&quot; fill=&quot;currentColor&quot; stroke=&quot;none&quot; stroke-width=&quot;0&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;copy-icon&quot;&gt;&lt;use href=&quot;#github-copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 -8 24 24&quot; fill=&quot;currentColor&quot; stroke=&quot;none&quot; stroke-width=&quot;0&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;check-icon&quot;&gt;&lt;use href=&quot;#github-check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code data-language=&quot;dot&quot; data-theme=&quot;github-light github-dark&quot; style=&quot;display: grid;&quot; class=&quot;notranslate&quot;&gt;&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;digraph decision_tree_preprocessing {&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    rankdir=TB&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    node [shape=box style=filled fontname=&quot;Helvetica&quot; fontsize=11]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    edge [fontname=&quot;Helvetica&quot; fontsize=10]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt; &lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    raw [label=&quot;Raw Data\nMixed types, unscaled, missing&quot; fillcolor=&quot;#e8e8e8&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    tree [label=&quot;Decision Tree\n(Threshold-based splits)&quot; fillcolor=&quot;#ffd700&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    model [label=&quot;Trained Model\nNo preprocessing required&quot; fillcolor=&quot;#d4edda&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt; &lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    scaling [label=&quot;NOT NEEDED:\n- Feature scaling\n- Normalization\n- One-hot encoding\n- Outlier removal&quot; fillcolor=&quot;#ffcccc&quot; shape=note]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt; &lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    raw -&gt; tree -&gt; model&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    tree -- scaling [style=dashed label=&quot;skips&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Scale-invariant&lt;/strong&gt;: Feature values can be in any range without affecting tree quality&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Type-flexible&lt;/strong&gt;: Handles numerical, categorical, and ordinal features natively&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Robust to outliers&lt;/strong&gt;: Extreme values don’t distort split decisions&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Missing-value tolerant&lt;/strong&gt;: Can use surrogate splits or majority routing for missing features&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;semantic-network&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Semantic Network&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#semantic-network&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: semantic_Decision_Tree_Preprocessing Pages: 1 --&gt;
&lt;svg width=&quot;204pt&quot; height=&quot;170pt&quot; viewBox=&quot;0.00 0.00 204.00 170.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 165.63)&quot;&gt;
&lt;title&gt;semantic_Decision_Tree_Preprocessing&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-165.63 200.41,-165.63 200.41,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- THIS --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;THIS&lt;/title&gt;
&lt;ellipse fill=&quot;#ffd700&quot; stroke=&quot;black&quot; stroke-width=&quot;2&quot; cx=&quot;91.92&quot; cy=&quot;-86.21&quot; rx=&quot;91.92&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;91.92&quot; y=&quot;-82.31&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;13.00&quot;&gt;Decision Tree Prepro&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL1 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL1&lt;/title&gt;
&lt;ellipse fill=&quot;#f0f0f0&quot; stroke=&quot;black&quot; cx=&quot;135.82&quot; cy=&quot;-143.63&quot; rx=&quot;60.59&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;135.82&quot; y=&quot;-140.33&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Related Concept&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL1 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M105.81,-104.37C111.03,-111.21 116.97,-118.97 122.17,-125.77&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;94.95&quot; y=&quot;-119.27&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;related&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL2 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL2&lt;/title&gt;
&lt;ellipse fill=&quot;#d4edda&quot; stroke=&quot;black&quot; cx=&quot;67.96&quot; cy=&quot;-18&quot; rx=&quot;41.67&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;67.96&quot; y=&quot;-14.7&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Builds Into&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL2 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M85.5,-67.93C82.01,-57.98 77.7,-45.73 74.24,-35.86&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;109.62&quot; y=&quot;-39.29&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;builds into&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../decision-tree-splitting&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-splitting&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Splitting&lt;/a&gt; — threshold-based splits don’t require scaling&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../regression&quot; class=&quot;internal alias&quot; data-slug=&quot;regression&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Regression&lt;/a&gt; — linear regression requires feature scaling and encoding&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../supervised-learning&quot; class=&quot;internal alias&quot; data-slug=&quot;supervised-learning&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Supervised Learning&lt;/a&gt; — trees reduce the preprocessing burden in supervised workflows&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../decision-tree-interpretability&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-interpretability&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Interpretability&lt;/a&gt; — both are practical advantages of trees&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../decision-tree-flexibility&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-flexibility&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Flexibility&lt;/a&gt; — low preprocessing contributes to flexibility&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../classification&quot; class=&quot;internal alias&quot; data-slug=&quot;classification&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Classification&lt;/a&gt; — trees are a low-preprocessing option for classification&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Not zero preprocessing&lt;/strong&gt;: Extremely noisy data or massive cardinality still benefit from preprocessing&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;High-cardinality categories&lt;/strong&gt;: An attribute with 10,000 unique values can cause overfitting even in trees&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Missing data handling varies&lt;/strong&gt;: Not all tree implementations handle missing values — check your library&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Still benefits from cleaning&lt;/strong&gt;: Removing irrelevant features speeds up training and reduces overfitting&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>decision-tree-splitting</title>
    <link href="https://animishraa05.github.io/wiki/decision-tree/decision-tree-splitting" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/decision-tree/decision-tree-splitting.md" />
    <summary>The Problem A decision tree needs to divide its dataset into progressively cleaner groups.</summary>
    <published>2026-05-06T00:00:00.000Z</published>
    <updated>2026-05-06T00:00:00.000Z</updated>
    <publishedTime>May 06, 2026</publishedTime>
    <updatedTime>May 06, 2026</updatedTime>
    <category term="ml" label="ml" />
<category term="decision-trees" label="decision-trees" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;A decision tree needs to divide its dataset into progressively cleaner groups. The question of &lt;em&gt;how&lt;/em&gt; to split — which attribute to use, at what threshold, and into how many groups — determines whether the tree will learn meaningful patterns or noise.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Decision tree splitting is the process of partitioning a node’s dataset into subsets based on an attribute’s values. Each split creates child nodes, ideally with higher purity (fewer mixed classes) than the parent. The split is chosen to maximize Information Gain or minimize Gini impurity.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;The splitting process follows these steps:&lt;/p&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Candidate evaluation&lt;/strong&gt;: For each available attribute, calculate the impurity reduction (Information Gain or Gini decrease) if that attribute were used to split&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Best attribute selection&lt;/strong&gt;: Choose the attribute with the highest Information Gain (or lowest weighted Gini Index)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Partition creation&lt;/strong&gt;: Create one child node per possible value of the chosen attribute&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Data distribution&lt;/strong&gt;: Assign each training instance to the child node corresponding to its attribute value&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Recursive continuation&lt;/strong&gt;: Repeat the process for each child node that is not yet pure&lt;/li&gt;
&lt;/ol&gt;
&lt;p dir=&quot;auto&quot;&gt;For continuous attributes (like income or age), the algorithm finds an optimal threshold (e.g., “Income &gt; $50,000?”) by testing candidate thresholds and selecting the one that maximizes impurity reduction. The source example splits first on Income, then on Age, then on Previous Purchases — each split refining the prediction further.&lt;/p&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: decision_tree_splitting Pages: 1 --&gt;
&lt;svg width=&quot;310pt&quot; height=&quot;314pt&quot; viewBox=&quot;0.00 0.00 310.00 314.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 309.6)&quot;&gt;
&lt;title&gt;decision_tree_splitting&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-309.6 306.39,-309.6 306.39,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- parent --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;parent&lt;/title&gt;
&lt;polygon fill=&quot;#ffd700&quot; stroke=&quot;black&quot; points=&quot;187.39,-305.6 104.01,-305.6 104.01,-254.4 187.39,-254.4 187.39,-305.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;145.7&quot; y=&quot;-290.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Parent Node&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;145.7&quot; y=&quot;-276.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;(All Data)&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;145.7&quot; y=&quot;-262&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Entropy: 1.0&lt;/text&gt;
&lt;/g&gt;
&lt;!-- eval --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;eval&lt;/title&gt;
&lt;polygon fill=&quot;#e8e8e8&quot; stroke=&quot;black&quot; points=&quot;224.74,-206.4 66.66,-206.4 66.66,-169.6 224.74,-169.6 224.74,-206.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;145.7&quot; y=&quot;-191.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Evaluate All Attributes&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;145.7&quot; y=&quot;-177.2&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Calculate Information Gain&lt;/text&gt;
&lt;/g&gt;
&lt;!-- parent&amp;#45;&amp;gt;eval --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;parent-&gt;eval&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M145.7,-253.93C145.7,-242.81 145.7,-229.66 145.7,-218.11&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;149.2,-218.32 145.7,-208.32 142.2,-218.32 149.2,-218.32&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;159.32&quot; y=&quot;-227.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;step 1&lt;/text&gt;
&lt;/g&gt;
&lt;!-- best --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;best&lt;/title&gt;
&lt;polygon fill=&quot;#cce5ff&quot; stroke=&quot;black&quot; points=&quot;194.89,-121.6 96.51,-121.6 96.51,-84.8 194.89,-84.8 194.89,-121.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;145.7&quot; y=&quot;-106.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Best Attribute&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;145.7&quot; y=&quot;-92.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;(Income &gt; 50K)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- eval&amp;#45;&amp;gt;best --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;eval-&gt;best&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M145.7,-169.44C145.7,-158.97 145.7,-145.42 145.7,-133.38&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;149.2,-133.53 145.7,-123.53 142.2,-133.53 149.2,-133.53&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;178.21&quot; y=&quot;-142.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;step 2: max IG&lt;/text&gt;
&lt;/g&gt;
&lt;!-- left --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;left&lt;/title&gt;
&lt;polygon fill=&quot;#d4edda&quot; stroke=&quot;black&quot; points=&quot;131.4,-36.8 0,-36.8 0,0 131.4,0 131.4,-36.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;65.7&quot; y=&quot;-22&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Child: Income &amp;#x3C;= 50K&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;65.7&quot; y=&quot;-7.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Pure (No Purchase)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- best&amp;#45;&amp;gt;left --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;best-&gt;left&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M128.73,-84.64C117.67,-73.19 103.05,-58.05 90.67,-45.24&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;93.43,-43.07 83.97,-38.31 88.4,-47.93 93.43,-43.07&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;133.56&quot; y=&quot;-57.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;No branch&lt;/text&gt;
&lt;/g&gt;
&lt;!-- right --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;right&lt;/title&gt;
&lt;polygon fill=&quot;#ffcccc&quot; stroke=&quot;black&quot; points=&quot;302.39,-36.8 149.01,-36.8 149.01,0 302.39,0 302.39,-36.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;225.7&quot; y=&quot;-22&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Child: Income &gt; 50K&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;225.7&quot; y=&quot;-7.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Mixed (needs more splits)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- best&amp;#45;&amp;gt;right --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;best-&gt;right&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M162.67,-84.64C173.73,-73.19 188.35,-58.05 200.73,-45.24&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;203,-47.93 207.43,-38.31 197.97,-43.07 203,-47.93&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;215.78&quot; y=&quot;-57.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;Yes branch&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Greedy&lt;/strong&gt;: Each split is locally optimal; the algorithm doesn’t look ahead to future splits&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Binary or multi-way&lt;/strong&gt;: Can split into two groups (threshold-based) or many groups (categorical attributes)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Purity-driven&lt;/strong&gt;: The goal is always to create purer child nodes than the parent&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Irreversible&lt;/strong&gt;: Once data is split, it cannot be reassigned to a different branch&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;semantic-network&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Semantic Network&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#semantic-network&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: semantic_Decision_Tree_Splitting Pages: 1 --&gt;
&lt;svg width=&quot;198pt&quot; height=&quot;170pt&quot; viewBox=&quot;0.00 0.00 198.00 170.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 165.63)&quot;&gt;
&lt;title&gt;semantic_Decision_Tree_Splitting&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-165.63 193.71,-165.63 193.71,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- THIS --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;THIS&lt;/title&gt;
&lt;ellipse fill=&quot;#ffd700&quot; stroke=&quot;black&quot; stroke-width=&quot;2&quot; cx=&quot;85.22&quot; cy=&quot;-86.21&quot; rx=&quot;85.22&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;85.22&quot; y=&quot;-82.31&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;13.00&quot;&gt;Decision Tree Splitt&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL1 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL1&lt;/title&gt;
&lt;ellipse fill=&quot;#f0f0f0&quot; stroke=&quot;black&quot; cx=&quot;129.12&quot; cy=&quot;-143.63&quot; rx=&quot;60.59&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;129.12&quot; y=&quot;-140.33&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Related Concept&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL1 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M99.11,-104.37C104.33,-111.21 110.27,-118.97 115.47,-125.77&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;88.25&quot; y=&quot;-119.27&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;related&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL2 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL2&lt;/title&gt;
&lt;ellipse fill=&quot;#d4edda&quot; stroke=&quot;black&quot; cx=&quot;61.26&quot; cy=&quot;-18&quot; rx=&quot;41.67&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;61.26&quot; y=&quot;-14.7&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Builds Into&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL2 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M78.8,-67.93C75.31,-57.98 71.01,-45.73 67.54,-35.86&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;102.92&quot; y=&quot;-39.29&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;builds into&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../information-gain&quot; class=&quot;internal alias&quot; data-slug=&quot;information-gain&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Information Gain&lt;/a&gt; — primary metric for choosing splits&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../gini-index&quot; class=&quot;internal alias&quot; data-slug=&quot;gini-index&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Gini Index&lt;/a&gt; — alternative metric for choosing splits&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../internal-node&quot; class=&quot;internal alias&quot; data-slug=&quot;internal-node&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Internal Node&lt;/a&gt; — each split creates internal nodes&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../node-purity&quot; class=&quot;internal alias&quot; data-slug=&quot;node-purity&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Node Purity&lt;/a&gt; — splitting aims to increase purity&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../recursive-tree-building&quot; class=&quot;internal alias&quot; data-slug=&quot;recursive-tree-building&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Recursive Tree Building&lt;/a&gt; — splitting is the recursive step&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../decision-tree-structure&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-structure&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Structure&lt;/a&gt; — splits define the tree’s branches&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../attribute-selection-measures&quot; class=&quot;internal alias&quot; data-slug=&quot;attribute-selection-measures&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Attribute Selection Measures&lt;/a&gt; — the framework for evaluating splits&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Greedy trap&lt;/strong&gt;: The locally best split may prevent a globally better tree structure&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Threshold sensitivity&lt;/strong&gt;: Small changes in continuous thresholds can dramatically alter split quality&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Categorical explosion&lt;/strong&gt;: Attributes with many unique values (like IDs) can create artificially high Information Gain&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No split improvement&lt;/strong&gt;: If no attribute improves purity, the node becomes a leaf instead of splitting&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>decision-tree-stopping-conditions</title>
    <link href="https://animishraa05.github.io/wiki/decision-tree/decision-tree-stopping-conditions" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/decision-tree/decision-tree-stopping-conditions.md" />
    <summary>The Problem Without stopping conditions, a decision tree would keep splitting until every leaf contains exactly one training instance — creating a tree that perfectly memorizes the training data but fails completely on new data.</summary>
    <published>2026-05-06T00:00:00.000Z</published>
    <updated>2026-05-06T00:00:00.000Z</updated>
    <publishedTime>May 06, 2026</publishedTime>
    <updatedTime>May 06, 2026</updatedTime>
    <category term="ml" label="ml" />
<category term="decision-trees" label="decision-trees" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Without stopping conditions, a decision tree would keep splitting until every leaf contains exactly one training instance — creating a tree that perfectly memorizes the training data but fails completely on new data. The algorithm must know when to stop growing.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Stopping conditions are the criteria that determine when a node should become a leaf rather than continuing to split. The three primary conditions from the source are: (1) all instances share the same class, (2) no attributes remain to split on, and (3) no instances reach the node.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Three stopping conditions are evaluated at each node during recursive tree building:&lt;/p&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;strong&gt;All same class (purity)&lt;/strong&gt;: If all training instances at the node belong to one class, label the node with that class (“yes” or “no”) and stop. No further splitting can improve purity.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;strong&gt;No attributes remaining&lt;/strong&gt;: If all features have been used on the path from root to this node, no more splits are possible. Label the node with a majority vote of the training instances remaining at that node.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;strong&gt;No instances&lt;/strong&gt;: If the node receives zero training instances (because no training example matched the path to this node), label the node with a majority vote of the parent node’s training instances — using the parent’s context as the best available prior.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;strong&gt;Additional practical conditions (not in source but commonly used):&lt;/strong&gt;&lt;/p&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Maximum depth&lt;/strong&gt;: Stop when the tree reaches a pre-specified depth limit&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Minimum samples&lt;/strong&gt;: Stop when the node has fewer than a threshold number of instances&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Minimum impurity decrease&lt;/strong&gt;: Stop when no attribute provides a meaningful purity improvement&lt;/li&gt;
&lt;/ul&gt;
&lt;p dir=&quot;auto&quot;&gt;The source explicitly states: “If all positive or all negative training instances remain, label that node ‘yes’ or ‘no’ accordingly.”&lt;/p&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;figure data-rehype-pretty-code-figure=&quot;&quot;&gt;&lt;pre style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e&quot; tabindex=&quot;0&quot; data-language=&quot;dot&quot; data-theme=&quot;github-light github-dark&quot; class=&quot;notranslate&quot;&gt;&lt;span class=&quot;clipboard-button&quot; type=&quot;button&quot; aria-label=&quot;copy source&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 -8 24 24&quot; fill=&quot;currentColor&quot; stroke=&quot;none&quot; stroke-width=&quot;0&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;copy-icon&quot;&gt;&lt;use href=&quot;#github-copy&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 -8 24 24&quot; fill=&quot;currentColor&quot; stroke=&quot;none&quot; stroke-width=&quot;0&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;check-icon&quot;&gt;&lt;use href=&quot;#github-check&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;code data-language=&quot;dot&quot; data-theme=&quot;github-light github-dark&quot; style=&quot;display: grid;&quot; class=&quot;notranslate&quot;&gt;&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;digraph stopping_conditions {&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    rankdir=TB&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    node [shape=box style=filled fontname=&quot;Helvetica&quot; fontsize=11]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    edge [fontname=&quot;Helvetica&quot; fontsize=10]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt; &lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    node [label=&quot;Current Node\n(Being evaluated)&quot; fillcolor=&quot;#cce5ff&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    check1 [label=&quot;Check 1: All same class?&quot; fillcolor=&quot;#e8d5f5&quot; shape=diamond]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    check2 [label=&quot;Check 2: No attributes left?&quot; fillcolor=&quot;#e8d5f5&quot; shape=diamond]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    check3 [label=&quot;Check 3: No instances?&quot; fillcolor=&quot;#e8d5f5&quot; shape=diamond]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    leaf1 [label=&quot;Leaf: label with class&quot; fillcolor=&quot;#d4edda&quot; shape=diamond]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    leaf2 [label=&quot;Leaf: majority vote&quot; fillcolor=&quot;#ffcccc&quot; shape=diamond]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    leaf3 [label=&quot;Leaf: parent&#039;s majority vote&quot; fillcolor=&quot;#ffcccc&quot; shape=diamond]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    continue [label=&quot;Continue splitting\n(recurse)&quot; fillcolor=&quot;#ffd700&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt; &lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    node -&gt; check1 -&gt; check2 -&gt; check3&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    check1 -&gt; leaf1 [label=&quot;Yes&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    check1 -&gt; check2 [label=&quot;No&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    check2 -&gt; leaf2 [label=&quot;Yes&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    check2 -&gt; check3 [label=&quot;No&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    check3 -&gt; leaf3 [label=&quot;Yes&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;    check3 -&gt; continue [label=&quot;No&quot;]&lt;/span&gt;&lt;/span&gt;
&lt;span data-line=&quot;&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Necessary for termination&lt;/strong&gt;: Without stopping conditions, recursion would not terminate&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Prevent overfitting&lt;/strong&gt;: Stopping before perfect purity avoids memorizing training noise&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Hierarchical&lt;/strong&gt;: Conditions are checked in order; earlier conditions take precedence&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Fallback logic&lt;/strong&gt;: Each condition has a default labeling strategy (class, majority vote, parent’s vote)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;semantic-network&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Semantic Network&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#semantic-network&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: semantic_Decision_Tree_Stopping_Conditions Pages: 1 --&gt;
&lt;svg width=&quot;203pt&quot; height=&quot;170pt&quot; viewBox=&quot;0.00 0.00 203.00 170.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 165.63)&quot;&gt;
&lt;title&gt;semantic_Decision_Tree_Stopping_Conditions&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-165.63 198.98,-165.63 198.98,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- THIS --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;THIS&lt;/title&gt;
&lt;ellipse fill=&quot;#ffd700&quot; stroke=&quot;black&quot; stroke-width=&quot;2&quot; cx=&quot;90.49&quot; cy=&quot;-86.21&quot; rx=&quot;90.49&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;90.49&quot; y=&quot;-82.31&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;13.00&quot;&gt;Decision Tree Stoppi&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL1 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL1&lt;/title&gt;
&lt;ellipse fill=&quot;#f0f0f0&quot; stroke=&quot;black&quot; cx=&quot;134.39&quot; cy=&quot;-143.63&quot; rx=&quot;60.59&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;134.39&quot; y=&quot;-140.33&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Related Concept&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL1 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M104.38,-104.37C109.6,-111.21 115.54,-118.97 120.74,-125.77&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;131.6&quot; y=&quot;-119.27&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;related&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL2 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL2&lt;/title&gt;
&lt;ellipse fill=&quot;#d4edda&quot; stroke=&quot;black&quot; cx=&quot;66.53&quot; cy=&quot;-18&quot; rx=&quot;41.67&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;66.53&quot; y=&quot;-14.7&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Builds Into&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL2 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M84.07,-67.93C80.58,-57.98 76.28,-45.73 72.81,-35.86&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;108.19&quot; y=&quot;-39.29&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;builds into&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../recursive-tree-building&quot; class=&quot;internal alias&quot; data-slug=&quot;recursive-tree-building&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Recursive Tree Building&lt;/a&gt; — stopping conditions terminate the recursion&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../leaf-node&quot; class=&quot;internal alias&quot; data-slug=&quot;leaf-node&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Leaf Node&lt;/a&gt; — stopping conditions create leaf nodes&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../node-purity&quot; class=&quot;internal alias&quot; data-slug=&quot;node-purity&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Node Purity&lt;/a&gt; — purity check is the first stopping condition&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../overfitting&quot; class=&quot;internal alias&quot; data-slug=&quot;overfitting&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Overfitting&lt;/a&gt; — stopping conditions are the primary defense against overfitting&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../decision-tree-structure&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-structure&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Structure&lt;/a&gt; — determines the final tree shape&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../attribute-selection-measures&quot; class=&quot;internal alias&quot; data-slug=&quot;attribute-selection-measures&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Attribute Selection Measures&lt;/a&gt; — attribute exhaustion is a stopping condition&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Premature stopping&lt;/strong&gt;: Too aggressive conditions produce shallow, underfit trees&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Late stopping&lt;/strong&gt;: Too lenient conditions produce deep, overfit trees&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Empty node paradox&lt;/strong&gt;: When no instances reach a node, the prediction is essentially a guess based on the parent&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Attribute reuse&lt;/strong&gt;: Some implementations allow reusing attributes, which can prevent the “no attributes” condition from ever triggering&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>decision-tree-structure</title>
    <link href="https://animishraa05.github.io/wiki/decision-tree/decision-tree-structure" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/decision-tree/decision-tree-structure.md" />
    <summary>The Problem Machine learning models often function as black boxes — complex mathematical transformations that are nearly impossible for humans to understand or debug.</summary>
    <published>2026-05-06T00:00:00.000Z</published>
    <updated>2026-05-06T00:00:00.000Z</updated>
    <publishedTime>May 06, 2026</publishedTime>
    <updatedTime>May 06, 2026</updatedTime>
    <category term="ml" label="ml" />
<category term="decision-trees" label="decision-trees" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Machine learning models often function as black boxes — complex mathematical transformations that are nearly impossible for humans to understand or debug. When a model makes a wrong prediction, practitioners need to understand &lt;em&gt;why&lt;/em&gt; to fix it, trust it, or explain it to stakeholders.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;A decision tree is a supervised learning algorithm with a hierarchical tree structure consisting of a root node (first split), internal nodes (attribute tests), branches (attribute values), and leaf nodes (final predictions). It works like a flowchart, making step-by-step decisions that anyone can follow from top to bottom.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;The structure maps directly to how decisions are made:&lt;/p&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Root Node&lt;/strong&gt; — The topmost node representing the entire dataset. It performs the first and most important attribute test, chosen by the attribute selection measure (e.g., Information Gain or Gini Index).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Internal Nodes&lt;/strong&gt; — Intermediate decision points, each representing a test on a specific feature/attribute. Every internal node asks a question like “Is income &gt; $50,000?”&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Branches&lt;/strong&gt; — Edges connecting nodes, each representing a possible outcome of the attribute test. For a binary split, there are two branches (Yes/No); for multi-way splits, there are more.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Leaf Nodes (Terminal Nodes)&lt;/strong&gt; — The bottommost nodes that cannot be split further. Each leaf holds a final prediction: a class label (classification) or a continuous value (regression).&lt;/li&gt;
&lt;/ol&gt;
&lt;p dir=&quot;auto&quot;&gt;The tree is built top-down: start with all data at the root, find the best attribute to split on, create child nodes for each outcome, and repeat recursively until stopping conditions are met.&lt;/p&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: decision_tree_structure Pages: 1 --&gt;
&lt;svg width=&quot;404pt&quot; height=&quot;298pt&quot; viewBox=&quot;0.00 0.00 404.00 298.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 294.4)&quot;&gt;
&lt;title&gt;decision_tree_structure&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-294.4 400.39,-294.4 400.39,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- root --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;root&lt;/title&gt;
&lt;polygon fill=&quot;#ffd700&quot; stroke=&quot;black&quot; points=&quot;131.56,-290.4 19.84,-290.4 19.84,-253.6 131.56,-253.6 131.56,-290.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;75.7&quot; y=&quot;-275.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Root Node&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;75.7&quot; y=&quot;-261.2&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;(Income &gt; $50K?)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- leaf_no1 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;leaf_no1&lt;/title&gt;
&lt;polygon fill=&quot;#ffcccc&quot; stroke=&quot;black&quot; points=&quot;115.39,-205.6 0,-205.6 0,-168.8 115.39,-168.8 115.39,-205.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;57.7&quot; y=&quot;-190.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Leaf: No Purchase&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;57.7&quot; y=&quot;-176.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;(Impure subset)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- root&amp;#45;&amp;gt;leaf_no1 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;root-&gt;leaf_no1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M71.88,-253.44C69.58,-242.86 66.6,-229.14 63.96,-217.01&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;67.44,-216.53 61.89,-207.5 60.6,-218.01 67.44,-216.53&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;74.17&quot; y=&quot;-226.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;No&lt;/text&gt;
&lt;/g&gt;
&lt;!-- internal_age --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;internal_age&lt;/title&gt;
&lt;polygon fill=&quot;#cce5ff&quot; stroke=&quot;black&quot; points=&quot;221.72,-205.6 133.67,-205.6 133.67,-168.8 221.72,-168.8 221.72,-205.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;177.7&quot; y=&quot;-190.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Internal Node&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;177.7&quot; y=&quot;-176.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;(Age &gt; 30?)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- root&amp;#45;&amp;gt;internal_age --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;root-&gt;internal_age&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M97.58,-253.24C112.1,-241.45 131.36,-225.82 147.35,-212.83&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;149.12,-215.91 154.68,-206.89 144.71,-210.47 149.12,-215.91&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;141.42&quot; y=&quot;-226.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;Yes&lt;/text&gt;
&lt;/g&gt;
&lt;!-- leaf_no2 --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;leaf_no2&lt;/title&gt;
&lt;polygon fill=&quot;#ffcccc&quot; stroke=&quot;black&quot; points=&quot;190.39,-120.4 75,-120.4 75,-84.4 190.39,-84.4 190.39,-120.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;132.7&quot; y=&quot;-98.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Leaf: No Purchase&lt;/text&gt;
&lt;/g&gt;
&lt;!-- internal_age&amp;#45;&amp;gt;leaf_no2 --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;internal_age-&gt;leaf_no2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M168.15,-168.64C162.15,-157.59 154.27,-143.1 147.47,-130.58&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;150.64,-129.1 142.79,-121.98 144.49,-132.44 150.64,-129.1&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;164.28&quot; y=&quot;-141.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;No&lt;/text&gt;
&lt;/g&gt;
&lt;!-- internal_purch --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;internal_purch&lt;/title&gt;
&lt;polygon fill=&quot;#cce5ff&quot; stroke=&quot;black&quot; points=&quot;344.56,-120.8 208.84,-120.8 208.84,-84 344.56,-84 344.56,-120.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;276.7&quot; y=&quot;-106&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Internal Node&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;276.7&quot; y=&quot;-91.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;(Prev Purchases &gt; 0?)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- internal_age&amp;#45;&amp;gt;internal_purch --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;internal_age-&gt;internal_purch&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M198.69,-168.64C212.64,-156.97 231.17,-141.48 246.67,-128.51&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;248.8,-131.29 254.23,-122.19 244.31,-125.92 248.8,-131.29&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;241.74&quot; y=&quot;-141.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;Yes&lt;/text&gt;
&lt;/g&gt;
&lt;!-- leaf_yes --&gt;
&lt;g id=&quot;node6&quot; class=&quot;node&quot;&gt;
&lt;title&gt;leaf_yes&lt;/title&gt;
&lt;polygon fill=&quot;#d4edda&quot; stroke=&quot;black&quot; points=&quot;263.06,-36 166.34,-36 166.34,0 263.06,0 263.06,-36&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;214.7&quot; y=&quot;-14.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Leaf: Purchase&lt;/text&gt;
&lt;/g&gt;
&lt;!-- internal_purch&amp;#45;&amp;gt;leaf_yes --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;internal_purch-&gt;leaf_yes&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M263.24,-83.52C254.84,-72.36 243.88,-57.78 234.5,-45.31&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;237.42,-43.38 228.61,-37.49 231.82,-47.58 237.42,-43.38&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;258.02&quot; y=&quot;-57&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;Yes&lt;/text&gt;
&lt;/g&gt;
&lt;!-- leaf_no3 --&gt;
&lt;g id=&quot;node7&quot; class=&quot;node&quot;&gt;
&lt;title&gt;leaf_no3&lt;/title&gt;
&lt;polygon fill=&quot;#ffcccc&quot; stroke=&quot;black&quot; points=&quot;396.39,-36 281,-36 281,0 396.39,0 396.39,-36&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;338.7&quot; y=&quot;-14.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Leaf: No Purchase&lt;/text&gt;
&lt;/g&gt;
&lt;!-- internal_purch&amp;#45;&amp;gt;leaf_no3 --&gt;
&lt;g id=&quot;edge6&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;internal_purch-&gt;leaf_no3&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M290.15,-83.52C298.55,-72.36 309.51,-57.78 318.9,-45.31&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;321.57,-47.58 324.78,-37.49 315.98,-43.38 321.57,-47.58&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;317.8&quot; y=&quot;-57&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;No&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Hierarchical&lt;/strong&gt;: Strictly top-down; no cycles or backtracking&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Recursive&lt;/strong&gt;: Each subtree follows the same structural rules as the whole tree&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Interpretable&lt;/strong&gt;: Any prediction path is human-readable as a sequence of if-then rules&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Flexible&lt;/strong&gt;: Supports both classification (categorical leaves) and regression (numeric leaves)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Low preprocessing&lt;/strong&gt;: Handles mixed data types without scaling or normalization&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;semantic-network&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Semantic Network&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#semantic-network&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: semantic_Decision_Tree_Structure Pages: 1 --&gt;
&lt;svg width=&quot;201pt&quot; height=&quot;170pt&quot; viewBox=&quot;0.00 0.00 201.00 170.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 165.63)&quot;&gt;
&lt;title&gt;semantic_Decision_Tree_Structure&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-165.63 197.05,-165.63 197.05,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- THIS --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;THIS&lt;/title&gt;
&lt;ellipse fill=&quot;#ffd700&quot; stroke=&quot;black&quot; stroke-width=&quot;2&quot; cx=&quot;88.57&quot; cy=&quot;-86.21&quot; rx=&quot;88.57&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;88.57&quot; y=&quot;-82.31&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;13.00&quot;&gt;Decision Tree Struct&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL1 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL1&lt;/title&gt;
&lt;ellipse fill=&quot;#f0f0f0&quot; stroke=&quot;black&quot; cx=&quot;132.46&quot; cy=&quot;-143.63&quot; rx=&quot;60.59&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;132.46&quot; y=&quot;-140.33&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Related Concept&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL1 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M102.46,-104.37C107.68,-111.21 113.61,-118.97 118.81,-125.77&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;91.59&quot; y=&quot;-119.27&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;related&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL2 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL2&lt;/title&gt;
&lt;ellipse fill=&quot;#d4edda&quot; stroke=&quot;black&quot; cx=&quot;64.61&quot; cy=&quot;-18&quot; rx=&quot;41.67&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;64.61&quot; y=&quot;-14.7&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Builds Into&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL2 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M82.15,-67.93C78.65,-57.98 74.35,-45.73 70.88,-35.86&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;106.27&quot; y=&quot;-39.29&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;builds into&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../supervised-learning&quot; class=&quot;internal alias&quot; data-slug=&quot;supervised-learning&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Supervised Learning&lt;/a&gt; — decision trees are a supervised algorithm family&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../decision-tree-prediction&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-prediction&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Prediction&lt;/a&gt; — the structure determines how predictions are made&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../root-node&quot; class=&quot;internal alias&quot; data-slug=&quot;root-node&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Root Node&lt;/a&gt; — the entry point of every decision tree&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../internal-node&quot; class=&quot;internal alias&quot; data-slug=&quot;internal-node&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Internal Node&lt;/a&gt; — intermediate decision points in the tree&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../leaf-node&quot; class=&quot;internal alias&quot; data-slug=&quot;leaf-node&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Leaf Node&lt;/a&gt; — terminal nodes holding predictions&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../decision-tree-splitting&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-splitting&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Splitting&lt;/a&gt; — how nodes create child branches&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../entropy&quot; class=&quot;internal alias&quot; data-slug=&quot;entropy&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Entropy&lt;/a&gt; — used to decide the best splits at each node&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../gini-index&quot; class=&quot;internal alias&quot; data-slug=&quot;gini-index&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Gini Index&lt;/a&gt; — alternative to entropy for choosing splits&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Deep trees become unreadable&lt;/strong&gt;: A tree with 20+ levels loses its interpretability advantage&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Missing structural info&lt;/strong&gt;: The structure itself doesn’t indicate confidence — a leaf with 1 sample looks the same as one with 1000&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Ordering matters&lt;/strong&gt;: The same dataset can produce structurally different trees depending on which attribute is chosen first&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Empty branches&lt;/strong&gt;: Some attribute values may not appear in the training data, creating structural gaps&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>entropy-calculation</title>
    <link href="https://animishraa05.github.io/wiki/decision-tree/entropy-calculation" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/decision-tree/entropy-calculation.md" />
    <summary>The Problem Understanding that entropy measures uncertainty is abstract; practitioners need to know exactly how to compute it on a real dataset to use it for attribute selection in decision trees.</summary>
    <published>2026-05-06T00:00:00.000Z</published>
    <updated>2026-05-06T00:00:00.000Z</updated>
    <publishedTime>May 06, 2026</publishedTime>
    <updatedTime>May 06, 2026</updatedTime>
    <category term="ml" label="ml" />
<category term="decision-trees" label="decision-trees" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Understanding that entropy measures uncertainty is abstract; practitioners need to know exactly how to compute it on a real dataset to use it for attribute selection in decision trees.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Entropy calculation involves counting class frequencies, computing their proportions, applying the log₂ function to each proportion, multiplying by the proportion, summing these products, and negating the result.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Step-by-step computation:&lt;/p&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Count instances per class&lt;/strong&gt;: Tally how many training examples belong to each class label&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Compute proportions&lt;/strong&gt;: Divide each class count by the total number of instances&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Apply log₂&lt;/strong&gt;: Take the base-2 logarithm of each proportion&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Weight by proportion&lt;/strong&gt;: Multiply each log value by its corresponding proportion&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Sum and negate&lt;/strong&gt;: Add all weighted log values and multiply by -1&lt;/li&gt;
&lt;/ol&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;strong&gt;Worked example from source:&lt;/strong&gt;
Dataset X = {a, a, a, b, b, b, b, b}&lt;/p&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Total instances: 8&lt;/li&gt;
&lt;li&gt;Class a: 3 instances → P(a) = 3/8 = 0.375&lt;/li&gt;
&lt;li&gt;Class b: 5 instances → P(b) = 5/8 = 0.625&lt;/li&gt;
&lt;/ul&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;H&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;mi&gt;X&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mo stretchy=&quot;false&quot;&gt;[&lt;/mo&gt;&lt;mn&gt;0.375&lt;/mn&gt;&lt;mo&gt;×&lt;/mo&gt;&lt;msub&gt;&lt;mrow&gt;&lt;mi&gt;log&lt;/mi&gt;&lt;mo&gt;⁡&lt;/mo&gt;&lt;/mrow&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;mn&gt;0.375&lt;/mn&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mn&gt;0.625&lt;/mn&gt;&lt;mo&gt;×&lt;/mo&gt;&lt;msub&gt;&lt;mrow&gt;&lt;mi&gt;log&lt;/mi&gt;&lt;mo&gt;⁡&lt;/mo&gt;&lt;/mrow&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;mn&gt;0.625&lt;/mn&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo stretchy=&quot;false&quot;&gt;]&lt;/mo&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;H(X) = -[0.375 \times \log_2(0.375) + 0.625 \times \log_2(0.625)]&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1em;vertical-align:-0.25em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.0813em;&quot;&gt;H&lt;/span&gt;&lt;span class=&quot;mopen&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.0785em;&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;mclose&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1em;vertical-align:-0.25em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;−&lt;/span&gt;&lt;span class=&quot;mopen&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;0.375&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mbin&quot;&gt;×&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1em;vertical-align:-0.25em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mop&quot;&gt;&lt;span class=&quot;mop&quot;&gt;lo&lt;span style=&quot;margin-right:0.0139em;&quot;&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;msupsub&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.207em;&quot;&gt;&lt;span style=&quot;top:-2.4559em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.2441em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mopen&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;0.375&lt;/span&gt;&lt;span class=&quot;mclose&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mbin&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.7278em;vertical-align:-0.0833em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;0.625&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mbin&quot;&gt;×&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1em;vertical-align:-0.25em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mop&quot;&gt;&lt;span class=&quot;mop&quot;&gt;lo&lt;span style=&quot;margin-right:0.0139em;&quot;&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;msupsub&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.207em;&quot;&gt;&lt;span style=&quot;top:-2.4559em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.2441em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mopen&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;0.625&lt;/span&gt;&lt;span class=&quot;mclose&quot;&gt;)]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mo stretchy=&quot;false&quot;&gt;[&lt;/mo&gt;&lt;mn&gt;0.375&lt;/mn&gt;&lt;mo&gt;×&lt;/mo&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1.415&lt;/mn&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mn&gt;0.625&lt;/mn&gt;&lt;mo&gt;×&lt;/mo&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;0.678&lt;/mn&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo stretchy=&quot;false&quot;&gt;]&lt;/mo&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;= -[0.375 \times (-1.415) + 0.625 \times (-0.678)]&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.3669em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1em;vertical-align:-0.25em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;−&lt;/span&gt;&lt;span class=&quot;mopen&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;0.375&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mbin&quot;&gt;×&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1em;vertical-align:-0.25em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mopen&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;−&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;1.415&lt;/span&gt;&lt;span class=&quot;mclose&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mbin&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.7278em;vertical-align:-0.0833em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;0.625&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mbin&quot;&gt;×&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1em;vertical-align:-0.25em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mopen&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;−&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;0.678&lt;/span&gt;&lt;span class=&quot;mclose&quot;&gt;)]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;0.530&lt;/mn&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;0.424&lt;/mn&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;= -(-0.530 - 0.424)&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.3669em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1em;vertical-align:-0.25em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;−&lt;/span&gt;&lt;span class=&quot;mopen&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;−&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;0.530&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mbin&quot;&gt;−&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1em;vertical-align:-0.25em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;0.424&lt;/span&gt;&lt;span class=&quot;mclose&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;0.954&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;= 0.954&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.3669em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6444em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;0.954&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p dir=&quot;auto&quot;&gt;The entropy of 0.954 (near the maximum of 1.0 for binary) confirms this dataset is highly impure.&lt;/p&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: entropy_calculation Pages: 1 --&gt;
&lt;svg width=&quot;257pt&quot; height=&quot;437pt&quot; viewBox=&quot;0.00 0.00 257.00 437.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 432.8)&quot;&gt;
&lt;title&gt;entropy_calculation&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-432.8 253.01,-432.8 253.01,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- raw --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;raw&lt;/title&gt;
&lt;polygon fill=&quot;#e8e8e8&quot; stroke=&quot;black&quot; points=&quot;171.35,-428.8 77.67,-428.8 77.67,-392.8 171.35,-392.8 171.35,-428.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;124.51&quot; y=&quot;-414.1&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Raw Dataset&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;124.51&quot; y=&quot;-400.9&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;{a,a,a,b,b,b,b,b}&lt;/text&gt;
&lt;/g&gt;
&lt;!-- count --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;count&lt;/title&gt;
&lt;polygon fill=&quot;#cce5ff&quot; stroke=&quot;black&quot; points=&quot;171.95,-356.8 77.06,-356.8 77.06,-320.8 171.95,-320.8 171.95,-356.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;124.51&quot; y=&quot;-342.1&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Count: a=3, b=5&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;124.51&quot; y=&quot;-328.9&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Total=8&lt;/text&gt;
&lt;/g&gt;
&lt;!-- raw&amp;#45;&amp;gt;count --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;raw-&gt;count&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M124.51,-392.5C124.51,-385.21 124.51,-376.53 124.51,-368.34&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;128.01,-368.42 124.51,-358.42 121.01,-368.42 128.01,-368.42&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- prob --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;prob&lt;/title&gt;
&lt;polygon fill=&quot;#cce5ff&quot; stroke=&quot;black&quot; points=&quot;190.29,-284.8 58.72,-284.8 58.72,-248.8 190.29,-248.8 190.29,-284.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;124.51&quot; y=&quot;-263.5&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;P(a)=0.375, P(b)=0.625&lt;/text&gt;
&lt;/g&gt;
&lt;!-- count&amp;#45;&amp;gt;prob --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;count-&gt;prob&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M124.51,-320.5C124.51,-313.21 124.51,-304.53 124.51,-296.34&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;128.01,-296.42 124.51,-286.42 121.01,-296.42 128.01,-296.42&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- log --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;log&lt;/title&gt;
&lt;polygon fill=&quot;#e8d5f5&quot; stroke=&quot;black&quot; points=&quot;180.66,-212.8 68.35,-212.8 68.35,-176.8 180.66,-176.8 180.66,-212.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;124.51&quot; y=&quot;-198.1&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;log₂(0.375)=-1.415&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;124.51&quot; y=&quot;-184.9&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;log₂(0.625)=-0.678&lt;/text&gt;
&lt;/g&gt;
&lt;!-- prob&amp;#45;&amp;gt;log --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;prob-&gt;log&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M124.51,-248.5C124.51,-241.21 124.51,-232.53 124.51,-224.34&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;128.01,-224.42 124.51,-214.42 121.01,-224.42 128.01,-224.42&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- weighted --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;weighted&lt;/title&gt;
&lt;polygon fill=&quot;#e8d5f5&quot; stroke=&quot;black&quot; points=&quot;187.39,-140.8 61.62,-140.8 61.62,-104.8 187.39,-104.8 187.39,-140.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;124.51&quot; y=&quot;-126.1&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;0.375×(-1.415)=-0.53&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;124.51&quot; y=&quot;-112.9&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;0.625×(-0.678)=-0.424&lt;/text&gt;
&lt;/g&gt;
&lt;!-- log&amp;#45;&amp;gt;weighted --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;log-&gt;weighted&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M124.51,-176.5C124.51,-169.21 124.51,-160.53 124.51,-152.34&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;128.01,-152.42 124.51,-142.42 121.01,-152.42 128.01,-152.42&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- result --&gt;
&lt;g id=&quot;node6&quot; class=&quot;node&quot;&gt;
&lt;title&gt;result&lt;/title&gt;
&lt;polygon fill=&quot;#ffd700&quot; stroke=&quot;black&quot; points=&quot;124.51,-68.8 0,-34.4 124.51,0 249.01,-34.4 124.51,-68.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;124.51&quot; y=&quot;-37.7&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;H(X) = -(-0.53 - 0.424)&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;124.51&quot; y=&quot;-24.5&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;= 0.954&lt;/text&gt;
&lt;/g&gt;
&lt;!-- weighted&amp;#45;&amp;gt;result --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;weighted-&gt;result&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M124.51,-104.32C124.51,-97.4 124.51,-89.1 124.51,-80.7&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;128.01,-80.81 124.51,-70.81 121.01,-80.81 128.01,-80.81&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Deterministic&lt;/strong&gt;: Same input always produces the same entropy value&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;O(c) computation&lt;/strong&gt;: Linear in the number of classes c (not in the number of instances)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Base-2 standard&lt;/strong&gt;: Log base 2 gives entropy in bits; natural log gives nats; base 10 gives hartleys&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Zero handling&lt;/strong&gt;: When pᵢ = 0, the term pᵢ × log(pᵢ) is defined as 0&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;semantic-network&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Semantic Network&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#semantic-network&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: semantic_Entropy_Calculation Pages: 1 --&gt;
&lt;svg width=&quot;198pt&quot; height=&quot;170pt&quot; viewBox=&quot;0.00 0.00 198.00 170.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 165.63)&quot;&gt;
&lt;title&gt;semantic_Entropy_Calculation&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-165.63 193.72,-165.63 193.72,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- THIS --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;THIS&lt;/title&gt;
&lt;ellipse fill=&quot;#ffd700&quot; stroke=&quot;black&quot; stroke-width=&quot;2&quot; cx=&quot;85.23&quot; cy=&quot;-86.21&quot; rx=&quot;85.23&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;85.23&quot; y=&quot;-82.31&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;13.00&quot;&gt;Entropy Calculation&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL1 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL1&lt;/title&gt;
&lt;ellipse fill=&quot;#f0f0f0&quot; stroke=&quot;black&quot; cx=&quot;129.13&quot; cy=&quot;-143.63&quot; rx=&quot;60.59&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;129.13&quot; y=&quot;-140.33&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Related Concept&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL1 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M99.12,-104.37C104.35,-111.21 110.28,-118.97 115.48,-125.77&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;88.26&quot; y=&quot;-119.27&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;related&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL2 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL2&lt;/title&gt;
&lt;ellipse fill=&quot;#d4edda&quot; stroke=&quot;black&quot; cx=&quot;61.28&quot; cy=&quot;-18&quot; rx=&quot;41.67&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;61.28&quot; y=&quot;-14.7&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Builds Into&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL2 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M78.81,-67.93C75.32,-57.98 71.02,-45.73 67.55,-35.86&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;102.93&quot; y=&quot;-39.29&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;builds into&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../entropy&quot; class=&quot;internal alias&quot; data-slug=&quot;entropy&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Entropy&lt;/a&gt; — this is the computational method behind the concept&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../information-gain&quot; class=&quot;internal alias&quot; data-slug=&quot;information-gain&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Information Gain&lt;/a&gt; — entropy values are needed to compute IG&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../node-purity&quot; class=&quot;internal alias&quot; data-slug=&quot;node-purity&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Node Purity&lt;/a&gt; — calculation quantifies the purity concept&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../gini-index&quot; class=&quot;internal alias&quot; data-slug=&quot;gini-index&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Gini Index&lt;/a&gt; — different computational approach to measuring impurity&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../decision-tree-splitting&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-splitting&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Splitting&lt;/a&gt; — entropy values determine split quality&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../attribute-selection-measures&quot; class=&quot;internal alias&quot; data-slug=&quot;attribute-selection-measures&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Attribute Selection Measures&lt;/a&gt; — entropy is used in Information Gain&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Floating point precision&lt;/strong&gt;: Very small probabilities can cause numerical issues with log&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Single-class shortcut&lt;/strong&gt;: If only one class exists, skip computation — entropy is 0&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Large datasets&lt;/strong&gt;: Counting can overflow with huge datasets; use incremental or streaming approaches&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Negative zero&lt;/strong&gt;: Some implementations may produce -0.0; normalize to 0.0 for consistency&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>Entropy vs Gini -- Impurity Measures Compared</title>
    <link href="https://animishraa05.github.io/wiki/decision-tree/entropy-vs-gini" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/decision-tree/entropy-vs-gini.md" />
    <summary>What’s Being Compared Both Entropy (used in Information Gain) and Gini Index are impurity measures used to decide which attribute to split on at each node of a decision tree.</summary>
    <published>2026-05-06T00:00:00.000Z</published>
    <updated>2026-05-06T00:00:00.000Z</updated>
    <publishedTime>May 06, 2026</publishedTime>
    <updatedTime>May 06, 2026</updatedTime>
    <category term="ml" label="ml" />
<category term="decision-trees" label="decision-trees" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;whats-being-compared&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;What’s Being Compared&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#whats-being-compared&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Both Entropy (used in Information Gain) and Gini Index are impurity measures used to decide which attribute to split on at each node of a decision tree. They share the same goal — find the split that creates the purest child nodes — but achieve it through different mathematical formulations. Understanding the difference helps practitioners choose the right criterion for their specific problem and computational constraints.&lt;/p&gt;
&lt;h2 id=&quot;the-core-tension&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Core Tension&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-core-tension&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;strong&gt;Information-theoretic rigor vs computational efficiency.&lt;/strong&gt; Entropy is grounded in information theory and measures uncertainty in bits, providing a theoretically sound framework. Gini Index uses simple squared probabilities, trading theoretical elegance for speed. In practice, both produce nearly identical trees on most datasets.&lt;/p&gt;
&lt;h2 id=&quot;comparison&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Comparison&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#comparison&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;


















































&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Dimension&lt;/th&gt;&lt;th&gt;&lt;a href=&quot;../../entropy&quot; class=&quot;internal alias&quot; data-slug=&quot;entropy&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Entropy (Information Gain)&lt;/a&gt;&lt;/th&gt;&lt;th&gt;&lt;a href=&quot;../../gini-index&quot; class=&quot;internal alias&quot; data-slug=&quot;gini-index&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Gini Index&lt;/a&gt;&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;Formula&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;H&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;mi&gt;S&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mo&gt;∑&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;p&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;/msub&gt;&lt;msub&gt;&lt;mrow&gt;&lt;mi&gt;log&lt;/mi&gt;&lt;mo&gt;⁡&lt;/mo&gt;&lt;/mrow&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;p&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;H(S) = -\sum p_i \log_2(p_i)&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1em;vertical-align:-0.25em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.0813em;&quot;&gt;H&lt;/span&gt;&lt;span class=&quot;mopen&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.0576em;&quot;&gt;S&lt;/span&gt;&lt;span class=&quot;mclose&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1em;vertical-align:-0.25em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;−&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.1667em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mop op-symbol small-op&quot; style=&quot;position:relative;top:0em;&quot;&gt;∑&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.1667em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;msupsub&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.3117em;&quot;&gt;&lt;span style=&quot;top:-2.55em;margin-left:0em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.15em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.1667em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mop&quot;&gt;&lt;span class=&quot;mop&quot;&gt;lo&lt;span style=&quot;margin-right:0.0139em;&quot;&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;msupsub&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.207em;&quot;&gt;&lt;span style=&quot;top:-2.4559em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.2441em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mopen&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;msupsub&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.3117em;&quot;&gt;&lt;span style=&quot;top:-2.55em;margin-left:0em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.15em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mclose&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;G&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mo&gt;∑&lt;/mo&gt;&lt;msubsup&gt;&lt;mi&gt;p&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;/msubsup&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;Gini = 1 - \sum p_i^2&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6833em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;G&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;ini&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.7278em;vertical-align:-0.0833em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mbin&quot;&gt;−&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1.0728em;vertical-align:-0.2587em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mop op-symbol small-op&quot; style=&quot;position:relative;top:0em;&quot;&gt;∑&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.1667em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;msupsub&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.8141em;&quot;&gt;&lt;span style=&quot;top:-2.4413em;margin-left:0em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;top:-3.063em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.2587em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Range (binary)&lt;/td&gt;&lt;td&gt;[0, 1]&lt;/td&gt;&lt;td&gt;[0, 0.5]&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Computation cost&lt;/td&gt;&lt;td&gt;Higher (logarithm)&lt;/td&gt;&lt;td&gt;Lower (squaring)&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Theoretical basis&lt;/td&gt;&lt;td&gt;Information theory (Shannon)&lt;/td&gt;&lt;td&gt;Probability of misclassification&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Sensitivity&lt;/td&gt;&lt;td&gt;More sensitive to small probability changes&lt;/td&gt;&lt;td&gt;More sensitive to changes near extremes&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Split bias&lt;/td&gt;&lt;td&gt;Favors many-valued attributes (ID bias)&lt;/td&gt;&lt;td&gt;Favors equally-sized splits&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Default in sklearn&lt;/td&gt;&lt;td&gt;Not default&lt;/td&gt;&lt;td&gt;Default (&lt;code class=&quot;notranslate&quot;&gt;criterion=&quot;gini&quot;&lt;/code&gt;)&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;When to prefer&lt;/td&gt;&lt;td&gt;Theoretical interpretability matters&lt;/td&gt;&lt;td&gt;Performance on large datasets matters&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;h2 id=&quot;when-to-choose-entropy&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;When to Choose Entropy&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#when-to-choose-entropy&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;You need the information-theoretic interpretation (bits of information gained)&lt;/li&gt;
&lt;li&gt;You’re building a teaching/explanatory model where the theoretical foundation matters&lt;/li&gt;
&lt;li&gt;Your dataset is small enough that the computational overhead is negligible&lt;/li&gt;
&lt;li&gt;You want to connect to concepts like mutual information, KL divergence, or cross-entropy&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;when-to-choose-gini&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;When to Choose Gini&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#when-to-choose-gini&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;You’re working with large datasets where computation speed matters&lt;/li&gt;
&lt;li&gt;You want the sklearn default (battle-tested in production)&lt;/li&gt;
&lt;li&gt;You’re building production models where marginal accuracy differences don’t matter&lt;/li&gt;
&lt;li&gt;You prefer simpler mathematics (no logarithms, just squaring and summing)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;the-insight&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Insight&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-insight&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;The choice between entropy and Gini is rarely consequential — both measures are &lt;strong&gt;monotonically correlated&lt;/strong&gt;, meaning they generally agree on which splits are good and which are bad. The real-world accuracy difference is typically less than 1%. The practical decision comes down to: (1) computational budget for training, and (2) whether you need the information-theoretic interpretability. This is why sklearn defaults to Gini — it’s the “good enough and faster” option — but supports entropy for users who need it.&lt;/p&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: entropy_vs_gini Pages: 1 --&gt;
&lt;svg width=&quot;522pt&quot; height=&quot;50pt&quot; viewBox=&quot;0.00 0.00 522.00 50.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 45.6)&quot;&gt;
&lt;title&gt;entropy_vs_gini&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-45.6 517.64,-45.6 517.64,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- A --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;A&lt;/title&gt;
&lt;polygon fill=&quot;#f0f4ff&quot; stroke=&quot;black&quot; points=&quot;113.26,-41.6 0,-41.6 0,0 113.26,0 113.26,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;56.63&quot; y=&quot;-25&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;14.00&quot;&gt;Entropy Vs Gini&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;56.63&quot; y=&quot;-8.2&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;14.00&quot;&gt;Input&lt;/text&gt;
&lt;/g&gt;
&lt;!-- B --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;B&lt;/title&gt;
&lt;polygon fill=&quot;#f0f4ff&quot; stroke=&quot;black&quot; points=&quot;313.84,-41.6 192.03,-41.6 192.03,0 313.84,0 313.84,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;252.93&quot; y=&quot;-25&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;14.00&quot;&gt;Entropy Vs Gini&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;252.93&quot; y=&quot;-8.2&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;14.00&quot;&gt;Core Mechanism&lt;/text&gt;
&lt;/g&gt;
&lt;!-- A&amp;#45;&amp;gt;B --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;A-&gt;B&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M113.57,-20.8C134.38,-20.8 158.29,-20.8 180.32,-20.8&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;180.12,-24.3 190.12,-20.8 180.12,-17.3 180.12,-24.3&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;152.64&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;triggers&lt;/text&gt;
&lt;/g&gt;
&lt;!-- C --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;C&lt;/title&gt;
&lt;polygon fill=&quot;#f0f4ff&quot; stroke=&quot;black&quot; points=&quot;513.64,-41.6 400.38,-41.6 400.38,0 513.64,0 513.64,-41.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;457.01&quot; y=&quot;-25&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;14.00&quot;&gt;Entropy Vs Gini&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;457.01&quot; y=&quot;-8.2&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;14.00&quot;&gt;Output&lt;/text&gt;
&lt;/g&gt;
&lt;!-- B&amp;#45;&amp;gt;C --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;B-&gt;C&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M314.29,-20.8C337.78,-20.8 364.8,-20.8 388.9,-20.8&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;388.59,-24.3 398.59,-20.8 388.59,-17.3 388.59,-24.3&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;357.11&quot; y=&quot;-25&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;produces&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;semantic-network&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Semantic Network&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#semantic-network&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: semantic_entropy_vs_gini Pages: 1 --&gt;
&lt;svg width=&quot;183pt&quot; height=&quot;170pt&quot; viewBox=&quot;0.00 0.00 183.00 170.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 165.63)&quot;&gt;
&lt;title&gt;semantic_entropy_vs_gini&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-165.63 178.88,-165.63 178.88,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- THIS --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;THIS&lt;/title&gt;
&lt;ellipse fill=&quot;#ffd700&quot; stroke=&quot;black&quot; stroke-width=&quot;2&quot; cx=&quot;70.39&quot; cy=&quot;-86.21&quot; rx=&quot;70.39&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;70.39&quot; y=&quot;-82.31&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;13.00&quot;&gt;Entropy Vs Gini&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL1 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL1&lt;/title&gt;
&lt;ellipse fill=&quot;#f0f0f0&quot; stroke=&quot;black&quot; cx=&quot;114.29&quot; cy=&quot;-143.63&quot; rx=&quot;60.59&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;114.29&quot; y=&quot;-140.33&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Related Concept&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL1 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M84.04,-104.06C89.38,-111.04 95.48,-119.02 100.8,-125.98&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;73.38&quot; y=&quot;-119.22&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;related&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL2 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL2&lt;/title&gt;
&lt;ellipse fill=&quot;#d4edda&quot; stroke=&quot;black&quot; cx=&quot;46.44&quot; cy=&quot;-18&quot; rx=&quot;41.67&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;46.44&quot; y=&quot;-14.7&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Builds Into&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL2 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M63.97,-67.93C60.48,-57.98 56.18,-45.73 52.71,-35.86&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;88.09&quot; y=&quot;-39.29&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;builds into&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;a href=&quot;../../entropy&quot; class=&quot;internal alias&quot; data-slug=&quot;entropy&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Entropy&lt;/a&gt; — left side of this comparison&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../gini-index&quot; class=&quot;internal alias&quot; data-slug=&quot;gini-index&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Gini Index&lt;/a&gt; — right side of this comparison&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../information-gain&quot; class=&quot;internal alias&quot; data-slug=&quot;information-gain&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Information Gain&lt;/a&gt; — entropy’s application in decision trees&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../attribute-selection-measures&quot; class=&quot;internal alias&quot; data-slug=&quot;attribute-selection-measures&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Attribute Selection Measures&lt;/a&gt; — both are selection measures&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../decision-tree-splitting&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-splitting&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Splitting&lt;/a&gt; — both drive split decisions&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../entropy-calculation&quot; class=&quot;internal alias&quot; data-slug=&quot;entropy-calculation&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Entropy Calculation&lt;/a&gt; — detailed entropy computation&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;../../gini-index-properties&quot; class=&quot;internal alias&quot; data-slug=&quot;gini-index-properties&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Gini Index Properties&lt;/a&gt; — detailed Gini characteristics&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>entropy</title>
    <link href="https://animishraa05.github.io/wiki/decision-tree/entropy" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/decision-tree/entropy.md" />
    <summary>The Problem When building a decision tree, we need a mathematical way to quantify “how mixed up” a dataset is.</summary>
    <published>2026-05-06T00:00:00.000Z</published>
    <updated>2026-05-06T00:00:00.000Z</updated>
    <publishedTime>May 06, 2026</publishedTime>
    <updatedTime>May 06, 2026</updatedTime>
    <category term="ml" label="ml" />
<category term="decision-trees" label="decision-trees" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;When building a decision tree, we need a mathematical way to quantify “how mixed up” a dataset is. Without a numerical measure of impurity, we cannot compare different split options or determine which attribute best separates the classes.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Entropy is a measure of uncertainty or impurity in a dataset. It quantifies how unpredictable the class label of a randomly chosen instance would be. Higher entropy means more uncertainty (equal class distribution); entropy of 0 means perfect purity (all instances belong to one class).&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Entropy is calculated using the probability distribution of class labels:&lt;/p&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;H&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;mi&gt;S&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;msubsup&gt;&lt;mo&gt;∑&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;mi&gt;c&lt;/mi&gt;&lt;/msubsup&gt;&lt;msub&gt;&lt;mi&gt;p&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;/msub&gt;&lt;msub&gt;&lt;mrow&gt;&lt;mi&gt;log&lt;/mi&gt;&lt;mo&gt;⁡&lt;/mo&gt;&lt;/mrow&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;p&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;H(S) = -\sum_{i=1}^{c} p_i \log_2(p_i)&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1em;vertical-align:-0.25em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.0813em;&quot;&gt;H&lt;/span&gt;&lt;span class=&quot;mopen&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.0576em;&quot;&gt;S&lt;/span&gt;&lt;span class=&quot;mclose&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1.104em;vertical-align:-0.2997em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;−&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.1667em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mop&quot;&gt;&lt;span class=&quot;mop op-symbol small-op&quot; style=&quot;position:relative;top:0em;&quot;&gt;∑&lt;/span&gt;&lt;span class=&quot;msupsub&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.8043em;&quot;&gt;&lt;span style=&quot;top:-2.4003em;margin-left:0em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;mrel mtight&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mord mtight&quot;&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;top:-3.2029em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;c&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.2997em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.1667em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;msupsub&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.3117em;&quot;&gt;&lt;span style=&quot;top:-2.55em;margin-left:0em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.15em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.1667em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mop&quot;&gt;&lt;span class=&quot;mop&quot;&gt;lo&lt;span style=&quot;margin-right:0.0139em;&quot;&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;msupsub&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.207em;&quot;&gt;&lt;span style=&quot;top:-2.4559em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.2441em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mopen&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;msupsub&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.3117em;&quot;&gt;&lt;span style=&quot;top:-2.55em;margin-left:0em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.15em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mclose&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p dir=&quot;auto&quot;&gt;Where:&lt;/p&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;S&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;S&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6833em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.0576em;&quot;&gt;S&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; is the dataset&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;c&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;c&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.4306em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;c&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; is the number of classes&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msub&gt;&lt;mi&gt;p&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;/msub&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;p_i&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.625em;vertical-align:-0.1944em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;msupsub&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.3117em;&quot;&gt;&lt;span style=&quot;top:-2.55em;margin-left:0em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.15em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; is the proportion of instances belonging to class &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;i&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6595em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;strong&gt;Key behaviors:&lt;/strong&gt;&lt;/p&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Maximum entropy&lt;/strong&gt;: When classes are equally distributed (e.g., 3 “Yes” and 3 “No” → entropy ≈ 1.0)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Zero entropy&lt;/strong&gt;: When all instances belong to one class (e.g., 6 “Yes” and 0 “No” → entropy = 0)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Intermediate&lt;/strong&gt;: Any mixed distribution produces entropy between 0 and &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msub&gt;&lt;mrow&gt;&lt;mi&gt;log&lt;/mi&gt;&lt;mo&gt;⁡&lt;/mo&gt;&lt;/mrow&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;mi&gt;c&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;\log_2(c)&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1em;vertical-align:-0.25em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mop&quot;&gt;&lt;span class=&quot;mop&quot;&gt;lo&lt;span style=&quot;margin-right:0.0139em;&quot;&gt;g&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;msupsub&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.207em;&quot;&gt;&lt;span style=&quot;top:-2.4559em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.2441em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mopen&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;mclose&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p dir=&quot;auto&quot;&gt;The source example calculates entropy for X = {a, a, a, b, b, b, b, b}:&lt;/p&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;P(a) = 3/8 = 0.375, P(b) = 5/8 = 0.625&lt;/li&gt;
&lt;li&gt;H(X) = -[0.375 × log₂(0.375) + 0.625 × log₂(0.625)]&lt;/li&gt;
&lt;li&gt;H(X) = -[0.375 × (-1.415) + 0.625 × (-0.678)]&lt;/li&gt;
&lt;li&gt;H(X) = -(-0.53 - 0.424) = &lt;strong&gt;0.954&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p dir=&quot;auto&quot;&gt;This high entropy (near 1.0) reflects that the dataset is quite mixed, with no dominant class.&lt;/p&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: entropy Pages: 1 --&gt;
&lt;svg width=&quot;892pt&quot; height=&quot;110pt&quot; viewBox=&quot;0.00 0.00 892.00 110.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 106.4)&quot;&gt;
&lt;title&gt;entropy&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-106.4 887.81,-106.4 887.81,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- dataset --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;dataset&lt;/title&gt;
&lt;ellipse fill=&quot;#e8e8e8&quot; stroke=&quot;black&quot; cx=&quot;77.33&quot; cy=&quot;-51.2&quot; rx=&quot;77.33&quot; ry=&quot;26.02&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;77.33&quot; y=&quot;-54.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Dataset S&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;77.33&quot; y=&quot;-40.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Class Distribution&lt;/text&gt;
&lt;/g&gt;
&lt;!-- probs --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;probs&lt;/title&gt;
&lt;polygon fill=&quot;#cce5ff&quot; stroke=&quot;black&quot; points=&quot;347.28,-69.6 251.25,-69.6 251.25,-32.8 347.28,-32.8 347.28,-69.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;299.27&quot; y=&quot;-54.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Calculate pᵢ&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;299.27&quot; y=&quot;-40.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;for each class i&lt;/text&gt;
&lt;/g&gt;
&lt;!-- dataset&amp;#45;&amp;gt;probs --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;dataset-&gt;probs&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M154.95,-51.2C182.81,-51.2 213.82,-51.2 239.86,-51.2&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;239.55,-54.7 249.55,-51.2 239.55,-47.7 239.55,-54.7&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;202.96&quot; y=&quot;-54.2&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;count classes&lt;/text&gt;
&lt;/g&gt;
&lt;!-- formula --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;formula&lt;/title&gt;
&lt;polygon fill=&quot;#ffd700&quot; stroke=&quot;black&quot; points=&quot;560.12,-69.2 421.09,-69.2 421.09,-33.2 560.12,-33.2 560.12,-69.2&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;490.6&quot; y=&quot;-47.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;H(S) = -Σ pᵢ log₂(pᵢ)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- probs&amp;#45;&amp;gt;formula --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;probs-&gt;formula&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M347.56,-51.2C366.31,-51.2 388.41,-51.2 409.51,-51.2&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;409.26,-54.7 419.26,-51.2 409.26,-47.7 409.26,-54.7&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;384.19&quot; y=&quot;-54.2&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;plug into&lt;/text&gt;
&lt;/g&gt;
&lt;!-- entropy_val --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;entropy_val&lt;/title&gt;
&lt;polygon fill=&quot;#d4edda&quot; stroke=&quot;black&quot; points=&quot;752.75,-102.4 621.69,-51.2 752.75,0 883.81,-51.2 752.75,-102.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;752.75&quot; y=&quot;-62&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Entropy Value&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;752.75&quot; y=&quot;-47.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;0 = pure&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;752.75&quot; y=&quot;-33.2&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;1.0 = max uncertainty&lt;/text&gt;
&lt;/g&gt;
&lt;!-- formula&amp;#45;&amp;gt;entropy_val --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;formula-&gt;entropy_val&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M560.29,-51.2C575.54,-51.2 592.25,-51.2 609.25,-51.2&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;608.94,-54.7 618.94,-51.2 608.94,-47.7 608.94,-54.7&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;590.9&quot; y=&quot;-54.2&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;yields&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Range&lt;/strong&gt;: 0 (pure) to log₂(c) (maximum impurity for c classes); for binary classification, range is [0, 1]&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Log base 2&lt;/strong&gt;: Uses base-2 logarithm, so entropy is measured in bits&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Additive&lt;/strong&gt;: Entropy of combined systems equals the sum of individual entropies (for independent systems)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Symmetric&lt;/strong&gt;: Depends only on the probability distribution, not on class labels or ordering&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;semantic-network&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Semantic Network&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#semantic-network&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: semantic_Entropy Pages: 1 --&gt;
&lt;svg width=&quot;184pt&quot; height=&quot;170pt&quot; viewBox=&quot;0.00 0.00 184.00 170.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 165.63)&quot;&gt;
&lt;title&gt;semantic_Entropy&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-165.63 179.95,-165.63 179.95,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- THIS --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;THIS&lt;/title&gt;
&lt;ellipse fill=&quot;#ffd700&quot; stroke=&quot;black&quot; stroke-width=&quot;2&quot; cx=&quot;71.46&quot; cy=&quot;-86.21&quot; rx=&quot;40.26&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;71.46&quot; y=&quot;-82.31&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;13.00&quot;&gt;Entropy&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL1 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL1&lt;/title&gt;
&lt;ellipse fill=&quot;#f0f0f0&quot; stroke=&quot;black&quot; cx=&quot;115.36&quot; cy=&quot;-143.63&quot; rx=&quot;60.59&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;115.36&quot; y=&quot;-140.33&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Related Concept&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL1 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M84.63,-103.43C89.99,-110.44 96.18,-118.53 101.59,-125.61&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;112.15&quot; y=&quot;-101.92&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;related&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL2 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL2&lt;/title&gt;
&lt;ellipse fill=&quot;#d4edda&quot; stroke=&quot;black&quot; cx=&quot;47.51&quot; cy=&quot;-18&quot; rx=&quot;41.67&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;47.51&quot; y=&quot;-14.7&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Builds Into&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL2 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M65.17,-68.29C61.68,-58.34 57.34,-46 53.84,-36.04&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;29.75&quot; y=&quot;-56.36&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;builds into&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../information-gain&quot; class=&quot;internal alias&quot; data-slug=&quot;information-gain&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Information Gain&lt;/a&gt; — Information Gain is calculated as Entropy(parent) - weighted Entropy(children)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../node-purity&quot; class=&quot;internal alias&quot; data-slug=&quot;node-purity&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Node Purity&lt;/a&gt; — entropy is the mathematical formalization of purity&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../gini-index&quot; class=&quot;internal alias&quot; data-slug=&quot;gini-index&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Gini Index&lt;/a&gt; — both measure impurity but with different formulas and sensitivities&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../decision-tree-splitting&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-splitting&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Splitting&lt;/a&gt; — entropy drives split decisions&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../attribute-selection-measures&quot; class=&quot;internal alias&quot; data-slug=&quot;attribute-selection-measures&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Attribute Selection Measures&lt;/a&gt; — entropy is the foundation of Information Gain&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../entropy-calculation&quot; class=&quot;internal alias&quot; data-slug=&quot;entropy-calculation&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Entropy Calculation&lt;/a&gt; — detailed formula and worked example&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Log(0) undefined&lt;/strong&gt;: If a class has zero instances, that term is treated as 0 (by convention, 0 × log(0) = 0)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Multi-class scaling&lt;/strong&gt;: Entropy increases with the number of classes even at maximum impurity&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Computation cost&lt;/strong&gt;: Logarithm calculations are more expensive than Gini’s squaring&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Not scale-invariant&lt;/strong&gt;: Entropy depends on proportions, not absolute counts — a 50/50 split of 10 samples has the same entropy as 50/50 of 10,000&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>gini-index-properties</title>
    <link href="https://animishraa05.github.io/wiki/decision-tree/gini-index-properties" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/decision-tree/gini-index-properties.md" />
    <summary>The Problem Knowing the Gini Index formula is not enough — practitioners need to understand its specific behaviors, strengths, weaknesses, and when it outperforms or underperforms compared to entropy to make informed algorithm choices.</summary>
    <published>2026-05-06T00:00:00.000Z</published>
    <updated>2026-05-06T00:00:00.000Z</updated>
    <publishedTime>May 06, 2026</publishedTime>
    <updatedTime>May 06, 2026</updatedTime>
    <category term="ml" label="ml" />
<category term="decision-trees" label="decision-trees" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Knowing the Gini Index formula is not enough — practitioners need to understand its specific behaviors, strengths, weaknesses, and when it outperforms or underperforms compared to entropy to make informed algorithm choices.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;The Gini Index has six distinctive properties: it uses squared probability sums, indicates purity with lower values, evaluates split quality by comparing parent and child impurity, is faster to compute than entropy, favors equally-sized splits, and requires empirical tuning for optimal use.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;These properties manifest in practice:&lt;/p&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Squared probability computation&lt;/strong&gt;: &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;G&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mo&gt;∑&lt;/mo&gt;&lt;msubsup&gt;&lt;mi&gt;p&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;/msubsup&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;Gini = 1 - \sum p_i^2&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6833em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;G&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;ini&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.7278em;vertical-align:-0.0833em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mbin&quot;&gt;−&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1.0728em;vertical-align:-0.2587em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mop op-symbol small-op&quot; style=&quot;position:relative;top:0em;&quot;&gt;∑&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.1667em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;msupsub&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.8141em;&quot;&gt;&lt;span style=&quot;top:-2.4413em;margin-left:0em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;top:-3.063em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.2587em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; — summing squared probabilities and subtracting from 1&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Lower = purer&lt;/strong&gt;: A Gini of 0 means perfect homogeneity (all same class); higher values indicate more mixing&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Split evaluation&lt;/strong&gt;: Compares parent impurity to weighted child impurity; the difference indicates split quality&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Computational speed&lt;/strong&gt;: Squaring is faster than logarithm calculation — significant for large datasets with many attributes&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Equal-size bias&lt;/strong&gt;: The math naturally rewards splits that divide data evenly, which may not always align with classification accuracy&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Problem-dependent&lt;/strong&gt;: No single impurity measure is universally best; the choice depends on the specific dataset and requires experimentation&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: gini_properties Pages: 1 --&gt;
&lt;svg width=&quot;186pt&quot; height=&quot;464pt&quot; viewBox=&quot;0.00 0.00 186.00 464.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 460)&quot;&gt;
&lt;title&gt;gini_properties&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-460 182.01,-460 182.01,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- formula --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;formula&lt;/title&gt;
&lt;polygon fill=&quot;#cce5ff&quot; stroke=&quot;black&quot; points=&quot;155.4,-456 22.61,-456 22.61,-420 155.4,-420 155.4,-456&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;89.01&quot; y=&quot;-441.3&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;1. Squared Probabilities&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;89.01&quot; y=&quot;-428.1&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Gini = 1 - Σpᵢ²&lt;/text&gt;
&lt;/g&gt;
&lt;!-- scale --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;scale&lt;/title&gt;
&lt;polygon fill=&quot;#d4edda&quot; stroke=&quot;black&quot; points=&quot;142.09,-372 35.92,-372 35.92,-336 142.09,-336 142.09,-372&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;89.01&quot; y=&quot;-357.3&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;2. Scale: 0 = pure&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;89.01&quot; y=&quot;-344.1&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;0.5 = max impurity&lt;/text&gt;
&lt;/g&gt;
&lt;!-- formula&amp;#45;&amp;gt;scale --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;formula-&gt;scale&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M89.01,-419.61C89.01,-409.17 89.01,-395.64 89.01,-383.66&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;92.51,-383.88 89.01,-373.88 85.51,-383.88 92.51,-383.88&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;124.58&quot; y=&quot;-393&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;properties chain&lt;/text&gt;
&lt;/g&gt;
&lt;!-- split_eval --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;split_eval&lt;/title&gt;
&lt;polygon fill=&quot;#e8d5f5&quot; stroke=&quot;black&quot; points=&quot;178.01,-288 0,-288 0,-252 178.01,-252 178.01,-288&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;89.01&quot; y=&quot;-273.3&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;3. Split Quality&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;89.01&quot; y=&quot;-260.1&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Parent Gini - Weighted Child Gini&lt;/text&gt;
&lt;/g&gt;
&lt;!-- scale&amp;#45;&amp;gt;split_eval --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;scale-&gt;split_eval&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M89.01,-335.61C89.01,-325.17 89.01,-311.64 89.01,-299.66&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;92.51,-299.88 89.01,-289.88 85.51,-299.88 92.51,-299.88&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;124.58&quot; y=&quot;-309&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;properties chain&lt;/text&gt;
&lt;/g&gt;
&lt;!-- speed --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;speed&lt;/title&gt;
&lt;polygon fill=&quot;#d4edda&quot; stroke=&quot;black&quot; points=&quot;150.82,-204 27.2,-204 27.2,-168 150.82,-168 150.82,-204&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;89.01&quot; y=&quot;-189.3&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;4. Fast Computation&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;89.01&quot; y=&quot;-176.1&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;No logarithms needed&lt;/text&gt;
&lt;/g&gt;
&lt;!-- split_eval&amp;#45;&amp;gt;speed --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;split_eval-&gt;speed&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M89.01,-251.61C89.01,-241.17 89.01,-227.64 89.01,-215.66&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;92.51,-215.88 89.01,-205.88 85.51,-215.88 92.51,-215.88&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;124.58&quot; y=&quot;-225&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;properties chain&lt;/text&gt;
&lt;/g&gt;
&lt;!-- bias --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;bias&lt;/title&gt;
&lt;polygon fill=&quot;#ffcccc&quot; stroke=&quot;black&quot; points=&quot;151.73,-120 26.29,-120 26.29,-84 151.73,-84 151.73,-120&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;89.01&quot; y=&quot;-105.3&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;5. Equal-Size Bias&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;89.01&quot; y=&quot;-92.1&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Favors balanced splits&lt;/text&gt;
&lt;/g&gt;
&lt;!-- speed&amp;#45;&amp;gt;bias --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;speed-&gt;bias&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M89.01,-167.61C89.01,-157.17 89.01,-143.64 89.01,-131.66&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;92.51,-131.88 89.01,-121.88 85.51,-131.88 92.51,-131.88&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;124.58&quot; y=&quot;-141&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;properties chain&lt;/text&gt;
&lt;/g&gt;
&lt;!-- tuning --&gt;
&lt;g id=&quot;node6&quot; class=&quot;node&quot;&gt;
&lt;title&gt;tuning&lt;/title&gt;
&lt;polygon fill=&quot;#ffd700&quot; stroke=&quot;black&quot; points=&quot;150.2,-36 27.81,-36 27.81,0 150.2,0 150.2,-36&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;89.01&quot; y=&quot;-21.3&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;6. Requires Tuning&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;89.01&quot; y=&quot;-8.1&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Experiment to choose&lt;/text&gt;
&lt;/g&gt;
&lt;!-- bias&amp;#45;&amp;gt;tuning --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;bias-&gt;tuning&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; stroke-dasharray=&quot;5 2&quot; d=&quot;M89.01,-83.61C89.01,-73.17 89.01,-59.64 89.01,-47.66&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;92.51,-47.88 89.01,-37.88 85.51,-47.88 92.51,-47.88&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;124.58&quot; y=&quot;-57&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;properties chain&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Computationally efficient&lt;/strong&gt;: O(c) per split where c is number of classes — no expensive log operations&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Bounded&lt;/strong&gt;: Always between 0 and 0.5 for binary, 0 and (1 - 1/c) for c classes&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Continuous&lt;/strong&gt;: Smooth function of class probabilities, unlike some discrete measures&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Skew-sensitive&lt;/strong&gt;: More responsive to probability changes near 0 or 1 than near 0.5&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;semantic-network&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Semantic Network&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#semantic-network&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: semantic_Gini_Index_Properties Pages: 1 --&gt;
&lt;svg width=&quot;199pt&quot; height=&quot;170pt&quot; viewBox=&quot;0.00 0.00 199.00 170.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 165.63)&quot;&gt;
&lt;title&gt;semantic_Gini_Index_Properties&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-165.63 195.15,-165.63 195.15,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- THIS --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;THIS&lt;/title&gt;
&lt;ellipse fill=&quot;#ffd700&quot; stroke=&quot;black&quot; stroke-width=&quot;2&quot; cx=&quot;86.67&quot; cy=&quot;-86.21&quot; rx=&quot;86.67&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;86.67&quot; y=&quot;-82.31&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;13.00&quot;&gt;Gini Index Propertie&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL1 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL1&lt;/title&gt;
&lt;ellipse fill=&quot;#f0f0f0&quot; stroke=&quot;black&quot; cx=&quot;130.56&quot; cy=&quot;-143.63&quot; rx=&quot;60.59&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;130.56&quot; y=&quot;-140.33&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Related Concept&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL1 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M100.56,-104.37C105.78,-111.21 111.71,-118.97 116.91,-125.77&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;89.69&quot; y=&quot;-119.27&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;related&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL2 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL2&lt;/title&gt;
&lt;ellipse fill=&quot;#d4edda&quot; stroke=&quot;black&quot; cx=&quot;62.71&quot; cy=&quot;-18&quot; rx=&quot;41.67&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;62.71&quot; y=&quot;-14.7&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Builds Into&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL2 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M80.25,-67.93C76.75,-57.98 72.45,-45.73 68.98,-35.86&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;104.37&quot; y=&quot;-39.29&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;builds into&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../gini-index&quot; class=&quot;internal alias&quot; data-slug=&quot;gini-index&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Gini Index&lt;/a&gt; — this page details the specific properties of the Gini measure&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../entropy&quot; class=&quot;internal alias&quot; data-slug=&quot;entropy&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Entropy&lt;/a&gt; — entropy uses logs (slower) but is information-theoretic&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../decision-tree-splitting&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-splitting&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Splitting&lt;/a&gt; — properties affect split quality evaluation&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../entropy-vs-gini&quot; class=&quot;internal alias&quot; data-slug=&quot;entropy-vs-gini&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Entropy vs Gini Compared&lt;/a&gt; — synthesis comparing both impurity measures&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../attribute-selection-measures&quot; class=&quot;internal alias&quot; data-slug=&quot;attribute-selection-measures&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Attribute Selection Measures&lt;/a&gt; — Gini is one of the measures&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../gini-index&quot; class=&quot;internal alias&quot; data-slug=&quot;gini-index&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Gini Index&lt;/a&gt; — the base concept this page elaborates&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Equal-size trap&lt;/strong&gt;: A split creating 50/50 balanced but still impure groups may score better than an unbalanced but purer split&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Sklearn default&lt;/strong&gt;: If you don’t specify a criterion, sklearn uses “gini” — this may not be optimal for your data&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Not comparable to entropy values&lt;/strong&gt;: A Gini of 0.3 does not correspond to an entropy of 0.3; they use different scales&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Ties with entropy&lt;/strong&gt;: In most practical cases, Gini and entropy produce the same splits despite different values&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>gini-index</title>
    <link href="https://animishraa05.github.io/wiki/decision-tree/gini-index" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/decision-tree/gini-index.md" />
    <summary>The Problem Entropy-based Information Gain requires logarithmic computations, which are relatively expensive.</summary>
    <published>2026-05-06T00:00:00.000Z</published>
    <updated>2026-05-06T00:00:00.000Z</updated>
    <publishedTime>May 06, 2026</publishedTime>
    <updatedTime>May 06, 2026</updatedTime>
    <category term="ml" label="ml" />
<category term="decision-trees" label="decision-trees" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Entropy-based Information Gain requires logarithmic computations, which are relatively expensive. Decision tree algorithms need a faster impurity measure that produces similar quality splits without the computational overhead.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;The Gini Index measures the probability that a randomly chosen element from a dataset would be incorrectly classified if it were labeled according to the class distribution in that dataset. Lower Gini Index means purer subsets; a Gini of 0 indicates perfect purity.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;The Gini Index formula:&lt;/p&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;G&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;msubsup&gt;&lt;mo&gt;∑&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;/msubsup&gt;&lt;msubsup&gt;&lt;mi&gt;p&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;/msubsup&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;Gini = 1 - \sum_{i=1}^{n} p_i^2&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6833em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;G&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;ini&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.7278em;vertical-align:-0.0833em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mbin&quot;&gt;−&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1.1138em;vertical-align:-0.2997em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mop&quot;&gt;&lt;span class=&quot;mop op-symbol small-op&quot; style=&quot;position:relative;top:0em;&quot;&gt;∑&lt;/span&gt;&lt;span class=&quot;msupsub&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.8043em;&quot;&gt;&lt;span style=&quot;top:-2.4003em;margin-left:0em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;mrel mtight&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mord mtight&quot;&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;top:-3.2029em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;n&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.2997em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.1667em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;msupsub&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.8141em;&quot;&gt;&lt;span style=&quot;top:-2.4413em;margin-left:0em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;top:-3.063em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.2587em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p dir=&quot;auto&quot;&gt;Where &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msub&gt;&lt;mi&gt;p&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;/msub&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;p_i&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.625em;vertical-align:-0.1944em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;msupsub&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.3117em;&quot;&gt;&lt;span style=&quot;top:-2.55em;margin-left:0em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.15em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; is the probability of class &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;i&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6595em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; in the dataset.&lt;/p&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;strong&gt;Key behaviors:&lt;/strong&gt;&lt;/p&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Perfect purity (Gini = 0)&lt;/strong&gt;: All instances belong to one class → &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mo&gt;∑&lt;/mo&gt;&lt;msubsup&gt;&lt;mi&gt;p&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;/msubsup&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;\sum p_i^2 = 1&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1.0728em;vertical-align:-0.2587em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mop op-symbol small-op&quot; style=&quot;position:relative;top:0em;&quot;&gt;∑&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.1667em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;msupsub&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.8141em;&quot;&gt;&lt;span style=&quot;top:-2.4413em;margin-left:0em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;top:-3.063em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.2587em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6444em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; → &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;G&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;0&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;Gini = 0&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6833em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;G&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;ini&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6444em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Example: 100% “Yes” → &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;msup&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;/msup&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;0&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;1 - 1^2 = 0&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.7278em;vertical-align:-0.0833em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mbin&quot;&gt;−&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.8141em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mord&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;msupsub&quot;&gt;&lt;span class=&quot;vlist-t&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.8141em;&quot;&gt;&lt;span style=&quot;top:-3.063em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6444em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Maximum impurity (binary, Gini = 0.5)&lt;/strong&gt;: Equal class distribution → &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mo&gt;∑&lt;/mo&gt;&lt;msubsup&gt;&lt;mi&gt;p&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;/msubsup&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;0.5&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;\sum p_i^2 = 0.5&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1.0728em;vertical-align:-0.2587em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mop op-symbol small-op&quot; style=&quot;position:relative;top:0em;&quot;&gt;∑&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.1667em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;msupsub&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.8141em;&quot;&gt;&lt;span style=&quot;top:-2.4413em;margin-left:0em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;top:-3.063em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.2587em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6444em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;0.5&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; → &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;G&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;0.5&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;Gini = 0.5&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6833em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;G&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;ini&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6444em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;0.5&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Example: 50% “Yes”, 50% “No” → &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;mn&gt;0.25&lt;/mn&gt;&lt;mo&gt;+&lt;/mo&gt;&lt;mn&gt;0.25&lt;/mn&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mn&gt;0.5&lt;/mn&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;1 - (0.25 + 0.25) = 0.5&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.7278em;vertical-align:-0.0833em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mbin&quot;&gt;−&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1em;vertical-align:-0.25em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mopen&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;0.25&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mbin&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1em;vertical-align:-0.25em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;0.25&lt;/span&gt;&lt;span class=&quot;mclose&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6444em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;0.5&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;strong&gt;How it’s used in splitting:&lt;/strong&gt;&lt;/p&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Calculate the Gini Index for each potential split&lt;/li&gt;
&lt;li&gt;Compute the weighted Gini of the child nodes&lt;/li&gt;
&lt;li&gt;Choose the split with the lowest weighted Gini Index&lt;/li&gt;
&lt;/ol&gt;
&lt;p dir=&quot;auto&quot;&gt;The Gini Index is the default criterion in scikit-learn’s DecisionTreeClassifier. It is faster to compute than entropy (no logarithms needed — just squaring and summing probabilities) and is more sensitive to changes in class probabilities near the extremes.&lt;/p&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: gini_index Pages: 1 --&gt;
&lt;svg width=&quot;833pt&quot; height=&quot;110pt&quot; viewBox=&quot;0.00 0.00 833.00 110.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 106.4)&quot;&gt;
&lt;title&gt;gini_index&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-106.4 829.19,-106.4 829.19,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- dataset --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;dataset&lt;/title&gt;
&lt;ellipse fill=&quot;#e8e8e8&quot; stroke=&quot;black&quot; cx=&quot;77.33&quot; cy=&quot;-51.2&quot; rx=&quot;77.33&quot; ry=&quot;26.02&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;77.33&quot; y=&quot;-54.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Dataset&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;77.33&quot; y=&quot;-40.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Class Distribution&lt;/text&gt;
&lt;/g&gt;
&lt;!-- probs --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;probs&lt;/title&gt;
&lt;polygon fill=&quot;#cce5ff&quot; stroke=&quot;black&quot; points=&quot;280.7,-69.6 190.66,-69.6 190.66,-32.8 280.7,-32.8 280.7,-69.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;235.68&quot; y=&quot;-54.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Calculate pᵢ&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;235.68&quot; y=&quot;-40.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;for each class&lt;/text&gt;
&lt;/g&gt;
&lt;!-- dataset&amp;#45;&amp;gt;probs --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;dataset-&gt;probs&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M155.13,-51.2C163.13,-51.2 171.15,-51.2 178.85,-51.2&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;178.75,-54.7 188.75,-51.2 178.75,-47.7 178.75,-54.7&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- square --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;square&lt;/title&gt;
&lt;polygon fill=&quot;#e8d5f5&quot; stroke=&quot;black&quot; points=&quot;420.76,-69.6 316.7,-69.6 316.7,-32.8 420.76,-32.8 420.76,-69.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;368.73&quot; y=&quot;-54.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Square each pᵢ&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;368.73&quot; y=&quot;-40.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Sum them up&lt;/text&gt;
&lt;/g&gt;
&lt;!-- probs&amp;#45;&amp;gt;square --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;probs-&gt;square&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M281.05,-51.2C288.82,-51.2 297.04,-51.2 305.19,-51.2&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;305.11,-54.7 315.11,-51.2 305.11,-47.7 305.11,-54.7&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- formula --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;formula&lt;/title&gt;
&lt;polygon fill=&quot;#ffd700&quot; stroke=&quot;black&quot; points=&quot;563.11,-69.2 456.76,-69.2 456.76,-33.2 563.11,-33.2 563.11,-69.2&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;509.94&quot; y=&quot;-47.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Gini = 1 - Σ(pᵢ²)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- square&amp;#45;&amp;gt;formula --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;square-&gt;formula&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M421.17,-51.2C428.87,-51.2 436.89,-51.2 444.81,-51.2&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;444.8,-54.7 454.8,-51.2 444.8,-47.7 444.8,-54.7&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- result --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;result&lt;/title&gt;
&lt;polygon fill=&quot;#d4edda&quot; stroke=&quot;black&quot; points=&quot;712.15,-102.4 599.11,-51.2 712.15,0 825.19,-51.2 712.15,-102.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;712.15&quot; y=&quot;-62&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Gini Value&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;712.15&quot; y=&quot;-47.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;0 = pure&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;712.15&quot; y=&quot;-33.2&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;0.5 = max (binary)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- formula&amp;#45;&amp;gt;result --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;formula-&gt;result&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M563.54,-51.2C570.86,-51.2 578.63,-51.2 586.61,-51.2&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;586.52,-54.7 596.52,-51.2 586.52,-47.7 586.52,-54.7&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Range [0, 0.5]&lt;/strong&gt;: For binary classification, Gini ranges from 0 (pure) to 0.5 (max impurity)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Faster than entropy&lt;/strong&gt;: No logarithm computation — only multiplication and addition&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Sensitive to changes&lt;/strong&gt;: More responsive to shifts in class probabilities near the extremes&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Default in sklearn&lt;/strong&gt;: The most commonly used impurity measure in practice&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;semantic-network&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Semantic Network&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#semantic-network&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: semantic_Gini_Index Pages: 1 --&gt;
&lt;svg width=&quot;178pt&quot; height=&quot;170pt&quot; viewBox=&quot;0.00 0.00 178.00 170.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 165.63)&quot;&gt;
&lt;title&gt;semantic_Gini_Index&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-165.63 174.12,-165.63 174.12,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- THIS --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;THIS&lt;/title&gt;
&lt;ellipse fill=&quot;#ffd700&quot; stroke=&quot;black&quot; stroke-width=&quot;2&quot; cx=&quot;65.63&quot; cy=&quot;-86.21&quot; rx=&quot;49.35&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;65.63&quot; y=&quot;-82.31&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;13.00&quot;&gt;Gini Index&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL1 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL1&lt;/title&gt;
&lt;ellipse fill=&quot;#f0f0f0&quot; stroke=&quot;black&quot; cx=&quot;109.53&quot; cy=&quot;-143.63&quot; rx=&quot;60.59&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;109.53&quot; y=&quot;-140.33&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Related Concept&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL1 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M79.04,-103.75C84.39,-110.74 90.53,-118.78 95.9,-125.8&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;106.51&quot; y=&quot;-102.17&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;related&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL2 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL2&lt;/title&gt;
&lt;ellipse fill=&quot;#d4edda&quot; stroke=&quot;black&quot; cx=&quot;41.67&quot; cy=&quot;-18&quot; rx=&quot;41.67&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;41.67&quot; y=&quot;-14.7&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Builds Into&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL2 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M59.21,-67.93C55.72,-57.98 51.42,-45.73 47.95,-35.86&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;83.33&quot; y=&quot;-39.29&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;builds into&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../entropy&quot; class=&quot;internal alias&quot; data-slug=&quot;entropy&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Entropy&lt;/a&gt; — Gini uses squared probabilities; entropy uses logarithms&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../decision-tree-splitting&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-splitting&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Splitting&lt;/a&gt; — Gini determines the best split&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../node-purity&quot; class=&quot;internal alias&quot; data-slug=&quot;node-purity&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Node Purity&lt;/a&gt; — Gini quantifies the purity concept&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../attribute-selection-measures&quot; class=&quot;internal alias&quot; data-slug=&quot;attribute-selection-measures&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Attribute Selection Measures&lt;/a&gt; — Gini is a selection criterion&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../information-gain&quot; class=&quot;internal alias&quot; data-slug=&quot;information-gain&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Information Gain&lt;/a&gt; — both serve the same purpose with different formulas&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../gini-index-properties&quot; class=&quot;internal alias&quot; data-slug=&quot;gini-index-properties&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Gini Index Properties&lt;/a&gt; — detailed characteristics and trade-offs&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../entropy-vs-gini&quot; class=&quot;internal alias&quot; data-slug=&quot;entropy-vs-gini&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Entropy vs Gini Compared&lt;/a&gt; — synthesis comparing both measures&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Favors equal-sized splits&lt;/strong&gt;: Tends to prefer splits that create balanced child nodes, even if not optimal for accuracy&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Multi-class scaling&lt;/strong&gt;: Maximum Gini increases with more classes: &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;/&lt;/mi&gt;&lt;mi&gt;c&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;1 - 1/c&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.7278em;vertical-align:-0.0833em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mbin&quot;&gt;−&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1em;vertical-align:-0.25em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;1/&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;c&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; for &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;c&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;c&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.4306em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;c&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; classes&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Near-pure insensitivity&lt;/strong&gt;: When nodes are nearly pure, Gini changes are very small, which can cause premature stopping&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Not information-theoretic&lt;/strong&gt;: Unlike entropy, Gini has no connection to information theory or bits&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>id3-algorithm</title>
    <link href="https://animishraa05.github.io/wiki/decision-tree/id3-algorithm" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/decision-tree/id3-algorithm.md" />
    <summary>The Problem To build a decision tree systematically, we need a concrete algorithm that specifies exactly how to choose attributes, how to split data, when to stop, and how to handle edge cases — not just the intuition but the precise step-by-step procedure.</summary>
    <published>2026-05-06T00:00:00.000Z</published>
    <updated>2026-05-06T00:00:00.000Z</updated>
    <publishedTime>May 06, 2026</publishedTime>
    <updatedTime>May 06, 2026</updatedTime>
    <category term="ml" label="ml" />
<category term="decision-trees" label="decision-trees" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;To build a decision tree systematically, we need a concrete algorithm that specifies exactly how to choose attributes, how to split data, when to stop, and how to handle edge cases — not just the intuition but the precise step-by-step procedure.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;The ID3 (Iterative Dichotomiser 3) algorithm is the foundational decision tree construction algorithm that uses Information Gain as its attribute selection measure, builds the tree top-down recursively, and handles three stopping conditions: pure class, no attributes remaining, and no instances.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;The ID3 algorithm follows these exact steps:&lt;/p&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Initialize&lt;/strong&gt;: Create the root node with all training instances&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Check stopping conditions&lt;/strong&gt;:
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;If all instances are positive → return leaf labeled “yes”&lt;/li&gt;
&lt;li&gt;If all instances are negative → return leaf labeled “no”&lt;/li&gt;
&lt;li&gt;If no attributes remain → return leaf with majority class&lt;/li&gt;
&lt;li&gt;If no instances remain → return leaf with parent’s majority class&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Select best attribute&lt;/strong&gt;: Calculate Information Gain for each remaining attribute and choose the one with maximum gain&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Create root&lt;/strong&gt;: Label the current node with the selected attribute&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;For each value of the attribute&lt;/strong&gt;:
a. Create a branch for that value
b. Create a subset of instances matching that value
c. If the subset is empty → attach leaf with majority class
d. Otherwise → recursively call ID3 on the subset with remaining attributes&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Return&lt;/strong&gt;: The constructed tree&lt;/li&gt;
&lt;/ol&gt;
&lt;p dir=&quot;auto&quot;&gt;The source describes this as: “Start with all training instances associated with the root node. Use info gain to choose which attribute to label each node with. Recursively construct each subtree on the subset of training instances that would be classified down that path in the tree.”&lt;/p&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: id3_algorithm Pages: 1 --&gt;
&lt;svg width=&quot;436pt&quot; height=&quot;380pt&quot; viewBox=&quot;0.00 0.00 436.00 380.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 376)&quot;&gt;
&lt;title&gt;id3_algorithm&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-376 431.68,-376 431.68,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- init --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;init&lt;/title&gt;
&lt;polygon fill=&quot;#ffd700&quot; stroke=&quot;black&quot; points=&quot;330.58,-372 205.74,-372 205.74,-336 330.58,-336 330.58,-372&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;268.16&quot; y=&quot;-350.7&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Step 1: All data at root&lt;/text&gt;
&lt;/g&gt;
&lt;!-- stop --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;stop&lt;/title&gt;
&lt;polygon fill=&quot;#e8d5f5&quot; stroke=&quot;black&quot; points=&quot;268.16,-288 108.64,-270 268.16,-252 427.68,-270 268.16,-288&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;268.16&quot; y=&quot;-266.7&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Step 2: Check stopping conditions&lt;/text&gt;
&lt;/g&gt;
&lt;!-- init&amp;#45;&amp;gt;stop --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;init-&gt;stop&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M268.16,-335.61C268.16,-325.17 268.16,-311.64 268.16,-299.66&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;271.66,-299.88 268.16,-289.88 264.66,-299.88 271.66,-299.88&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;276.49&quot; y=&quot;-309&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;met&lt;/text&gt;
&lt;/g&gt;
&lt;!-- leaf --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;leaf&lt;/title&gt;
&lt;polygon fill=&quot;#d4edda&quot; stroke=&quot;black&quot; points=&quot;85.16,-204 0,-186 85.16,-168 170.32,-186 85.16,-204&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;85.16&quot; y=&quot;-182.7&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Return leaf node&lt;/text&gt;
&lt;/g&gt;
&lt;!-- stop&amp;#45;&amp;gt;leaf --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;stop-&gt;leaf&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M237.11,-255.09C205.28,-240.82 155.76,-218.64 121.97,-203.5&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;123.53,-200.36 112.97,-199.46 120.67,-206.75 123.53,-200.36&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;195.95&quot; y=&quot;-225&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;met&lt;/text&gt;
&lt;/g&gt;
&lt;!-- select --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;select&lt;/title&gt;
&lt;polygon fill=&quot;#cce5ff&quot; stroke=&quot;black&quot; points=&quot;347.69,-204 188.62,-204 188.62,-168 347.69,-168 347.69,-204&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;268.16&quot; y=&quot;-182.7&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Step 3: Max Information Gain&lt;/text&gt;
&lt;/g&gt;
&lt;!-- stop&amp;#45;&amp;gt;select --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;stop-&gt;select&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M268.16,-251.61C268.16,-241.17 268.16,-227.64 268.16,-215.66&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;271.66,-215.88 268.16,-205.88 264.66,-215.88 271.66,-215.88&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;284.83&quot; y=&quot;-225&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;not met&lt;/text&gt;
&lt;/g&gt;
&lt;!-- branch --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;branch&lt;/title&gt;
&lt;polygon fill=&quot;#cce5ff&quot; stroke=&quot;black&quot; points=&quot;353.1,-120 173.22,-120 173.22,-84 353.1,-84 353.1,-120&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;263.16&quot; y=&quot;-98.7&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Step 4: Branch per attribute value&lt;/text&gt;
&lt;/g&gt;
&lt;!-- select&amp;#45;&amp;gt;branch --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;select-&gt;branch&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M267.1,-167.61C266.46,-157.17 265.64,-143.64 264.91,-131.66&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;268.41,-131.64 264.31,-121.88 261.42,-132.07 268.41,-131.64&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;280.13&quot; y=&quot;-141&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;repeat&lt;/text&gt;
&lt;/g&gt;
&lt;!-- recurse --&gt;
&lt;g id=&quot;node6&quot; class=&quot;node&quot;&gt;
&lt;title&gt;recurse&lt;/title&gt;
&lt;polygon fill=&quot;#ffd700&quot; stroke=&quot;black&quot; points=&quot;408.43,-36 235.89,-36 235.89,0 408.43,0 408.43,-36&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;322.16&quot; y=&quot;-14.7&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Step 5: Recurse on each subset&lt;/text&gt;
&lt;/g&gt;
&lt;!-- branch&amp;#45;&amp;gt;recurse --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;branch-&gt;recurse&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M275.67,-83.61C283.65,-72.52 294.14,-57.94 303.14,-45.43&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;305.78,-47.76 308.78,-37.59 300.1,-43.67 305.78,-47.76&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;310.37&quot; y=&quot;-57&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;repeat&lt;/text&gt;
&lt;/g&gt;
&lt;!-- recurse&amp;#45;&amp;gt;stop --&gt;
&lt;g id=&quot;edge6&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;recurse-&gt;stop&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M336.64,-36.48C345.94,-48.89 357.18,-66.41 362.16,-84 376.7,-135.36 382.74,-157.15 357.16,-204 346.48,-223.55 327.11,-238.77 309.15,-249.54&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;307.68,-246.35 300.71,-254.33 311.13,-252.44 307.68,-246.35&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;388.88&quot; y=&quot;-141&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;repeat&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Greedy&lt;/strong&gt;: Never backtracks; each decision is final&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Information Gain&lt;/strong&gt;: Uses entropy-based IG as the sole attribute selection criterion&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Top-down&lt;/strong&gt;: Builds from root to leaves in a single pass&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Discrete attributes&lt;/strong&gt;: Original ID3 handles only categorical attributes (C4.5 extension handles continuous)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;semantic-network&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Semantic Network&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#semantic-network&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: semantic_ID3_Algorithm Pages: 1 --&gt;
&lt;svg width=&quot;178pt&quot; height=&quot;170pt&quot; viewBox=&quot;0.00 0.00 178.00 170.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 165.63)&quot;&gt;
&lt;title&gt;semantic_ID3_Algorithm&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-165.63 174.12,-165.63 174.12,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- THIS --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;THIS&lt;/title&gt;
&lt;ellipse fill=&quot;#ffd700&quot; stroke=&quot;black&quot; stroke-width=&quot;2&quot; cx=&quot;65.63&quot; cy=&quot;-86.21&quot; rx=&quot;61.31&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;65.63&quot; y=&quot;-82.31&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;13.00&quot;&gt;Id3 Algorithm&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL1 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL1&lt;/title&gt;
&lt;ellipse fill=&quot;#f0f0f0&quot; stroke=&quot;black&quot; cx=&quot;109.53&quot; cy=&quot;-143.63&quot; rx=&quot;60.59&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;109.53&quot; y=&quot;-140.33&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Related Concept&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL1 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M79.28,-104.06C84.62,-111.04 90.72,-119.02 96.04,-125.98&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;68.62&quot; y=&quot;-119.22&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;related&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL2 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL2&lt;/title&gt;
&lt;ellipse fill=&quot;#d4edda&quot; stroke=&quot;black&quot; cx=&quot;41.67&quot; cy=&quot;-18&quot; rx=&quot;41.67&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;41.67&quot; y=&quot;-14.7&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Builds Into&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL2 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M59.21,-67.93C55.72,-57.98 51.42,-45.73 47.95,-35.86&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;83.33&quot; y=&quot;-39.29&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;builds into&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../information-gain&quot; class=&quot;internal alias&quot; data-slug=&quot;information-gain&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Information Gain&lt;/a&gt; — ID3 uses IG as its selection measure&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../recursive-tree-building&quot; class=&quot;internal alias&quot; data-slug=&quot;recursive-tree-building&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Recursive Tree Building&lt;/a&gt; — ID3 is a specific recursive algorithm&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../decision-tree-stopping-conditions&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-stopping-conditions&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Stopping Conditions&lt;/a&gt; — ID3 uses the three standard stopping conditions&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../decision-tree-structure&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-structure&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Structure&lt;/a&gt; — ID3 produces the tree structure&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../entropy&quot; class=&quot;internal alias&quot; data-slug=&quot;entropy&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Entropy&lt;/a&gt; — IG in ID3 is based on entropy&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../gini-index&quot; class=&quot;internal alias&quot; data-slug=&quot;gini-index&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Gini Index&lt;/a&gt; — CART algorithm uses Gini instead of IG&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../attribute-selection-measures&quot; class=&quot;internal alias&quot; data-slug=&quot;attribute-selection-measures&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Attribute Selection Measures&lt;/a&gt; — ID3 pioneered the use of IG&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;No pruning&lt;/strong&gt;: Original ID3 does not include post-pruning, leading to overfitting&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Continuous features&lt;/strong&gt;: ID3 cannot natively handle numerical features (requires discretization or C4.5)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Missing values&lt;/strong&gt;: ID3 has no built-in mechanism for handling missing data&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Multi-valued bias&lt;/strong&gt;: Favors attributes with many distinct values (addressed by C4.5’s Gain Ratio)&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>information-gain-calculation</title>
    <link href="https://animishraa05.github.io/wiki/decision-tree/information-gain-calculation" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/decision-tree/information-gain-calculation.md" />
    <summary>The Problem Knowing that Information Gain measures uncertainty reduction is conceptual; implementing a decision tree requires the precise computational steps to evaluate every candidate attribute at every node.</summary>
    <published>2026-05-06T00:00:00.000Z</published>
    <updated>2026-05-06T00:00:00.000Z</updated>
    <publishedTime>May 06, 2026</publishedTime>
    <updatedTime>May 06, 2026</updatedTime>
    <category term="ml" label="ml" />
<category term="decision-trees" label="decision-trees" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Knowing that Information Gain measures uncertainty reduction is conceptual; implementing a decision tree requires the precise computational steps to evaluate every candidate attribute at every node.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Information Gain calculation involves computing the parent entropy, calculating each child’s entropy after a hypothetical split, weighting each child entropy by its proportion of the total data, and subtracting this weighted sum from the parent entropy.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Detailed calculation procedure:&lt;/p&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Compute parent entropy&lt;/strong&gt;: Calculate Entropy(S) for the entire dataset at the current node&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;For each candidate attribute A:&lt;/strong&gt;
a. Partition S into subsets &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msub&gt;&lt;mi&gt;S&lt;/mi&gt;&lt;mi&gt;v&lt;/mi&gt;&lt;/msub&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;S_v&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.8333em;vertical-align:-0.15em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.0576em;&quot;&gt;S&lt;/span&gt;&lt;span class=&quot;msupsub&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.1514em;&quot;&gt;&lt;span style=&quot;top:-2.55em;margin-left:-0.0576em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot; style=&quot;margin-right:0.0359em;&quot;&gt;v&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.15em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; for each value &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;v&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;v&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.4306em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.0359em;&quot;&gt;v&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; of attribute A
b. Calculate Entropy(&lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msub&gt;&lt;mi&gt;S&lt;/mi&gt;&lt;mi&gt;v&lt;/mi&gt;&lt;/msub&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;S_v&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.8333em;vertical-align:-0.15em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.0576em;&quot;&gt;S&lt;/span&gt;&lt;span class=&quot;msupsub&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.1514em;&quot;&gt;&lt;span style=&quot;top:-2.55em;margin-left:-0.0576em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot; style=&quot;margin-right:0.0359em;&quot;&gt;v&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.15em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;) for each subset
c. Compute the weighted average: &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mo&gt;∑&lt;/mo&gt;&lt;mfrac&gt;&lt;mrow&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∣&lt;/mi&gt;&lt;msub&gt;&lt;mi&gt;S&lt;/mi&gt;&lt;mi&gt;v&lt;/mi&gt;&lt;/msub&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∣&lt;/mi&gt;&lt;/mrow&gt;&lt;mrow&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∣&lt;/mi&gt;&lt;mi&gt;S&lt;/mi&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∣&lt;/mi&gt;&lt;/mrow&gt;&lt;/mfrac&gt;&lt;mo&gt;×&lt;/mo&gt;&lt;mi&gt;E&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mi&gt;t&lt;/mi&gt;&lt;mi&gt;r&lt;/mi&gt;&lt;mi&gt;o&lt;/mi&gt;&lt;mi&gt;p&lt;/mi&gt;&lt;mi&gt;y&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;S&lt;/mi&gt;&lt;mi&gt;v&lt;/mi&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;\sum \frac{|S_v|}{|S|} \times Entropy(S_v)&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1.53em;vertical-align:-0.52em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mop op-symbol small-op&quot; style=&quot;position:relative;top:0em;&quot;&gt;∑&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.1667em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mopen nulldelimiter&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mfrac&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:1.01em;&quot;&gt;&lt;span style=&quot;top:-2.655em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:3em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;∣&lt;/span&gt;&lt;span class=&quot;mord mathnormal mtight&quot; style=&quot;margin-right:0.0576em;&quot;&gt;S&lt;/span&gt;&lt;span class=&quot;mord mtight&quot;&gt;∣&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;top:-3.23em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:3em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;frac-line&quot; style=&quot;border-bottom-width:0.04em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;top:-3.485em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:3em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;∣&lt;/span&gt;&lt;span class=&quot;mord mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot; style=&quot;margin-right:0.0576em;&quot;&gt;S&lt;/span&gt;&lt;span class=&quot;msupsub&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.1645em;&quot;&gt;&lt;span style=&quot;top:-2.357em;margin-left:-0.0576em;margin-right:0.0714em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.5em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size3 size1 mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot; style=&quot;margin-right:0.0359em;&quot;&gt;v&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.143em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mord mtight&quot;&gt;∣&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.52em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mclose nulldelimiter&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mbin&quot;&gt;×&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1em;vertical-align:-0.25em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.0576em;&quot;&gt;E&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.0278em;&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;o&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.0359em;&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;mopen&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.0576em;&quot;&gt;S&lt;/span&gt;&lt;span class=&quot;msupsub&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.1514em;&quot;&gt;&lt;span style=&quot;top:-2.55em;margin-left:-0.0576em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot; style=&quot;margin-right:0.0359em;&quot;&gt;v&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.15em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mclose&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
d. Subtract from parent entropy: &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;G&lt;/mi&gt;&lt;mi&gt;a&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;mi&gt;S&lt;/mi&gt;&lt;mo separator=&quot;true&quot;&gt;,&lt;/mo&gt;&lt;mi&gt;A&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;E&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mi&gt;t&lt;/mi&gt;&lt;mi&gt;r&lt;/mi&gt;&lt;mi&gt;o&lt;/mi&gt;&lt;mi&gt;p&lt;/mi&gt;&lt;mi&gt;y&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;mi&gt;S&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;mtext&gt;weighted average&lt;/mtext&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;Gain(S, A) = Entropy(S) - \text{weighted average}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1em;vertical-align:-0.25em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;G&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;ain&lt;/span&gt;&lt;span class=&quot;mopen&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.0576em;&quot;&gt;S&lt;/span&gt;&lt;span class=&quot;mpunct&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.1667em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;mclose&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1em;vertical-align:-0.25em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.0576em;&quot;&gt;E&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.0278em;&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;o&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.0359em;&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;mopen&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.0576em;&quot;&gt;S&lt;/span&gt;&lt;span class=&quot;mclose&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mbin&quot;&gt;−&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.8889em;vertical-align:-0.1944em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord text&quot;&gt;&lt;span class=&quot;mord&quot;&gt;weighted average&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Select the attribute with maximum Gain&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;strong&gt;Worked example from source (split on attribute Y):&lt;/strong&gt;&lt;/p&gt;
&lt;p dir=&quot;auto&quot;&gt;Given dataset with 3 features (X, Y, Z) and 2 classes (I, II):&lt;/p&gt;



































&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;X&lt;/th&gt;&lt;th&gt;Y&lt;/th&gt;&lt;th&gt;Z&lt;/th&gt;&lt;th&gt;C&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;I&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;I&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;II&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;0&lt;/td&gt;&lt;td&gt;II&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Parent entropy: 2 of class I, 2 of class II → Entropy = 1.0&lt;/li&gt;
&lt;li&gt;Split on Y:
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;Y=1: 2 instances, both class I → Entropy = 0.0&lt;/li&gt;
&lt;li&gt;Y=0: 2 instances, both class II → Entropy = 0.0&lt;/li&gt;
&lt;li&gt;Weighted average: (2/4) × 0.0 + (2/4) × 0.0 = 0.0&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Gain(Y) = 1.0 - 0.0 = 1.0&lt;/strong&gt; (maximum possible)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p dir=&quot;auto&quot;&gt;Since splitting on Y produces perfectly pure children, Y is chosen as the root node, and no further splits are needed.&lt;/p&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: ig_calculation Pages: 1 --&gt;
&lt;svg width=&quot;245pt&quot; height=&quot;365pt&quot; viewBox=&quot;0.00 0.00 245.00 365.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 360.8)&quot;&gt;
&lt;title&gt;ig_calculation&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-360.8 240.81,-360.8 240.81,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- parent --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;parent&lt;/title&gt;
&lt;polygon fill=&quot;#ffd700&quot; stroke=&quot;black&quot; points=&quot;182.05,-356.8 54.76,-356.8 54.76,-320.8 182.05,-320.8 182.05,-356.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;118.41&quot; y=&quot;-342.1&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Step 1: Parent Entropy&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;118.41&quot; y=&quot;-328.9&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;H(S) = 1.0 (2I, 2II)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- split --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;split&lt;/title&gt;
&lt;polygon fill=&quot;#cce5ff&quot; stroke=&quot;black&quot; points=&quot;176.45,-284.8 60.36,-284.8 60.36,-248.8 176.45,-248.8 176.45,-284.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;118.41&quot; y=&quot;-270.1&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Step 2: Split on Y&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;118.41&quot; y=&quot;-256.9&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Y=1: {I,I} | Y=0: {II,II}&lt;/text&gt;
&lt;/g&gt;
&lt;!-- parent&amp;#45;&amp;gt;split --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;parent-&gt;split&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M118.41,-320.5C118.41,-313.21 118.41,-304.53 118.41,-296.34&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;121.91,-296.42 118.41,-286.42 114.91,-296.42 121.91,-296.42&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- child_e --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;child_e&lt;/title&gt;
&lt;polygon fill=&quot;#d4edda&quot; stroke=&quot;black&quot; points=&quot;183.26,-212.8 53.55,-212.8 53.55,-176.8 183.26,-176.8 183.26,-212.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;118.41&quot; y=&quot;-198.1&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Step 3: Child Entropies&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;118.41&quot; y=&quot;-184.9&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;H(Y=1) = 0, H(Y=0) = 0&lt;/text&gt;
&lt;/g&gt;
&lt;!-- split&amp;#45;&amp;gt;child_e --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;split-&gt;child_e&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M118.41,-248.5C118.41,-241.21 118.41,-232.53 118.41,-224.34&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;121.91,-224.42 118.41,-214.42 114.91,-224.42 121.91,-224.42&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- weighted --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;weighted&lt;/title&gt;
&lt;polygon fill=&quot;#e8d5f5&quot; stroke=&quot;black&quot; points=&quot;179.6,-140.8 57.21,-140.8 57.21,-104.8 179.6,-104.8 179.6,-140.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;118.41&quot; y=&quot;-126.1&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Step 4: Weighted Avg&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;118.41&quot; y=&quot;-112.9&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;(2/4)×0 + (2/4)×0 = 0&lt;/text&gt;
&lt;/g&gt;
&lt;!-- child_e&amp;#45;&amp;gt;weighted --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;child_e-&gt;weighted&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M118.41,-176.5C118.41,-169.21 118.41,-160.53 118.41,-152.34&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;121.91,-152.42 118.41,-142.42 114.91,-152.42 121.91,-152.42&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- gain --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;gain&lt;/title&gt;
&lt;polygon fill=&quot;#ffd700&quot; stroke=&quot;black&quot; points=&quot;118.41,-68.8 0,-34.4 118.41,0 236.81,-34.4 118.41,-68.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;118.41&quot; y=&quot;-37.7&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Step 5: Gain&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;118.41&quot; y=&quot;-24.5&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;1.0 - 0.0 = 1.0 (MAX)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- weighted&amp;#45;&amp;gt;gain --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;weighted-&gt;gain&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M118.41,-104.32C118.41,-97.4 118.41,-89.1 118.41,-80.7&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;121.91,-80.81 118.41,-70.81 114.91,-80.81 121.91,-80.81&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Per-attribute evaluation&lt;/strong&gt;: Must be computed for every candidate attribute at every node&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Monotonic&lt;/strong&gt;: Adding more attributes to the dataset cannot decrease the maximum achievable IG&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Computationally intensive&lt;/strong&gt;: Requires entropy calculation for each candidate split at each node&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Greedy&lt;/strong&gt;: Computed locally without considering future splits&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;semantic-network&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Semantic Network&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#semantic-network&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: semantic_Information_Gain_Calculation Pages: 1 --&gt;
&lt;svg width=&quot;202pt&quot; height=&quot;170pt&quot; viewBox=&quot;0.00 0.00 202.00 170.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 165.63)&quot;&gt;
&lt;title&gt;semantic_Information_Gain_Calculation&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-165.63 198.02,-165.63 198.02,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- THIS --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;THIS&lt;/title&gt;
&lt;ellipse fill=&quot;#ffd700&quot; stroke=&quot;black&quot; stroke-width=&quot;2&quot; cx=&quot;89.53&quot; cy=&quot;-86.21&quot; rx=&quot;89.53&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;89.53&quot; y=&quot;-82.31&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;13.00&quot;&gt;Information Gain Cal&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL1 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL1&lt;/title&gt;
&lt;ellipse fill=&quot;#f0f0f0&quot; stroke=&quot;black&quot; cx=&quot;133.43&quot; cy=&quot;-143.63&quot; rx=&quot;60.59&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;133.43&quot; y=&quot;-140.33&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Related Concept&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL1 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M103.42,-104.37C108.65,-111.21 114.58,-118.97 119.78,-125.77&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;92.56&quot; y=&quot;-119.27&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;related&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL2 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL2&lt;/title&gt;
&lt;ellipse fill=&quot;#d4edda&quot; stroke=&quot;black&quot; cx=&quot;65.58&quot; cy=&quot;-18&quot; rx=&quot;41.67&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;65.58&quot; y=&quot;-14.7&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Builds Into&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL2 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M83.11,-67.93C79.62,-57.98 75.32,-45.73 71.85,-35.86&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;107.23&quot; y=&quot;-39.29&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;builds into&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../information-gain&quot; class=&quot;internal alias&quot; data-slug=&quot;information-gain&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Information Gain&lt;/a&gt; — this is the computational procedure behind the concept&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../entropy-calculation&quot; class=&quot;internal alias&quot; data-slug=&quot;entropy-calculation&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Entropy Calculation&lt;/a&gt; — child entropy computations feed into IG&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../root-node&quot; class=&quot;internal alias&quot; data-slug=&quot;root-node&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Root Node&lt;/a&gt; — IG calculation determines the root attribute&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../recursive-tree-building&quot; class=&quot;internal alias&quot; data-slug=&quot;recursive-tree-building&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Recursive Tree Building&lt;/a&gt; — IG is computed at every recursive step&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../decision-tree-splitting&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-splitting&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Splitting&lt;/a&gt; — IG values drive the split decision&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../gini-index&quot; class=&quot;internal alias&quot; data-slug=&quot;gini-index&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Gini Index&lt;/a&gt; — different computational formula for the same goal&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Division by zero&lt;/strong&gt;: If |S| = 0 (empty node), IG is undefined — the node should be a leaf&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;All same values&lt;/strong&gt;: If an attribute has the same value for all instances, only one child exists and IG = 0&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Precision accumulation&lt;/strong&gt;: Repeated floating point operations can accumulate rounding errors in deep trees&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tie-breaking&lt;/strong&gt;: Multiple attributes may have identical IG; a deterministic tie-breaking rule is needed&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>information-gain</title>
    <link href="https://animishraa05.github.io/wiki/decision-tree/information-gain" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/decision-tree/information-gain.md" />
    <summary>The Problem A decision tree needs to decide which attribute to test at each node. Simply picking attributes randomly produces useless trees.</summary>
    <published>2026-05-06T00:00:00.000Z</published>
    <updated>2026-05-06T00:00:00.000Z</updated>
    <publishedTime>May 06, 2026</publishedTime>
    <updatedTime>May 06, 2026</updatedTime>
    <category term="ml" label="ml" />
<category term="decision-trees" label="decision-trees" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;A decision tree needs to decide which attribute to test at each node. Simply picking attributes randomly produces useless trees. We need a principled way to quantify “how much does this attribute help us reduce uncertainty about the class label?”&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Information Gain measures how much the entropy (uncertainty) decreases after splitting a dataset on a particular attribute. The attribute with the highest Information Gain is chosen for the split, because it creates the clearest separation of classes.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Information Gain is computed as the difference between the parent node’s entropy and the weighted average entropy of the child nodes:&lt;/p&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;G&lt;/mi&gt;&lt;mi&gt;a&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;mi&gt;S&lt;/mi&gt;&lt;mo separator=&quot;true&quot;&gt;,&lt;/mo&gt;&lt;mi&gt;A&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;E&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mi&gt;t&lt;/mi&gt;&lt;mi&gt;r&lt;/mi&gt;&lt;mi&gt;o&lt;/mi&gt;&lt;mi&gt;p&lt;/mi&gt;&lt;mi&gt;y&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;mi&gt;S&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mo&gt;−&lt;/mo&gt;&lt;msub&gt;&lt;mo&gt;∑&lt;/mo&gt;&lt;mrow&gt;&lt;mi&gt;v&lt;/mi&gt;&lt;mo&gt;∈&lt;/mo&gt;&lt;mi&gt;V&lt;/mi&gt;&lt;mi&gt;a&lt;/mi&gt;&lt;mi&gt;l&lt;/mi&gt;&lt;mi&gt;u&lt;/mi&gt;&lt;mi&gt;e&lt;/mi&gt;&lt;mi&gt;s&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;mi&gt;A&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mfrac&gt;&lt;mrow&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∣&lt;/mi&gt;&lt;msub&gt;&lt;mi&gt;S&lt;/mi&gt;&lt;mi&gt;v&lt;/mi&gt;&lt;/msub&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∣&lt;/mi&gt;&lt;/mrow&gt;&lt;mrow&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∣&lt;/mi&gt;&lt;mi&gt;S&lt;/mi&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;∣&lt;/mi&gt;&lt;/mrow&gt;&lt;/mfrac&gt;&lt;mo&gt;×&lt;/mo&gt;&lt;mi&gt;E&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mi&gt;t&lt;/mi&gt;&lt;mi&gt;r&lt;/mi&gt;&lt;mi&gt;o&lt;/mi&gt;&lt;mi&gt;p&lt;/mi&gt;&lt;mi&gt;y&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;msub&gt;&lt;mi&gt;S&lt;/mi&gt;&lt;mi&gt;v&lt;/mi&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;Gain(S, A) = Entropy(S) - \sum_{v \in Values(A)} \frac{|S_v|}{|S|} \times Entropy(S_v)&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1em;vertical-align:-0.25em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;G&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;ain&lt;/span&gt;&lt;span class=&quot;mopen&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.0576em;&quot;&gt;S&lt;/span&gt;&lt;span class=&quot;mpunct&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.1667em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;mclose&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1em;vertical-align:-0.25em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.0576em;&quot;&gt;E&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.0278em;&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;o&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.0359em;&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;mopen&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.0576em;&quot;&gt;S&lt;/span&gt;&lt;span class=&quot;mclose&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mbin&quot;&gt;−&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1.53em;vertical-align:-0.52em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mop&quot;&gt;&lt;span class=&quot;mop op-symbol small-op&quot; style=&quot;position:relative;top:0em;&quot;&gt;∑&lt;/span&gt;&lt;span class=&quot;msupsub&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.2253em;&quot;&gt;&lt;span style=&quot;top:-2.4003em;margin-left:0em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot; style=&quot;margin-right:0.0359em;&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;mrel mtight&quot;&gt;∈&lt;/span&gt;&lt;span class=&quot;mord mathnormal mtight&quot; style=&quot;margin-right:0.2222em;&quot;&gt;V&lt;/span&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mord mathnormal mtight&quot; style=&quot;margin-right:0.0197em;&quot;&gt;l&lt;/span&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;u&lt;/span&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;es&lt;/span&gt;&lt;span class=&quot;mopen mtight&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mord mathnormal mtight&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;mclose mtight&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.4747em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.1667em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mopen nulldelimiter&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mfrac&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:1.01em;&quot;&gt;&lt;span style=&quot;top:-2.655em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:3em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;∣&lt;/span&gt;&lt;span class=&quot;mord mathnormal mtight&quot; style=&quot;margin-right:0.0576em;&quot;&gt;S&lt;/span&gt;&lt;span class=&quot;mord mtight&quot;&gt;∣&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;top:-3.23em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:3em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;frac-line&quot; style=&quot;border-bottom-width:0.04em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;top:-3.485em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:3em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;&lt;span class=&quot;mord mtight&quot;&gt;∣&lt;/span&gt;&lt;span class=&quot;mord mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot; style=&quot;margin-right:0.0576em;&quot;&gt;S&lt;/span&gt;&lt;span class=&quot;msupsub&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.1645em;&quot;&gt;&lt;span style=&quot;top:-2.357em;margin-left:-0.0576em;margin-right:0.0714em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.5em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size3 size1 mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot; style=&quot;margin-right:0.0359em;&quot;&gt;v&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.143em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mord mtight&quot;&gt;∣&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.52em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mclose nulldelimiter&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mbin&quot;&gt;×&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1em;vertical-align:-0.25em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.0576em;&quot;&gt;E&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.0278em;&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;o&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.0359em;&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;mopen&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.0576em;&quot;&gt;S&lt;/span&gt;&lt;span class=&quot;msupsub&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.1514em;&quot;&gt;&lt;span style=&quot;top:-2.55em;margin-left:-0.0576em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot; style=&quot;margin-right:0.0359em;&quot;&gt;v&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.15em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mclose&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p dir=&quot;auto&quot;&gt;Where:&lt;/p&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;S&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;S&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6833em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.0576em;&quot;&gt;S&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; is the set of instances at the parent node&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;A&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;A&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6833em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;A&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; is the candidate attribute&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;msub&gt;&lt;mi&gt;S&lt;/mi&gt;&lt;mi&gt;v&lt;/mi&gt;&lt;/msub&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;S_v&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.8333em;vertical-align:-0.15em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.0576em;&quot;&gt;S&lt;/span&gt;&lt;span class=&quot;msupsub&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.1514em;&quot;&gt;&lt;span style=&quot;top:-2.55em;margin-left:-0.0576em;margin-right:0.05em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:2.7em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;sizing reset-size6 size3 mtight&quot;&gt;&lt;span class=&quot;mord mathnormal mtight&quot; style=&quot;margin-right:0.0359em;&quot;&gt;v&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.15em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; is the subset of &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;S&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;S&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6833em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.0576em;&quot;&gt;S&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; where attribute &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;A&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;A&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6833em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;A&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; has value &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;v&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;v&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.4306em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.0359em;&quot;&gt;v&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;V&lt;/mi&gt;&lt;mi&gt;a&lt;/mi&gt;&lt;mi&gt;l&lt;/mi&gt;&lt;mi&gt;u&lt;/mi&gt;&lt;mi&gt;e&lt;/mi&gt;&lt;mi&gt;s&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;mi&gt;A&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;Values(A)&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1em;vertical-align:-0.25em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.2222em;&quot;&gt;V&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.0197em;&quot;&gt;l&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;u&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;es&lt;/span&gt;&lt;span class=&quot;mopen&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;mclose&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; is the set of all possible values of attribute &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;A&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;A&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.6833em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;A&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;strong&gt;Interpretation:&lt;/strong&gt;&lt;/p&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;High IG&lt;/strong&gt;: The split creates very pure child groups (e.g., all “Young” bought, all “Old” didn’t buy) → this attribute is very useful&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Low IG&lt;/strong&gt;: The split barely changes the class distribution → this attribute provides little information&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Zero IG&lt;/strong&gt;: The split produces children with the same impurity as the parent → this attribute is useless for this node&lt;/li&gt;
&lt;/ul&gt;
&lt;p dir=&quot;auto&quot;&gt;In the source example, splitting on age into “Young” and “Old” produced perfect separation (all young bought, all old didn’t), resulting in maximum Information Gain.&lt;/p&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: information_gain Pages: 1 --&gt;
&lt;svg width=&quot;259pt&quot; height=&quot;350pt&quot; viewBox=&quot;0.00 0.00 259.00 350.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 346.4)&quot;&gt;
&lt;title&gt;information_gain&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-346.4 255.39,-346.4 255.39,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- parent --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;parent&lt;/title&gt;
&lt;polygon fill=&quot;#ffd700&quot; stroke=&quot;black&quot; points=&quot;184.22,-342.4 67.17,-342.4 67.17,-305.6 184.22,-305.6 184.22,-342.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;125.69&quot; y=&quot;-327.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Parent Node&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;125.69&quot; y=&quot;-313.2&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Entropy(S) = 0.954&lt;/text&gt;
&lt;/g&gt;
&lt;!-- attr --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;attr&lt;/title&gt;
&lt;polygon fill=&quot;#e8e8e8&quot; stroke=&quot;black&quot; points=&quot;220.08,-257.6 31.31,-257.6 31.31,-220.8 220.08,-220.8 220.08,-257.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;125.69&quot; y=&quot;-242.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Evaluate Attribute A&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;125.69&quot; y=&quot;-228.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Calculate weighted child entropy&lt;/text&gt;
&lt;/g&gt;
&lt;!-- parent&amp;#45;&amp;gt;attr --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;parent-&gt;attr&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M125.69,-305.44C125.69,-294.97 125.69,-281.42 125.69,-269.38&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;129.19,-269.53 125.69,-259.53 122.19,-269.53 129.19,-269.53&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;146.26&quot; y=&quot;-278.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;split on A&lt;/text&gt;
&lt;/g&gt;
&lt;!-- left --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;left&lt;/title&gt;
&lt;polygon fill=&quot;#d4edda&quot; stroke=&quot;black&quot; points=&quot;116.55,-172.8 28.84,-172.8 28.84,-121.6 116.55,-121.6 116.55,-172.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;72.69&quot; y=&quot;-158&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Child: S₁&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;72.69&quot; y=&quot;-143.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Entropy = 0.0&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;72.69&quot; y=&quot;-129.2&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;(pure)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- attr&amp;#45;&amp;gt;left --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;attr-&gt;left&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M115.22,-220.42C108.94,-209.75 100.73,-195.8 93.2,-183.02&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;96.21,-181.24 88.12,-174.4 90.18,-184.8 96.21,-181.24&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;111.44&quot; y=&quot;-193.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;S₁&lt;/text&gt;
&lt;/g&gt;
&lt;!-- right --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;right&lt;/title&gt;
&lt;polygon fill=&quot;#d4edda&quot; stroke=&quot;black&quot; points=&quot;222.55,-172.8 134.84,-172.8 134.84,-121.6 222.55,-121.6 222.55,-172.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;178.69&quot; y=&quot;-158&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Child: S₂&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;178.69&quot; y=&quot;-143.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Entropy = 0.0&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;178.69&quot; y=&quot;-129.2&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;(pure)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- attr&amp;#45;&amp;gt;right --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;attr-&gt;right&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M136.16,-220.42C142.45,-209.75 150.66,-195.8 158.19,-183.02&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;161.2,-184.8 163.26,-174.4 155.17,-181.24 161.2,-184.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;159.7&quot; y=&quot;-193.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;S₂&lt;/text&gt;
&lt;/g&gt;
&lt;!-- ig --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;ig&lt;/title&gt;
&lt;polygon fill=&quot;#ffd700&quot; stroke=&quot;black&quot; points=&quot;125.69,-73.6 0,-36.8 125.69,0 251.39,-36.8 125.69,-73.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;125.69&quot; y=&quot;-40.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Gain = 0.954 - 0.0&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;125.69&quot; y=&quot;-26&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;= 0.954 (MAXIMUM)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- left&amp;#45;&amp;gt;ig --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;left-&gt;ig&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M83.8,-121.35C88.07,-111.98 93.04,-101.25 97.76,-91.6 99.79,-87.45 101.94,-83.14 104.12,-78.86&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;107.05,-80.81 108.5,-70.31 100.82,-77.61 107.05,-80.81&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;127.23&quot; y=&quot;-94.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;weighted avg&lt;/text&gt;
&lt;/g&gt;
&lt;!-- right&amp;#45;&amp;gt;ig --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;right-&gt;ig&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M169.45,-121.15C165.76,-111.75 161.3,-101.07 156.69,-91.6 154.54,-87.17 152.17,-82.61 149.72,-78.11&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;152.98,-76.76 145.05,-69.73 146.87,-80.17 152.98,-76.76&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Non-negative&lt;/strong&gt;: Information Gain is always ≥ 0 (a split cannot increase weighted entropy)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Maximum = parent entropy&lt;/strong&gt;: Achieved when all children are perfectly pure (entropy = 0)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Biased toward many-valued attributes&lt;/strong&gt;: Attributes with more unique values tend to have higher IG&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Additive across nodes&lt;/strong&gt;: Total IG of a tree is the sum of IG at each split&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;semantic-network&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Semantic Network&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#semantic-network&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: semantic_Information_Gain Pages: 1 --&gt;
&lt;svg width=&quot;187pt&quot; height=&quot;170pt&quot; viewBox=&quot;0.00 0.00 187.00 170.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 165.63)&quot;&gt;
&lt;title&gt;semantic_Information_Gain&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-165.63 182.71,-165.63 182.71,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- THIS --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;THIS&lt;/title&gt;
&lt;ellipse fill=&quot;#ffd700&quot; stroke=&quot;black&quot; stroke-width=&quot;2&quot; cx=&quot;74.23&quot; cy=&quot;-86.21&quot; rx=&quot;74.23&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;74.23&quot; y=&quot;-82.31&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;13.00&quot;&gt;Information Gain&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL1 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL1&lt;/title&gt;
&lt;ellipse fill=&quot;#f0f0f0&quot; stroke=&quot;black&quot; cx=&quot;118.12&quot; cy=&quot;-143.63&quot; rx=&quot;60.59&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;118.12&quot; y=&quot;-140.33&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Related Concept&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL1 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M88.12,-104.37C93.34,-111.21 99.27,-118.97 104.47,-125.77&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;77.25&quot; y=&quot;-119.27&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;related&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL2 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL2&lt;/title&gt;
&lt;ellipse fill=&quot;#d4edda&quot; stroke=&quot;black&quot; cx=&quot;50.27&quot; cy=&quot;-18&quot; rx=&quot;41.67&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;50.27&quot; y=&quot;-14.7&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Builds Into&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL2 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M67.81,-67.93C64.31,-57.98 60.01,-45.73 56.54,-35.86&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;91.93&quot; y=&quot;-39.29&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;builds into&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../entropy&quot; class=&quot;internal alias&quot; data-slug=&quot;entropy&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Entropy&lt;/a&gt; — IG is the reduction in entropy after a split&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../decision-tree-splitting&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-splitting&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Splitting&lt;/a&gt; — IG determines which split to choose&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../entropy-calculation&quot; class=&quot;internal alias&quot; data-slug=&quot;entropy-calculation&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Entropy Calculation&lt;/a&gt; — entropy values are the building blocks of IG&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../root-node&quot; class=&quot;internal alias&quot; data-slug=&quot;root-node&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Root Node&lt;/a&gt; — root is chosen as the attribute with highest IG&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Contrasts with:&lt;/strong&gt; &lt;a href=&quot;../../gini-index&quot; class=&quot;internal alias&quot; data-slug=&quot;gini-index&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Gini Index&lt;/a&gt; — IG uses log-based entropy; Gini uses squared probabilities&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../attribute-selection-measures&quot; class=&quot;internal alias&quot; data-slug=&quot;attribute-selection-measures&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Attribute Selection Measures&lt;/a&gt; — IG is the primary selection measure&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../information-gain-calculation&quot; class=&quot;internal alias&quot; data-slug=&quot;information-gain-calculation&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Information Gain Calculation&lt;/a&gt; — detailed formula and worked example&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;ID bias&lt;/strong&gt;: Attributes like customer ID have maximum IG (each value is unique) but are meaningless — this led to Gain Ratio&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Zero IG&lt;/strong&gt;: If an attribute has the same value for all instances, IG = 0 and it should not be selected&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Rounding errors&lt;/strong&gt;: Near-zero IG values may appear positive due to floating point precision&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Not normalized&lt;/strong&gt;: IG values are absolute, not relative — a gain of 0.1 may be significant for one dataset but negligible for another&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>internal-node</title>
    <link href="https://animishraa05.github.io/wiki/decision-tree/internal-node" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/decision-tree/internal-node.md" />
    <summary>The Problem After the initial root split, the data in each child branch is still not pure — multiple classes or values coexist.</summary>
    <published>2026-05-06T00:00:00.000Z</published>
    <updated>2026-05-06T00:00:00.000Z</updated>
    <publishedTime>May 06, 2026</publishedTime>
    <updatedTime>May 06, 2026</updatedTime>
    <category term="ml" label="ml" />
<category term="decision-trees" label="decision-trees" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;After the initial root split, the data in each child branch is still not pure — multiple classes or values coexist. The tree needs a mechanism to keep asking questions and refining its predictions without prematurely stopping or over-splitting.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;An internal node (decision node) is any non-leaf node in a decision tree that represents an attribute test. Each internal node asks a question about a specific feature, and its branches represent the possible answers, directing the data flow to child nodes.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Internal nodes operate during both construction and prediction:&lt;/p&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;strong&gt;During construction:&lt;/strong&gt;&lt;/p&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;The subset of data reaching this node is analyzed&lt;/li&gt;
&lt;li&gt;Available attributes (excluding ancestors on this path) are evaluated&lt;/li&gt;
&lt;li&gt;The best attribute is chosen using Information Gain or Gini Index&lt;/li&gt;
&lt;li&gt;Branches are created for each possible value of the chosen attribute&lt;/li&gt;
&lt;/ol&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;strong&gt;During prediction:&lt;/strong&gt;&lt;/p&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;The incoming instance reaches the internal node&lt;/li&gt;
&lt;li&gt;The node evaluates its attribute test on the instance’s feature value&lt;/li&gt;
&lt;li&gt;Based on the answer, the instance is routed down the corresponding branch&lt;/li&gt;
&lt;li&gt;This continues until a leaf node is reached&lt;/li&gt;
&lt;/ol&gt;
&lt;p dir=&quot;auto&quot;&gt;In the source example, “Age &gt; 30?” and “Previous Purchases &gt; 0?” are internal nodes that refine predictions after the root node’s income check.&lt;/p&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: internal_node Pages: 1 --&gt;
&lt;svg width=&quot;256pt&quot; height=&quot;214pt&quot; viewBox=&quot;0.00 0.00 256.00 214.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 210.4)&quot;&gt;
&lt;title&gt;internal_node&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-210.4 251.54,-210.4 251.54,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- parent --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;parent&lt;/title&gt;
&lt;polygon fill=&quot;#e8e8e8&quot; stroke=&quot;black&quot; points=&quot;154.37,-206.4 70.99,-206.4 70.99,-169.6 154.37,-169.6 154.37,-206.4&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;112.68&quot; y=&quot;-191.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Parent Node&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;112.68&quot; y=&quot;-177.2&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;or Root&lt;/text&gt;
&lt;/g&gt;
&lt;!-- internal --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;internal&lt;/title&gt;
&lt;polygon fill=&quot;#cce5ff&quot; stroke=&quot;black&quot; points=&quot;156.7,-121.6 68.66,-121.6 68.66,-84.8 156.7,-84.8 156.7,-121.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;112.68&quot; y=&quot;-106.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Internal Node&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;112.68&quot; y=&quot;-92.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;(Age &gt; 30?)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- parent&amp;#45;&amp;gt;internal --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;parent-&gt;internal&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M112.68,-169.44C112.68,-158.97 112.68,-145.42 112.68,-133.38&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;116.18,-133.53 112.68,-123.53 109.18,-133.53 116.18,-133.53&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;138.8&quot; y=&quot;-142.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;data arrives&lt;/text&gt;
&lt;/g&gt;
&lt;!-- leaf_no --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;leaf_no&lt;/title&gt;
&lt;polygon fill=&quot;#ffcccc&quot; stroke=&quot;black&quot; points=&quot;93.36,-36.8 0,-36.8 0,0 93.36,0 93.36,-36.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;46.68&quot; y=&quot;-22&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Leaf Node&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;46.68&quot; y=&quot;-7.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;(No Purchase)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- internal&amp;#45;&amp;gt;leaf_no --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;internal-&gt;leaf_no&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M98.68,-84.64C89.73,-73.41 77.95,-58.63 67.86,-45.98&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;70.8,-44.04 61.83,-38.4 65.32,-48.4 70.8,-44.04&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;90.02&quot; y=&quot;-57.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;No&lt;/text&gt;
&lt;/g&gt;
&lt;!-- next_node --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;next_node&lt;/title&gt;
&lt;polygon fill=&quot;#cce5ff&quot; stroke=&quot;black&quot; points=&quot;247.54,-36.8 111.82,-36.8 111.82,0 247.54,0 247.54,-36.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;179.68&quot; y=&quot;-22&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Internal Node&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;179.68&quot; y=&quot;-7.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;(Prev Purchases &gt; 0?)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- internal&amp;#45;&amp;gt;next_node --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;internal-&gt;next_node&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M126.89,-84.64C135.98,-73.41 147.94,-58.63 158.18,-45.98&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;160.74,-48.37 164.31,-38.4 155.3,-43.97 160.74,-48.37&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;158.81&quot; y=&quot;-57.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;Yes&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Attribute test&lt;/strong&gt;: Each internal node tests exactly one feature/attribute&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Branching factor&lt;/strong&gt;: Number of outgoing branches equals the number of possible attribute values&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Subset-specific&lt;/strong&gt;: Operates only on the data subset that reached this node, not the full dataset&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Recursive role&lt;/strong&gt;: Internal nodes can have internal nodes as children, creating nested decision paths&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;semantic-network&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Semantic Network&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#semantic-network&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: semantic_Internal_Node Pages: 1 --&gt;
&lt;svg width=&quot;178pt&quot; height=&quot;170pt&quot; viewBox=&quot;0.00 0.00 178.00 170.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 165.63)&quot;&gt;
&lt;title&gt;semantic_Internal_Node&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-165.63 174.12,-165.63 174.12,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- THIS --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;THIS&lt;/title&gt;
&lt;ellipse fill=&quot;#ffd700&quot; stroke=&quot;black&quot; stroke-width=&quot;2&quot; cx=&quot;65.63&quot; cy=&quot;-86.21&quot; rx=&quot;62.27&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;65.63&quot; y=&quot;-82.31&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;13.00&quot;&gt;Internal Node&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL1 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL1&lt;/title&gt;
&lt;ellipse fill=&quot;#f0f0f0&quot; stroke=&quot;black&quot; cx=&quot;109.53&quot; cy=&quot;-143.63&quot; rx=&quot;60.59&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;109.53&quot; y=&quot;-140.33&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Related Concept&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL1 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M79.28,-104.06C84.62,-111.04 90.72,-119.02 96.04,-125.98&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;68.62&quot; y=&quot;-119.22&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;related&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL2 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL2&lt;/title&gt;
&lt;ellipse fill=&quot;#d4edda&quot; stroke=&quot;black&quot; cx=&quot;41.67&quot; cy=&quot;-18&quot; rx=&quot;41.67&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;41.67&quot; y=&quot;-14.7&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Builds Into&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL2 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M59.21,-67.93C55.72,-57.98 51.42,-45.73 47.95,-35.86&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;83.33&quot; y=&quot;-39.29&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;builds into&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../decision-tree-splitting&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-splitting&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Splitting&lt;/a&gt; — internal nodes are created by splitting&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../decision-tree-structure&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-structure&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Structure&lt;/a&gt; — internal nodes form the tree’s intermediate layers&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../leaf-node&quot; class=&quot;internal alias&quot; data-slug=&quot;leaf-node&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Leaf Node&lt;/a&gt; — internal nodes eventually terminate at leaves&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../attribute-selection-measures&quot; class=&quot;internal alias&quot; data-slug=&quot;attribute-selection-measures&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Attribute Selection Measures&lt;/a&gt; — chooses which attribute to test&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../root-node&quot; class=&quot;internal alias&quot; data-slug=&quot;root-node&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Root Node&lt;/a&gt; — root is a special case of an internal node (the first one)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../decision-tree-prediction&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-prediction&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Prediction&lt;/a&gt; — internal nodes guide the prediction path&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Feature reuse&lt;/strong&gt;: In some implementations, the same feature can be tested at multiple internal nodes along different paths&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Exhausted attributes&lt;/strong&gt;: If all features have been used on a path, remaining internal nodes must use majority vote&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Depth explosion&lt;/strong&gt;: Internal nodes can proliferate, creating trees too deep to interpret&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Overfitting risk&lt;/strong&gt;: Each internal node adds complexity; too many internal nodes memorize training data&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>leaf-node</title>
    <link href="https://animishraa05.github.io/wiki/decision-tree/leaf-node" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/decision-tree/leaf-node.md" />
    <summary>The Problem After a series of attribute tests, the tree must produce an actual output.</summary>
    <published>2026-05-06T00:00:00.000Z</published>
    <updated>2026-05-06T00:00:00.000Z</updated>
    <publishedTime>May 06, 2026</publishedTime>
    <updatedTime>May 06, 2026</updatedTime>
    <category term="ml" label="ml" />
<category term="decision-trees" label="decision-trees" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;After a series of attribute tests, the tree must produce an actual output. Without terminal points that commit to a prediction, the tree would be an infinite chain of questions with no answers.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;A leaf node (terminal node) is the bottommost node in a decision tree that cannot be split further. Each leaf node represents a final decision or prediction — a class label in classification tasks, or a continuous numeric value in regression tasks.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Leaf nodes are created when stopping conditions are met during tree construction:&lt;/p&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Pure subset&lt;/strong&gt;: All instances in the node belong to the same class → leaf with that class label&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No remaining attributes&lt;/strong&gt;: No more features available to split on → leaf with majority vote of remaining instances&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No instances&lt;/strong&gt;: The node receives zero training instances → leaf with majority vote of the parent’s instances&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Max depth reached&lt;/strong&gt;: Pre-configured depth limit is hit → leaf with majority prediction of current subset&lt;/li&gt;
&lt;/ol&gt;
&lt;p dir=&quot;auto&quot;&gt;During prediction, a leaf node is the endpoint:&lt;/p&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;The incoming instance follows a path from root to leaf&lt;/li&gt;
&lt;li&gt;At the leaf, the stored prediction is returned as the tree’s output&lt;/li&gt;
&lt;li&gt;In classification, this is a discrete class (e.g., “Purchase” or “No Purchase”)&lt;/li&gt;
&lt;li&gt;In regression, this is typically the mean value of training samples that reached this leaf&lt;/li&gt;
&lt;/ul&gt;
&lt;p dir=&quot;auto&quot;&gt;The source example shows leaf nodes like “No Purchase” (when income ≤ &lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mn&gt;50&lt;/mn&gt;&lt;mi&gt;K&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;)&lt;/mo&gt;&lt;mi&gt;a&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mi&gt;d&lt;/mi&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;&quot;&lt;/mi&gt;&lt;mi&gt;P&lt;/mi&gt;&lt;mi&gt;u&lt;/mi&gt;&lt;mi&gt;r&lt;/mi&gt;&lt;mi&gt;c&lt;/mi&gt;&lt;mi&gt;h&lt;/mi&gt;&lt;mi&gt;a&lt;/mi&gt;&lt;mi&gt;s&lt;/mi&gt;&lt;mi&gt;e&lt;/mi&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;&quot;&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;(&lt;/mo&gt;&lt;mi&gt;w&lt;/mi&gt;&lt;mi&gt;h&lt;/mi&gt;&lt;mi&gt;e&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mi&gt;i&lt;/mi&gt;&lt;mi&gt;n&lt;/mi&gt;&lt;mi&gt;c&lt;/mi&gt;&lt;mi&gt;o&lt;/mi&gt;&lt;mi&gt;m&lt;/mi&gt;&lt;mi&gt;e&lt;/mi&gt;&lt;mo&gt;&gt;&lt;/mo&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt;50K) and &quot;Purchase&quot; (when income &gt; &lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1em;vertical-align:-0.25em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;50&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.0715em;&quot;&gt;K&lt;/span&gt;&lt;span class=&quot;mclose&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;an&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.1389em;&quot;&gt;P&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;u&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.0278em;&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;ha&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;se&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;mopen&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot; style=&quot;margin-right:0.0269em;&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;nin&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;co&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;mord mathnormal&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;50K, age &gt; 30, and previous purchases &gt; 0).&lt;/p&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: leaf_node Pages: 1 --&gt;
&lt;svg width=&quot;476pt&quot; height=&quot;166pt&quot; viewBox=&quot;0.00 0.00 476.00 166.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 161.6)&quot;&gt;
&lt;title&gt;leaf_node&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-161.6 472.08,-161.6 472.08,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- parent --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;parent&lt;/title&gt;
&lt;polygon fill=&quot;#cce5ff&quot; stroke=&quot;black&quot; points=&quot;299.76,-157.6 173.02,-157.6 173.02,-121.6 299.76,-121.6 299.76,-157.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;236.39&quot; y=&quot;-136&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Parent Internal Node&lt;/text&gt;
&lt;/g&gt;
&lt;!-- leaf1 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;leaf1&lt;/title&gt;
&lt;polygon fill=&quot;#ffcccc&quot; stroke=&quot;black&quot; points=&quot;115.39,-73.6 0,-36.8 115.39,0 230.79,-36.8 115.39,-73.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;115.39&quot; y=&quot;-40.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Leaf: No Purchase&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;115.39&quot; y=&quot;-26&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;(Class = Negative)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- parent&amp;#45;&amp;gt;leaf1 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;parent-&gt;leaf1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M215.59,-121.27C199.11,-107.54 175.59,-87.95 155.48,-71.2&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;157.9,-68.66 147.98,-64.94 153.42,-74.03 157.9,-68.66&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;231.88&quot; y=&quot;-94.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;condition not met&lt;/text&gt;
&lt;/g&gt;
&lt;!-- leaf2 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;leaf2&lt;/title&gt;
&lt;polygon fill=&quot;#d4edda&quot; stroke=&quot;black&quot; points=&quot;358.39,-73.6 248.7,-36.8 358.39,0 468.08,-36.8 358.39,-73.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;358.39&quot; y=&quot;-40.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Leaf: Purchase&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;358.39&quot; y=&quot;-26&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;(Class = Positive)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- parent&amp;#45;&amp;gt;leaf2 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;parent-&gt;leaf2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M257.37,-121.27C274.1,-107.44 298.03,-87.67 318.4,-70.84&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;320.53,-73.62 326.01,-64.55 316.07,-68.23 320.53,-73.62&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;319.83&quot; y=&quot;-94.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;condition met&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Terminal&lt;/strong&gt;: No outgoing branches — the decision path ends here&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Holds prediction&lt;/strong&gt;: Stores the class label (classification) or numeric value (regression)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No impurity&lt;/strong&gt;: Ideally, all instances at a leaf belong to the same class&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Majority vote fallback&lt;/strong&gt;: When impurity remains, predicts the most common class in the subset&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;semantic-network&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Semantic Network&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#semantic-network&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: semantic_Leaf_Node Pages: 1 --&gt;
&lt;svg width=&quot;178pt&quot; height=&quot;170pt&quot; viewBox=&quot;0.00 0.00 178.00 170.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 165.63)&quot;&gt;
&lt;title&gt;semantic_Leaf_Node&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-165.63 174.12,-165.63 174.12,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- THIS --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;THIS&lt;/title&gt;
&lt;ellipse fill=&quot;#ffd700&quot; stroke=&quot;black&quot; stroke-width=&quot;2&quot; cx=&quot;65.63&quot; cy=&quot;-86.21&quot; rx=&quot;50.32&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;65.63&quot; y=&quot;-82.31&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;13.00&quot;&gt;Leaf Node&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL1 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL1&lt;/title&gt;
&lt;ellipse fill=&quot;#f0f0f0&quot; stroke=&quot;black&quot; cx=&quot;109.53&quot; cy=&quot;-143.63&quot; rx=&quot;60.59&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;109.53&quot; y=&quot;-140.33&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Related Concept&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL1 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M79.04,-103.75C84.39,-110.74 90.53,-118.78 95.9,-125.8&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;106.51&quot; y=&quot;-102.17&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;related&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL2 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL2&lt;/title&gt;
&lt;ellipse fill=&quot;#d4edda&quot; stroke=&quot;black&quot; cx=&quot;41.67&quot; cy=&quot;-18&quot; rx=&quot;41.67&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;41.67&quot; y=&quot;-14.7&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Builds Into&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL2 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M59.21,-67.93C55.72,-57.98 51.42,-45.73 47.95,-35.86&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;83.33&quot; y=&quot;-39.29&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;builds into&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../decision-tree-structure&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-structure&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Structure&lt;/a&gt; — leaves are the terminal elements of the tree&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../decision-tree-stopping-conditions&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-stopping-conditions&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Stopping Conditions&lt;/a&gt; — determines when a node becomes a leaf&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../node-purity&quot; class=&quot;internal alias&quot; data-slug=&quot;node-purity&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Node Purity&lt;/a&gt; — pure subsets become leaves directly&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../decision-tree-prediction&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-prediction&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Prediction&lt;/a&gt; — leaves provide the final output&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../classification&quot; class=&quot;internal alias&quot; data-slug=&quot;classification&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Classification&lt;/a&gt; — leaf nodes output class labels in classification&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../regression&quot; class=&quot;internal alias&quot; data-slug=&quot;regression&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Regression&lt;/a&gt; — leaf nodes output continuous values in regression&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Single-sample leaves&lt;/strong&gt;: A leaf with one training sample is perfectly pure but almost certainly overfitted&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Empty leaves&lt;/strong&gt;: Can occur when a branch has no training data; defaults to parent’s majority class&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Imbalanced leaf predictions&lt;/strong&gt;: A leaf may be dominated by one class but still contain minority class errors&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Leaf depth variance&lt;/strong&gt;: Some leaves may be 2 levels deep, others 20 — leading to inconsistent prediction confidence&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>node-purity</title>
    <link href="https://animishraa05.github.io/wiki/decision-tree/node-purity" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/decision-tree/node-purity.md" />
    <summary>The Problem The entire goal of building a decision tree is to create groups where all members share the same class label.</summary>
    <published>2026-05-06T00:00:00.000Z</published>
    <updated>2026-05-06T00:00:00.000Z</updated>
    <publishedTime>May 06, 2026</publishedTime>
    <updatedTime>May 06, 2026</updatedTime>
    <category term="ml" label="ml" />
<category term="decision-trees" label="decision-trees" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;The entire goal of building a decision tree is to create groups where all members share the same class label. Without a clear definition of what “pure” means and how to measure it, we cannot evaluate whether a split is good or bad.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Node purity refers to how homogeneous a subset of data is with respect to the target class. A perfectly pure node contains instances of only one class. An impure node contains a mix of classes. The goal of every split in a decision tree is to create child nodes that are purer than the parent.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Purity is quantified by impurity measures:&lt;/p&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Entropy&lt;/strong&gt;: 0 = pure, log₂(c) = maximum impurity&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Gini Index&lt;/strong&gt;: 0 = pure, 0.5 = maximum impurity (binary classification)&lt;/li&gt;
&lt;/ul&gt;
&lt;p dir=&quot;auto&quot;&gt;&lt;strong&gt;The purity progression during tree building:&lt;/strong&gt;&lt;/p&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;Root node starts with the full dataset — typically impure (mixed classes)&lt;/li&gt;
&lt;li&gt;A split is chosen that maximally increases purity in the child nodes&lt;/li&gt;
&lt;li&gt;Each child node is evaluated: if pure enough, it becomes a leaf; if not, it splits again&lt;/li&gt;
&lt;li&gt;This continues until all leaf nodes are pure (or stopping conditions prevent further splitting)&lt;/li&gt;
&lt;/ol&gt;
&lt;p dir=&quot;auto&quot;&gt;The source states: “A decision tree splits the dataset based on feature values to create pure subsets — ideally all items in a group belong to the same class.” In the worked example, splitting on attribute Y produced children where one contained only class I and the other only class II — both perfectly pure.&lt;/p&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: node_purity Pages: 1 --&gt;
&lt;svg width=&quot;462pt&quot; height=&quot;128pt&quot; viewBox=&quot;0.00 0.00 462.00 128.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 124.2)&quot;&gt;
&lt;title&gt;node_purity&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-124.2 458.18,-124.2 458.18,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- impure --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;impure&lt;/title&gt;
&lt;polygon fill=&quot;#ffcccc&quot; stroke=&quot;black&quot; points=&quot;85.37,-85.2 0,-85.2 0,-34 85.37,-34 85.37,-85.2&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;42.68&quot; y=&quot;-70.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Impure Node&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;42.68&quot; y=&quot;-56&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;{I, I, II, II}&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;42.68&quot; y=&quot;-41.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Gini = 0.5&lt;/text&gt;
&lt;/g&gt;
&lt;!-- split --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;split&lt;/title&gt;
&lt;polygon fill=&quot;#cce5ff&quot; stroke=&quot;black&quot; points=&quot;289.45,-77.6 158.05,-77.6 158.05,-41.6 289.45,-41.6 289.45,-77.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;223.75&quot; y=&quot;-56&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Split on Best Attribute&lt;/text&gt;
&lt;/g&gt;
&lt;!-- impure&amp;#45;&amp;gt;split --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;impure-&gt;split&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M85.67,-59.6C103.81,-59.6 125.62,-59.6 146.45,-59.6&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;146.38,-63.1 156.38,-59.6 146.38,-56.1 146.38,-63.1&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;121.71&quot; y=&quot;-62.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;find split&lt;/text&gt;
&lt;/g&gt;
&lt;!-- pure1 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;pure1&lt;/title&gt;
&lt;polygon fill=&quot;#d4edda&quot; stroke=&quot;black&quot; points=&quot;454.18,-120.2 372.14,-120.2 372.14,-69 454.18,-69 454.18,-120.2&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;413.16&quot; y=&quot;-105.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Pure Child 1&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;413.16&quot; y=&quot;-91&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;{I, I}&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;413.16&quot; y=&quot;-76.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Gini = 0.0&lt;/text&gt;
&lt;/g&gt;
&lt;!-- split&amp;#45;&amp;gt;pure1 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;split-&gt;pure1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M289.77,-71.74C313,-76.08 338.83,-80.9 360.75,-85&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;359.86,-88.39 370.33,-86.79 361.15,-81.51 359.86,-88.39&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;330.8&quot; y=&quot;-86.28&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;outcome 1&lt;/text&gt;
&lt;/g&gt;
&lt;!-- pure2 --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;pure2&lt;/title&gt;
&lt;polygon fill=&quot;#d4edda&quot; stroke=&quot;black&quot; points=&quot;454.18,-51.2 372.14,-51.2 372.14,0 454.18,0 454.18,-51.2&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;413.16&quot; y=&quot;-36.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Pure Child 2&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;413.16&quot; y=&quot;-22&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;{II, II}&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;413.16&quot; y=&quot;-7.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Gini = 0.0&lt;/text&gt;
&lt;/g&gt;
&lt;!-- split&amp;#45;&amp;gt;pure2 --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;split-&gt;pure2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M289.77,-47.8C313,-43.59 338.83,-38.9 360.75,-34.93&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;361.12,-38.42 370.33,-33.19 359.87,-31.53 361.12,-38.42&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;330.8&quot; y=&quot;-46.62&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;outcome 2&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Binary notion&lt;/strong&gt;: A node is either pure (one class) or impure (multiple classes)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Measurable&lt;/strong&gt;: Quantified by entropy, Gini Index, or other impurity metrics&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Progressive&lt;/strong&gt;: Purity increases (impurity decreases) with each effective split&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Local&lt;/strong&gt;: Purity is evaluated per-node, not globally across the tree&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;semantic-network&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Semantic Network&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#semantic-network&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: semantic_Node_Purity Pages: 1 --&gt;
&lt;svg width=&quot;178pt&quot; height=&quot;170pt&quot; viewBox=&quot;0.00 0.00 178.00 170.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 165.63)&quot;&gt;
&lt;title&gt;semantic_Node_Purity&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-165.63 174.12,-165.63 174.12,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- THIS --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;THIS&lt;/title&gt;
&lt;ellipse fill=&quot;#ffd700&quot; stroke=&quot;black&quot; stroke-width=&quot;2&quot; cx=&quot;65.63&quot; cy=&quot;-86.21&quot; rx=&quot;55.57&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;65.63&quot; y=&quot;-82.31&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;13.00&quot;&gt;Node Purity&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL1 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL1&lt;/title&gt;
&lt;ellipse fill=&quot;#f0f0f0&quot; stroke=&quot;black&quot; cx=&quot;109.53&quot; cy=&quot;-143.63&quot; rx=&quot;60.59&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;109.53&quot; y=&quot;-140.33&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Related Concept&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL1 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M79.28,-104.06C84.62,-111.04 90.72,-119.02 96.04,-125.98&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;106.7&quot; y=&quot;-102.42&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;related&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL2 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL2&lt;/title&gt;
&lt;ellipse fill=&quot;#d4edda&quot; stroke=&quot;black&quot; cx=&quot;41.67&quot; cy=&quot;-18&quot; rx=&quot;41.67&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;41.67&quot; y=&quot;-14.7&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Builds Into&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL2 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M59.21,-67.93C55.72,-57.98 51.42,-45.73 47.95,-35.86&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;83.33&quot; y=&quot;-39.29&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;builds into&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../entropy&quot; class=&quot;internal alias&quot; data-slug=&quot;entropy&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Entropy&lt;/a&gt; — entropy is one measure of (im)purity&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../gini-index&quot; class=&quot;internal alias&quot; data-slug=&quot;gini-index&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Gini Index&lt;/a&gt; — Gini is another measure of (im)purity&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../decision-tree-splitting&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-splitting&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Splitting&lt;/a&gt; — splitting aims to increase purity&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../leaf-node&quot; class=&quot;internal alias&quot; data-slug=&quot;leaf-node&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Leaf Node&lt;/a&gt; — pure nodes become leaves&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../node-purity&quot; class=&quot;internal alias&quot; data-slug=&quot;node-purity&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Node Purity&lt;/a&gt; — the concept itself&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../information-gain&quot; class=&quot;internal alias&quot; data-slug=&quot;information-gain&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Information Gain&lt;/a&gt; — IG measures the purity increase from a split&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../recursive-tree-building&quot; class=&quot;internal alias&quot; data-slug=&quot;recursive-tree-building&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Recursive Tree Building&lt;/a&gt; — purity determines when to stop recursing&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Perfect purity = overfitting&lt;/strong&gt;: A pure leaf with a single training instance memorizes noise&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Near-purity is common&lt;/strong&gt;: Real-world data rarely achieves perfect purity; thresholds must be set&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Purity ≠ accuracy&lt;/strong&gt;: A pure node may be “pure” but wrong if the training data has errors&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Class skew&lt;/strong&gt;: In imbalanced datasets, a node can appear pure by being dominated by the majority class&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>recursive-tree-building</title>
    <link href="https://animishraa05.github.io/wiki/decision-tree/recursive-tree-building" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/decision-tree/recursive-tree-building.md" />
    <summary>The Problem A decision tree cannot be built in a single pass — it needs to grow incrementally, making decisions at each node based on the data that reaches it, and stopping at the right time to avoid overfitting.</summary>
    <published>2026-05-06T00:00:00.000Z</published>
    <updated>2026-05-06T00:00:00.000Z</updated>
    <publishedTime>May 06, 2026</publishedTime>
    <updatedTime>May 06, 2026</updatedTime>
    <category term="ml" label="ml" />
<category term="decision-trees" label="decision-trees" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;A decision tree cannot be built in a single pass — it needs to grow incrementally, making decisions at each node based on the data that reaches it, and stopping at the right time to avoid overfitting.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;Recursive tree building is the top-down algorithm that starts with all training data at the root, selects the best attribute using an attribute selection measure, creates child nodes for each attribute value, and then recursively applies the same process to each child node until stopping conditions are met.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;The algorithm proceeds as follows:&lt;/p&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Start at root&lt;/strong&gt;: Associate all training instances with the root node&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Choose best attribute&lt;/strong&gt;: Use Information Gain (or Gini Index) to select the attribute that best splits the data&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Create branches&lt;/strong&gt;: For each possible value of the selected attribute, create a child node and assign the corresponding data subset&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Recurse on each child&lt;/strong&gt;: For each child node, repeat steps 2-3 using only the data subset that reached that node&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Apply stopping conditions&lt;/strong&gt; at each node:
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;All same class&lt;/strong&gt;: If all instances at this node belong to one class → label the node with that class (leaf)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No attributes left&lt;/strong&gt;: If no more attributes are available to split → label with majority vote of remaining instances&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No instances&lt;/strong&gt;: If the node receives zero instances → label with majority vote of the parent’s instances&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Terminate&lt;/strong&gt;: When all branches end in leaf nodes, the tree is complete&lt;/li&gt;
&lt;/ol&gt;
&lt;p dir=&quot;auto&quot;&gt;The source describes this as: “Recursively construct each subtree on the subset of training instances that would be classified down that path in the tree.”&lt;/p&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: recursive_tree_building Pages: 1 --&gt;
&lt;svg width=&quot;409pt&quot; height=&quot;358pt&quot; viewBox=&quot;0.00 0.00 409.00 358.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 354)&quot;&gt;
&lt;title&gt;recursive_tree_building&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-354 404.94,-354 404.94,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- start --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;start&lt;/title&gt;
&lt;polygon fill=&quot;#ffd700&quot; stroke=&quot;black&quot; points=&quot;352.94,-350 228.1,-350 228.1,-314 352.94,-314 352.94,-350&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;290.52&quot; y=&quot;-328.7&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Step 1: All data at root&lt;/text&gt;
&lt;/g&gt;
&lt;!-- select --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;select&lt;/title&gt;
&lt;polygon fill=&quot;#cce5ff&quot; stroke=&quot;black&quot; points=&quot;366.09,-277 214.95,-277 214.95,-241 366.09,-241 366.09,-277&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;290.52&quot; y=&quot;-262.3&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Step 2: Select best attribute&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;290.52&quot; y=&quot;-249.1&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;(max IG / min Gini)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- start&amp;#45;&amp;gt;select --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;start-&gt;select&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M290.52,-313.81C290.52,-306.23 290.52,-297.1 290.52,-288.54&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;294.02,-288.54 290.52,-278.54 287.02,-288.54 294.02,-288.54&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- split --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;split&lt;/title&gt;
&lt;polygon fill=&quot;#cce5ff&quot; stroke=&quot;black&quot; points=&quot;301.48,-204 129.55,-204 129.55,-168 301.48,-168 301.48,-204&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;215.52&quot; y=&quot;-189.3&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Step 3: Create child nodes&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;215.52&quot; y=&quot;-176.1&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;partition data by attribute values&lt;/text&gt;
&lt;/g&gt;
&lt;!-- select&amp;#45;&amp;gt;split --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;select-&gt;split&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M272.36,-240.81C263.22,-232.16 251.96,-221.5 241.88,-211.96&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;244.53,-209.65 234.86,-205.32 239.72,-214.73 244.53,-209.65&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- check --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;check&lt;/title&gt;
&lt;polygon fill=&quot;#e8d5f5&quot; stroke=&quot;black&quot; points=&quot;159.52,-120 0,-102 159.52,-84 319.04,-102 159.52,-120&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;159.52&quot; y=&quot;-98.7&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Step 4: Check stopping conditions&lt;/text&gt;
&lt;/g&gt;
&lt;!-- split&amp;#45;&amp;gt;check --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;split-&gt;check&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M203.64,-167.61C195.86,-156.22 185.57,-141.15 176.88,-128.42&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;180,-126.78 171.47,-120.5 174.22,-130.73 180,-126.78&quot;&gt;&lt;/polygon&gt;
&lt;/g&gt;
&lt;!-- leaf --&gt;
&lt;g id=&quot;node5&quot; class=&quot;node&quot;&gt;
&lt;title&gt;leaf&lt;/title&gt;
&lt;polygon fill=&quot;#d4edda&quot; stroke=&quot;black&quot; points=&quot;159.52,-36 69.54,-18 159.52,0 249.5,-18 159.52,-36&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;159.52&quot; y=&quot;-14.7&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Stop → Leaf node&lt;/text&gt;
&lt;/g&gt;
&lt;!-- check&amp;#45;&amp;gt;leaf --&gt;
&lt;g id=&quot;edge4&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;check-&gt;leaf&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M159.52,-83.61C159.52,-73.17 159.52,-59.64 159.52,-47.66&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;163.02,-47.88 159.52,-37.88 156.02,-47.88 163.02,-47.88&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;189.26&quot; y=&quot;-57&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;condition met&lt;/text&gt;
&lt;/g&gt;
&lt;!-- recurse --&gt;
&lt;g id=&quot;node6&quot; class=&quot;node&quot;&gt;
&lt;title&gt;recurse&lt;/title&gt;
&lt;polygon fill=&quot;#ffd700&quot; stroke=&quot;black&quot; points=&quot;400.94,-36 276.1,-36 276.1,0 400.94,0 400.94,-36&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;338.52&quot; y=&quot;-21.3&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Recurse on each child&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;338.52&quot; y=&quot;-8.1&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;(go to Step 2)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- check&amp;#45;&amp;gt;recurse --&gt;
&lt;g id=&quot;edge5&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;check-&gt;recurse&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M188.06,-86.91C207.5,-77.41 233.87,-64.7 257.36,-54 266.79,-49.7 276.9,-45.23 286.67,-40.99&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;287.91,-44.26 295.7,-37.08 285.13,-37.84 287.91,-44.26&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;295.44&quot; y=&quot;-57&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;condition not met&lt;/text&gt;
&lt;/g&gt;
&lt;!-- recurse&amp;#45;&amp;gt;select --&gt;
&lt;g id=&quot;edge6&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;recurse-&gt;select&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M337.4,-36.23C335.96,-56.39 333.08,-90.75 328.52,-120 322.63,-157.72 321.18,-167.34 310.52,-204 308.02,-212.58 304.83,-221.75 301.74,-230.05&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;298.51,-228.7 298.19,-239.29 305.04,-231.21 298.51,-228.7&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;339.8&quot; y=&quot;-141&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;repeat&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Top-down&lt;/strong&gt;: Always starts from the full dataset and refines downward&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Greedy&lt;/strong&gt;: Never reconsiders or backtracks on previous split decisions&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Divide and conquer&lt;/strong&gt;: Each recursive call handles a smaller, simpler subset&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Deterministic&lt;/strong&gt;: Given the same data and measure, always produces the same tree&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;semantic-network&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Semantic Network&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#semantic-network&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: semantic_Recursive_Tree_Building Pages: 1 --&gt;
&lt;svg width=&quot;203pt&quot; height=&quot;170pt&quot; viewBox=&quot;0.00 0.00 203.00 170.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 165.63)&quot;&gt;
&lt;title&gt;semantic_Recursive_Tree_Building&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-165.63 198.97,-165.63 198.97,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- THIS --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;THIS&lt;/title&gt;
&lt;ellipse fill=&quot;#ffd700&quot; stroke=&quot;black&quot; stroke-width=&quot;2&quot; cx=&quot;90.48&quot; cy=&quot;-86.21&quot; rx=&quot;90.48&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;90.48&quot; y=&quot;-82.31&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;13.00&quot;&gt;Recursive Tree Build&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL1 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL1&lt;/title&gt;
&lt;ellipse fill=&quot;#f0f0f0&quot; stroke=&quot;black&quot; cx=&quot;134.38&quot; cy=&quot;-143.63&quot; rx=&quot;60.59&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;134.38&quot; y=&quot;-140.33&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Related Concept&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL1 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M104.37,-104.37C109.6,-111.21 115.53,-118.97 120.73,-125.77&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;131.59&quot; y=&quot;-119.27&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;related&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL2 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL2&lt;/title&gt;
&lt;ellipse fill=&quot;#d4edda&quot; stroke=&quot;black&quot; cx=&quot;66.53&quot; cy=&quot;-18&quot; rx=&quot;41.67&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;66.53&quot; y=&quot;-14.7&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Builds Into&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL2 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M84.06,-67.93C80.57,-57.98 76.27,-45.73 72.8,-35.86&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;108.18&quot; y=&quot;-39.29&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;builds into&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../decision-tree-splitting&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-splitting&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Splitting&lt;/a&gt; — splitting is the recursive step&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../attribute-selection-measures&quot; class=&quot;internal alias&quot; data-slug=&quot;attribute-selection-measures&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Attribute Selection Measures&lt;/a&gt; — determines the best attribute at each step&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../decision-tree-stopping-conditions&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-stopping-conditions&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Stopping Conditions&lt;/a&gt; — determines when recursion terminates&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../decision-tree-structure&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-structure&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Structure&lt;/a&gt; — the result of recursive building&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../root-node&quot; class=&quot;internal alias&quot; data-slug=&quot;root-node&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Root Node&lt;/a&gt; — the base case of the recursion&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../leaf-node&quot; class=&quot;internal alias&quot; data-slug=&quot;leaf-node&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Leaf Node&lt;/a&gt; — the termination case of the recursion&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../information-gain&quot; class=&quot;internal alias&quot; data-slug=&quot;information-gain&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Information Gain&lt;/a&gt; — common criterion for attribute selection&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;No base case&lt;/strong&gt;: If stopping conditions are not properly checked, the recursion may create infinite depth&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Data fragmentation&lt;/strong&gt;: Deep recursion produces very small subsets that may not generalize&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Attribute exhaustion&lt;/strong&gt;: Running out of attributes before reaching purity forces majority vote leaves&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Memory growth&lt;/strong&gt;: Each recursive call holds its own data subset; deep trees consume significant memory&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry><entry>
    <title>root-node</title>
    <link href="https://animishraa05.github.io/wiki/decision-tree/root-node" />
    <link rel="alternate" type="text/markdown" href="https://animishraa05.github.io/wiki/decision-tree/root-node.md" />
    <summary>The Problem When building a decision tree from scratch, the first question matters most — it determines how the entire dataset is initially partitioned, and a poor first split cascades into suboptimal decisions throughout the tree.</summary>
    <published>2026-05-06T00:00:00.000Z</published>
    <updated>2026-05-06T00:00:00.000Z</updated>
    <publishedTime>May 06, 2026</publishedTime>
    <updatedTime>May 06, 2026</updatedTime>
    <category term="ml" label="ml" />
<category term="decision-trees" label="decision-trees" />
    <author>
      <name>Animesh Mishra</name>
      <email>animesh.mishra818@gmail.com</email>
    </author>
    <content type="html">&lt;h2 id=&quot;the-problem&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;The Problem&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#the-problem&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;When building a decision tree from scratch, the first question matters most — it determines how the entire dataset is initially partitioned, and a poor first split cascades into suboptimal decisions throughout the tree.&lt;/p&gt;
&lt;h2 id=&quot;core-idea&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Core Idea&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#core-idea&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;The root node is the topmost node of a decision tree, representing the entire training dataset. It performs the first and most impactful attribute test, chosen because it provides the maximum Information Gain (or minimum Gini impurity) among all available features.&lt;/p&gt;
&lt;h2 id=&quot;how-it-works&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;How It Works&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#how-it-works&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p dir=&quot;auto&quot;&gt;During tree construction:&lt;/p&gt;
&lt;ol dir=&quot;auto&quot;&gt;
&lt;li&gt;All training instances are associated with the root node&lt;/li&gt;
&lt;li&gt;Every available attribute is evaluated using an attribute selection measure (Information Gain, Gini Index)&lt;/li&gt;
&lt;li&gt;The attribute that best separates the data — creating the purest child subsets — is selected&lt;/li&gt;
&lt;li&gt;The root node is labeled with this attribute and branches are created for each possible value&lt;/li&gt;
&lt;li&gt;Each branch receives a subset of the data, which becomes the input for the corresponding child node&lt;/li&gt;
&lt;/ol&gt;
&lt;p dir=&quot;auto&quot;&gt;The root node is unique because it sees the full dataset. Its split has the largest potential impact on tree quality. In the customer purchase example from the source, “Income &gt; $50K?” is chosen as the root because income is the strongest single predictor of whether someone will buy a product.&lt;/p&gt;
&lt;h2 id=&quot;visual-explanation&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Visual Explanation&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#visual-explanation&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: root_node Pages: 1 --&gt;
&lt;svg width=&quot;318pt&quot; height=&quot;230pt&quot; viewBox=&quot;0.00 0.00 318.00 230.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 225.64)&quot;&gt;
&lt;title&gt;root_node&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-225.64 313.9,-225.64 313.9,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- dataset --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;dataset&lt;/title&gt;
&lt;ellipse fill=&quot;#e8e8e8&quot; stroke=&quot;black&quot; cx=&quot;156.7&quot; cy=&quot;-195.62&quot; rx=&quot;98.08&quot; ry=&quot;26.02&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;156.7&quot; y=&quot;-199.22&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Full Dataset&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;156.7&quot; y=&quot;-184.82&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;(All Training Instances)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- root --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;root&lt;/title&gt;
&lt;polygon fill=&quot;#ffd700&quot; stroke=&quot;black&quot; points=&quot;218.06,-121.6 95.35,-121.6 95.35,-84.8 218.06,-84.8 218.06,-121.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;156.7&quot; y=&quot;-106.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Root Node&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;156.7&quot; y=&quot;-92.4&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;(Best Attribute Split)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- dataset&amp;#45;&amp;gt;root --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;dataset-&gt;root&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M156.7,-169.43C156.7,-158.26 156.7,-145.05 156.7,-133.45&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;160.2,-133.6 156.7,-123.6 153.2,-133.6 160.2,-133.6&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;191.17&quot; y=&quot;-142.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;all data flows to&lt;/text&gt;
&lt;/g&gt;
&lt;!-- left_child --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;left_child&lt;/title&gt;
&lt;polygon fill=&quot;#cce5ff&quot; stroke=&quot;black&quot; points=&quot;149.41,-36.8 0,-36.8 0,0 149.41,0 149.41,-36.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;74.7&quot; y=&quot;-22&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Child Node 1&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;74.7&quot; y=&quot;-7.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;(Subset: Income &amp;#x3C;= 50K)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- root&amp;#45;&amp;gt;left_child --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;root-&gt;left_child&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M139.31,-84.64C127.97,-73.19 112.98,-58.05 100.29,-45.24&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;102.94,-42.94 93.42,-38.3 97.97,-47.86 102.94,-42.94&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;143.68&quot; y=&quot;-57.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;No branch&lt;/text&gt;
&lt;/g&gt;
&lt;!-- right_child --&gt;
&lt;g id=&quot;node4&quot; class=&quot;node&quot;&gt;
&lt;title&gt;right_child&lt;/title&gt;
&lt;polygon fill=&quot;#cce5ff&quot; stroke=&quot;black&quot; points=&quot;309.9,-36.8 167.5,-36.8 167.5,0 309.9,0 309.9,-36.8&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;238.7&quot; y=&quot;-22&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;Child Node 2&lt;/text&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;238.7&quot; y=&quot;-7.6&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;12.00&quot;&gt;(Subset: Income &gt; 50K)&lt;/text&gt;
&lt;/g&gt;
&lt;!-- root&amp;#45;&amp;gt;right_child --&gt;
&lt;g id=&quot;edge3&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;root-&gt;right_child&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M174.09,-84.64C185.43,-73.19 200.42,-58.05 213.11,-45.24&quot;&gt;&lt;/path&gt;
&lt;polygon fill=&quot;black&quot; stroke=&quot;black&quot; points=&quot;215.44,-47.86 219.99,-38.3 210.47,-42.94 215.44,-47.86&quot;&gt;&lt;/polygon&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;227.91&quot; y=&quot;-57.8&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;10.00&quot;&gt;Yes branch&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;key-properties&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Key Properties&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#key-properties&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Maximum impact&lt;/strong&gt;: The root split affects every subsequent decision in the tree&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Chosen by metric&lt;/strong&gt;: Selected via highest Information Gain or lowest Gini Index among all attributes&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Single per tree&lt;/strong&gt;: Every decision tree has exactly one root node&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Sees all data&lt;/strong&gt;: Unlike internal nodes, the root evaluates every training instance&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;semantic-network&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Semantic Network&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#semantic-network&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;graphviz-container&quot; style=&quot;display: flex; justify-content: center; margin: 1.5rem 0; overflow-x: auto;&quot; dir=&quot;auto&quot;&gt;&lt;!--?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?--&gt;

&lt;!-- Generated by graphviz version 15.1.0 (0)
 --&gt;
&lt;!-- Title: semantic_Root_Node Pages: 1 --&gt;
&lt;svg width=&quot;178pt&quot; height=&quot;170pt&quot; viewBox=&quot;0.00 0.00 178.00 170.00&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot;&gt;
&lt;g id=&quot;graph0&quot; class=&quot;graph&quot; transform=&quot;scale(1 1) rotate(0) translate(4 165.63)&quot;&gt;
&lt;title&gt;semantic_Root_Node&lt;/title&gt;
&lt;polygon fill=&quot;white&quot; stroke=&quot;none&quot; points=&quot;-4,4 -4,-165.63 174.12,-165.63 174.12,4 -4,4&quot;&gt;&lt;/polygon&gt;
&lt;!-- THIS --&gt;
&lt;g id=&quot;node1&quot; class=&quot;node&quot;&gt;
&lt;title&gt;THIS&lt;/title&gt;
&lt;ellipse fill=&quot;#ffd700&quot; stroke=&quot;black&quot; stroke-width=&quot;2&quot; cx=&quot;65.63&quot; cy=&quot;-86.21&quot; rx=&quot;51.74&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;65.63&quot; y=&quot;-82.31&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;13.00&quot;&gt;Root Node&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL1 --&gt;
&lt;g id=&quot;node2&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL1&lt;/title&gt;
&lt;ellipse fill=&quot;#f0f0f0&quot; stroke=&quot;black&quot; cx=&quot;109.53&quot; cy=&quot;-143.63&quot; rx=&quot;60.59&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;109.53&quot; y=&quot;-140.33&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Related Concept&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL1 --&gt;
&lt;g id=&quot;edge1&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL1&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M79.28,-104.06C84.62,-111.04 90.72,-119.02 96.04,-125.98&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;106.7&quot; y=&quot;-102.42&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;related&lt;/text&gt;
&lt;/g&gt;
&lt;!-- REL2 --&gt;
&lt;g id=&quot;node3&quot; class=&quot;node&quot;&gt;
&lt;title&gt;REL2&lt;/title&gt;
&lt;ellipse fill=&quot;#d4edda&quot; stroke=&quot;black&quot; cx=&quot;41.67&quot; cy=&quot;-18&quot; rx=&quot;41.67&quot; ry=&quot;18&quot;&gt;&lt;/ellipse&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;41.67&quot; y=&quot;-14.7&quot; font-family=&quot;Helvetica,sans-Serif&quot; font-size=&quot;11.00&quot;&gt;Builds Into&lt;/text&gt;
&lt;/g&gt;
&lt;!-- THIS&amp;#45;&amp;#45;REL2 --&gt;
&lt;g id=&quot;edge2&quot; class=&quot;edge&quot;&gt;
&lt;title&gt;THIS--REL2&lt;/title&gt;
&lt;path fill=&quot;none&quot; stroke=&quot;black&quot; d=&quot;M59.21,-67.93C55.72,-57.98 51.42,-45.73 47.95,-35.86&quot;&gt;&lt;/path&gt;
&lt;text xml:space=&quot;preserve&quot; text-anchor=&quot;middle&quot; x=&quot;83.33&quot; y=&quot;-39.29&quot; font-family=&quot;Times,serif&quot; font-size=&quot;14.00&quot;&gt;builds into&lt;/text&gt;
&lt;/g&gt;
&lt;/g&gt;
&lt;/svg&gt;
&lt;/div&gt;
&lt;h2 id=&quot;connections&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Connections&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#connections&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../decision-tree-structure&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-structure&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Structure&lt;/a&gt; — root is the top element of the tree&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../attribute-selection-measures&quot; class=&quot;internal alias&quot; data-slug=&quot;attribute-selection-measures&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Attribute Selection Measures&lt;/a&gt; — determines which attribute becomes the root&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../information-gain&quot; class=&quot;internal alias&quot; data-slug=&quot;information-gain&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Information Gain&lt;/a&gt; — common criterion for root selection&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Built from:&lt;/strong&gt; &lt;a href=&quot;../../gini-index&quot; class=&quot;internal alias&quot; data-slug=&quot;gini-index&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Gini Index&lt;/a&gt; — alternative criterion for root selection&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Builds into:&lt;/strong&gt; &lt;a href=&quot;../../internal-node&quot; class=&quot;internal alias&quot; data-slug=&quot;internal-node&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Internal Node&lt;/a&gt; — children of the root become internal nodes&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Related:&lt;/strong&gt; &lt;a href=&quot;../../decision-tree-splitting&quot; class=&quot;internal alias&quot; data-slug=&quot;decision-tree-splitting&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;Decision Tree Splitting&lt;/a&gt; — root performs the first split&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;edge-cases--gotchas&quot; dir=&quot;auto&quot;&gt;&lt;span class=&quot;highlight-span&quot;&gt;Edge Cases &amp;#x26; Gotchas&lt;/span&gt;&lt;a data-role=&quot;anchor&quot; data-no-popover href=&quot;#edge-cases--gotchas&quot; class=&quot;internal&quot;&gt;&lt;span class=&quot;indicator-hook&quot;&gt;&lt;/span&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;use href=&quot;#github-anchor&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul dir=&quot;auto&quot;&gt;
&lt;li&gt;&lt;strong&gt;Tied attributes&lt;/strong&gt;: Two features may have identical Information Gain; the choice is arbitrary and can affect tree shape&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No good split&lt;/strong&gt;: If no attribute reduces impurity, the root becomes a leaf immediately (majority vote)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Sensitive to data changes&lt;/strong&gt;: Adding or removing a few samples can change which attribute is selected as root&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Single point of failure&lt;/strong&gt;: A bad root choice cannot be corrected by later splits&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry>
</feed>