การใช้ entropy เป็น criterion
ในแบบฝึกหัดนี้ จะได้ฝึก classification tree บนชุดข้อมูล Wisconsin Breast Cancer โดยใช้ entropy เป็น information criterion โดยใช้ฟีเจอร์ทั้ง 30 ตัวในชุดข้อมูล ซึ่งแบ่งเป็นข้อมูล train 80% และ test 20%
X_train และอาร์เรย์ของ label y_train พร้อมใช้งานใน workspace แล้ว
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
Machine Learning with Tree-Based Models in Python
คำแนะนำการฝึกหัด
Import
DecisionTreeClassifierจากsklearn.treeสร้าง
DecisionTreeClassifierชื่อdt_entropyโดยกำหนด maximum depth เป็น 8ตั้งค่า information criterion เป็น
'entropy'Fit
dt_entropyบนชุดข้อมูล training
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# Import DecisionTreeClassifier from sklearn.tree
from ____.____ import ____
# Instantiate dt_entropy, set 'entropy' as the information criterion
dt_entropy = ____(____=____, ____='____', random_state=1)
# Fit dt_entropy to the training set
____.____(____, ____)