Neuron 101

Classification / Decision tree

Türkçe

Plate37

Unit 4 · Topic 5 of 10

Decision tree

Medium, 8 min, 7 steps

812162024283236024681012temperature, degreessunny hours
Keyboard: left and right arrows change the step, space plays and pauses.

Step 1 of 7 Days

Separating by asking questions

The red circles are days when the ice cream sold out, the blue squares days when it did not. A decision tree starts with a single question: is a feature below a threshold? Then it asks each part new questions.

Open in Colab
  1. def gini(s):
  2. if not s:
  3. return 0
  4. p = sum(s) / len(s)
  5. return 1 - p * p - (1 - p) ** 2
  6. def puan(sol, sag):
  7. n = len(sol) + len(sag)
  8. return (len(sol) * gini(sol)
  9. + len(sag) * gini(sag)) / n
  10. # her özellik ve eşik için puan
  11. # hesaplanır, en küçüğü seçilir
derinlik
2
yaprak
3
dogruluk
0.94