run costruisci-un-albero.bas
MDN-119:44
DEMO by Michele di Nuzzo

Build a tree

MDN · LAB BUILD A TREE Decision trees · 1984
radice / ramo «sì» / ramo «no»
root, “yes” branch, “no” branch: choose the node to work on
domanda su
question on: choose the variable of the question
soglia
threshold: move the split point
Taglio migliore per questo nodo
best split for this node: the one with the lowest Gini
questo nodo fa una domanda
this node asks a question: switch its split on or off
Albero di Gini completo
complete Gini tree: best split in all three nodes

▶ Run ⬇ Download (.html)

The lab shows how a decision tree chooses its questions. On 4,000 online orders from 2023 and 2024 you choose the variable and threshold of each node yourself; on the right is the Gini impurity curve for each possible threshold, with the white dot on the best split. The lab’s interface is in Italian.

Things to try

  • The first question: try total, items and first order by hand, then press “Taglio migliore” (best split).
  • The Gini curve: with the total it is irregular, with many local minima.
  • Different questions in the branches: press “Albero di Gini completo” (complete Gini tree) and see the best question change.

The article: Build a tree.

The demo is a single HTML file: download it and use it offline, even without an internet connection. Licence: CC BY-NC 4.0 — you may share it, crediting the author and this page, but not for commercial purposes.