เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

Calculating root entropy

This exercise continues with the loan default example from the slides. The image shows the root node of a decision tree split by color. In these next three exercises, you will calculate the entropy of the root node, calculate the entropy of the child nodes, and determine the information gain that color provides for determining loan default status.

In this exercise, the task is to calculate the entropy of the root node in this decision tree.

decison tree split by color

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

Dimensionality Reduction in R

ดูคอร์ส

คำแนะนำการฝึกหัด

  • Calculate the class probabilities of "yes" and "no" classes in the root node for defaulting on a loan.
  • Use the class probabilities to calculate the entropy of the root node.

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

# Calculate the class probabilities
p_yes <- ___
p_no <- ___

# Calculate the entropy
entropy_root <- -(___ * log2(p_yes)) + 
  -(___ * ___(___))

entropy_root
แก้ไขและรันโค้ด