MulaiMulai sekarang secara gratis

Splitting the tree

Given the Gini index that would result from splitting by either variable A or B, respectively, decide by which variable the tree should split next.

Latihan ini adalah bagian dari kursus

HR Analytics: Predicting Employee Churn in Python

Lihat Kursus

Petunjuk latihan

  • Check which Gini is lower.
  • If A has lower Gini, split by A, else, split by B.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Gini index in case of splitting by variable A or B
gini_A = 0.65
gini_B = 0.15

# check which Gini is lower and use it for spliting
if ____ < ____:
    print("split by A!")
____:
    print("split by B!")
Edit dan Jalankan Kode