Curvingo · Made in India

Glossary

Select one of the keywords on the left…

Decision TreesDecision Tree

Reading time: ~5 min

Back at the stall, Meena picks 20 mangoes she is sure about — 10 of each kind — and Sonu weighs and measures them. These are the training data. Each dot is one mango: amber for Alphonso and green for Totapuri.

Every question a tree asks is one straight cut: "Is the weight at most so many grams?" or "Is the length at most so many centimetres?". Each side of the cut then guesses the kind it has most of, and mangoes that land on the wrong side get a red ring. Drag the purple cut and complete both missions.

The cleanest single question is "Is the length at most 10.25 cm?". Only two mangoes end up on the wrong side: a short Totapuri that is very heavy, and a long Alphonso that is very big. One question cannot sort them, so the tree asks a second question on each side — and a third, if it needs one.

Split, Then Split Again

The computer repeats the same trick inside every box: find the best cut, split, then look at each new box on its own. Tap a box that still holds both colours. The computer finds the best question for that box, and the tree diagram below grows one node at a time.

That is the whole training algorithm, and it has a name: recursive partitioning. Split the data, split each part in the same way, and keep going until every box is pure. Every box on the chart is one leaf of the tree. The number of questions on the longest path is the tree's depth; Meena's tree has depth 3.

Sina