Pruning (การตัดแต่ง) เป็นกระบวนการลดขนาด Decision Trees สามารถลดความเสี่ยงของ Overfitting โดยกำหนดขนาด Tree หรือกำจัดพื้นที่ของ Tree ที่ให้ Power น้อย Pruning ช่วยโดยการ Trim กิ่งที่ตาม Anomalies ใน Training Data เนื่องจาก Noise หรือ Outliers และช่วย Original Tree ด้วยวิธีที่เพิ่ม Generalization Efficiency (ประสิทธิภาพการทั่วไป) ของ Tree
วิธีต่างๆ โดยทั่วไปใช้ Statistical Measures เพื่อลบ Branches ที่น่าเชื่อถือน้อยที่สุด (Least Reliable) มักผลลัพธ์เป็น Classification ที่เร็วกว่า และปรับปรุงความสามารถของ Tree ในการจัดประเภท Independent Test Data ให้ถูกต้อง
2 แนวทางหลักของ Tree Pruning
1. Pre-pruning Approach (การตัดแต่งก่อน - Early Stopping)
ใน Pre-pruning Tree ถูก "Pruned" โดยหยุดการสร้างก่อนเวลา (Early) (เช่น โดยตัดสินใจไม่แบ่ง/Partition Subset ของ Training Samples ที่ Node ที่กำหนดเพิ่มเติม) เมื่อหยุด Node กลายเป็น Leaf Leaf สามารถแสดง Most Common Class ระหว่าง Subset Samples หรือ Probability Distribution ของ Samples นั้นๆ
เมื่อสร้าง Tree Measures เช่น Statistical Significance, χ² (Chi-square), Information Gain ฯลฯ 可用于 决定 Split 的慷慨 (Generosity of a split) หากการ Partition Samples ที่ Node นำไปสู่ Split ที่ต่ำกว่า Pre-specified Threshold แล้ว การ Partition ของ Subset นั้นจะหยุด มีปัญหาในการเลือก Threshold ที่เหมาะสม Threshold สูงเกินไป → Oversimplified Trees, Threshold ต่ำเกินไป → Very Little Simplification
2. Post-pruning Approach (การตัดแต่งหลัง - Pruning หลังสร้าง Tree เสร็จ)
Post-pruning Approach กำจัด Branches จาก Tree ที่ "โตเต็มที่" (Fully Grown) Tree Node ถูก Pruned โดยการลบ Branches ของมัน อัลกอริทึม Price Complexity Pruning เป็นตัวอย่างของ Post-pruning Approach Node ที่ Pruned กลายเป็น Leaf และติดฉลากด้วย Most Common Class ระหว่าง Branches เดิมของมัน
สำหรับ Non-leaf Node ทุกตัวใน Tree อัลกอริทึมคำนวณ Expected Error Rate ที่อาจเกิด หาก Subtree ที่ Node นั้นถูก Pruned ต่อมา คำนวณ Expected Error Rate หาก Node ไม่ถูก Pruned โดยใช้ Error Rates ของแต่ละ Branch น้ำหนัก (Weighting) ตามขนาด Observations ตามแต่ละ Branch หาก Pruning Node นำไปสู่ Expected Error Rate สูงกว่า Subtree จะถูกเก็บไว้ (Preserved) มิฉะนั้น จะถูก Pruned
หลังสร้างชุด Trees ที่ Pruned เพิ่มขึ้นเรื่อยๆ (Increasingly Pruned Trees) Independent Test Set สามารถประเมิน Efficiency ของแต่ละ Tree Decision Tree ที่ลด Expected Error Cost ต่ำสุด จะถูกเลือก