1 / 69

Data Mining Classification: Basic Concepts, Decision Trees

Data Mining Classification: Basic Concepts, Decision Trees. Introduction to Data Mining เรียบเรียงโดย : นางสาวยุพดี อมรพงศาพันธ์ 48035493 วิทยาการคอมพิวเตอร์ มหาวิทยาบูรพา. A spiral galaxy กาแลกซี่ขดเป็นวง. An elliptical galaxy กาแลกซี่รูปวงรี.

kamuzu
Download Presentation

Data Mining Classification: Basic Concepts, Decision Trees

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Data Mining Classification: Basic Concepts, Decision Trees Introduction to Data Mining เรียบเรียงโดย: นางสาวยุพดี อมรพงศาพันธ์ 48035493 วิทยาการคอมพิวเตอร์ มหาวิทยาบูรพา data mining classification basic concepts decision trees

  2. A spiral galaxy กาแลกซี่ขดเป็นวง An elliptical galaxy กาแลกซี่รูปวงรี ~*~ ภาพนี้เป็นการทำ classification ของ galaxy ~*~ data mining classification basic concepts decision trees

  3. 4 5 6 1 2 3 7 Pruning Algorithm PUBLIC Algorithm K-fold Cross-Validation Classification Definition Building Algorithm Test of Significance Confidence Interval for Accuracy หัวข้อนำเสนอ data mining classification basic concepts decision trees

  4. Classification : Definition • Classificationเป็นแขนงหนึ่งในการทำ Data mining ซึ่งเป็นศาสตร์ที่ใกล้เคียงกับการเรียนรู้ ด้วยเครื่องจักร(Machine Learning)โดยใช้ข้อมูลฝึกฝน (Training set) นำมาให้เครื่องจักรเรียนรู้ และสร้างแบบจำลองเพื่อนำไปใช้ในการทำนายผลข้อมูลโดยส่วนที่ต้องการทำนายจะถูกเรียกว่าClass label or Class • Data Mining เป็นวิธีการนำข้อมูลฝึกฝน (Training Set) มาจำแนกโดยอาศัยคุณลักษณะ (Attribute), ประเภท หรือ คลาส (Class) ของแต่ละข้อมูลนำมาสร้างแบบจำลอง (Model) ด้วยกระบวนการเรียนรู้ด้วยเครื่อง (Machine Learning) Classification คืออะไร Classification เกี่ยวกับ Data mining อย่างไร • จุดประสงค์ของการจัดจำแนกประเภท คือ สามารถนำแบบจำลองที่สร้างขึ้นมาทำนายข้อมูลที่ไม่เคยพบมาก่อน (ข้อมูลในอนาคต) แล้วได้ผลลัพธ์ถูกต้องแม่นยำเป็นที่น่าพอใจ จุดประสงค์การทำClassification คืออะไร data mining classification basic concepts decision trees

  5. Classification Task induction Training Set induction Test Set data mining classification basic concepts decision trees

  6. Decision Tree Induction • Algorithms ที่นำมาใช้ในการสร้างต้นไม้ตัดสินใจ : • Hunt’s Algorithm (เร็ว) • CART • ID3, C4.5 • SLIQ,SPRINT data mining classification basic concepts decision trees

  7. Example of Decision Tree Categorical Categorical Continuous Class Label Splitting Attribute Marital Single, Divorced Married H_Owner No Yes No No Income < 77 >= 77 No Yes Model: Decision Tree Training Data Set data mining classification basic concepts decision trees

  8. Building Algorithm • กำหนดวิธีการแบ่งแยกข้อมูลที่มีอยู่ได้อย่างไร • เราจะระบุ Attribute ให้เป็นกลุ่มใด? • เราจะเลือก Attribute มาทำการ Split ได้อย่างไร? • เราจะหยุดการแบ่งแยกข้อมูลเมื่อไร • เมื่อทุกข้อมูลใน node นั้นเป็น Class เดียวกัน • เมื่อทุกข้อมูลใน node นั้นมีค่าของ Attribute เหมือนกัน • ใช้วิธีหยุดการแตกกิ่งเมื่อความยาวเกินค่าที่กำหนดซึ่งเป็นวิธี Pre-Pruning (PUBLIC) data mining classification basic concepts decision trees

  9. ปัจจัยที่ใช้ในการพิจารณาปัจจัยที่ใช้ในการพิจารณา • Attribute Type • Nominal แบ่งเป็นกลุ่ม • Ordinal แบ่งเป็นกลุ่มโดยมีการเรียงลำดับของกลุ่ม • Continuous เป็นข้อมูลมีความต่อเนื่องกัน • จำนวนของทางที่จะแยก • 2 way split (Binary split) • Multi-way split data mining classification basic concepts decision trees

  10. accept Yes No ตัวอย่างการ split • ข้อมูลชนิด Nominal Attribute (กลุ่ม) • ข้อมูลชนิด Ordinal Attribute (ลำดับ) • ข้อมูลชนิด Continuous Attribute (ต่อเนื่อง) color color Red,Blue Green Red Green blue Add Your Text level level Low,medium high low high medium income income < 50 >= 50 < 10 >= 30 [10, 20) [20, 30) data mining classification basic concepts decision trees

  11. คำศัพท์ Classification • Attribute Type • Categorical ข้อมูลชนิดเป็นกลุ่ม • Continuous หรือ Numeric เป็นข้อมูลมีความต่อเนื่องกัน • หยุดการแบ่งแยกข้อมูลเมื่อ • เมื่อทุกข้อมูลใน node นั้นเป็น Class เดียวกัน • เมื่อทุกข้อมูลใน node นั้นมีค่าของ Attribute เหมือนกัน data mining classification basic concepts decision trees

  12. การเลือก Best Split Input Data : 9 record of class 0, 11 record of class 1 • Node ที่มีความเป็น Homogeneous มากกว่า จะมีคุณสมบัติแยกข้อมูลได้ดีกว่า C0 : 0 C1 : 10 C0 : 4 C1 : 6 C0 : 5 C1 : 5 C0 : 9C1 : 1 Non- Homogeneous ข้อมูลมีลักษณะไม่เหมือนกัน Homogeneous ข้อมูลมีลักษณะเหมือนกัน data mining classification basic concepts decision trees

  13. Measures of node impurity • Gini Index (ค่าที่บ่งบอกว่า attribute สมควรนำมาใช้เป็นคุณลักษณะในการแบ่ง ) • Entropy (การคำนวณหาค่าความยุ่งเหยิงของข้อมูลกลุ่มหนึ่ง ) • Misclassification error (การคำนวณความผิดพลาดที่เกิดกับโนด t) C-1 Gini(t) = 1 -å [p(i|t)]2 i=0 C-1 Entropy(t)= 1 -å [p(i|t)]log2p(i|t)i=0 Classification error(t) = 1 – Max[p(i|t)] i data mining classification basic concepts decision trees

  14. Gini Index • จากสูตร เมื่อนำมาทดสอบกับตัวอย่างต่างๆกัน C-1 Gini(t) = 1 -å [p(i|t)]2 i=0 Gini = 1 – (0/6)2 – (6/6)2 = 0 Gini = 1 – (1/6)2 – (5/6)2 = 0.278 Gini = 1 – (3/6)2 – (3/6)2 = 0.5 data mining classification basic concepts decision trees

  15. Owner yes No C0 : 8 C1 : 2 C0 : 0 C1 : 4 N1 N2 Split based on Gini k • คำนวณค่า split ได้จาก • ตัวอย่างการคำนวณ Ginisplit = 1 -å ni/n Gini(i)i=1 Gini(N1) = 1 – (8/10)2 – (2/10)2 =0.32 Gini(N2) = 1 – (0/4)2 – (4/4)2 =0 Ginisplit = (10/14)(0.32) + (4/14)(0) = 0.2286 data mining classification basic concepts decision trees

  16. Examples for computing Entropy P(C1) = 0/6 = 0 P(C2) = 6/6 = 1 Entropy = – 0 log2 0– 1 log2 1 = – 0 – 0 = 0 P(C1) = 1/6 P(C2) = 5/6 Entropy = – (1/6) log2 (1/6)– (5/6) log2 (5/6) = 0.65 P(C1) = 2/6 P(C2) = 4/6 Entropy = – (2/6) log2 (2/6)– (4/6) log2 (4/6) = 0.92 data mining classification basic concepts decision trees

  17. Information Gain: การคำนวณค่า information gain (ซึ่งประกอบด้วย entropy หลายค่ามารวมกัน) เพื่อมาเปรียบเทียบกันแล้วเลือกค่าที่สูงสุด เพื่อต้องการสร้าง node ใน decision tree โดยเลือก attribute อันใดอันหนึ่ง Splitting Based on INFO... data mining classification basic concepts decision trees

  18. Examples for Computing Error • Measures misclassification error made by a node. • - Maximum (1 - 1/nc) เมื่อ records การกระจายไปทุกๆ classes, แสดงว่าข้อมูลที่น่าสนใจมีน้อยมาก • - Minimum (0.0) เมื่อทุก records อยู่ภายใน class เดียว,แสดงว่าข้อมูลมีความน่าสนใจมาก P(C1) = 0/6 = 0 P(C2) = 6/6 = 1 Error = 1 – max (0, 1) = 1 – 1 = 0 P(C1) = 1/6 P(C2) = 5/6 Error = 1 – max (1/6, 5/6) = 1 – 5/6 = 1/6 P(C1) = 2/6 P(C2) = 4/6 Error = 1 – max (2/6, 4/6) = 1 – 4/6 = 1/3 data mining classification basic concepts decision trees

  19. Comparison among Splitting Criteria For a 2-class problem: data mining classification basic concepts decision trees

  20. Example Building phase Categorical Categorical Continuous Class Label Split Attribute ? การหา Split Attribute จะคำนวณหาค่า Ginisplitทุกๆ Attributes โดย Attribute ที่มีค่าน้อยที่สุด จะเป็น Split Attribute Training Data Set data mining classification basic concepts decision trees

  21. Owner yes No C0 : 3 C1 : 0 C0 : 4 C1 : 3 N1 N2 Example Building phase Categorical Categorical Continuous Class Label Attribute Home Owner Gini(N1) = 1 – (3/3)2 – (0/3)2 = 0 Gini(N2) = 1 – (4/7)2 – (3/7)2 = 0.4898 Ginisplit = (3/10)(0) + (7/10)(0.4898) = 0.3429 Training Data Set data mining classification basic concepts decision trees

  22. Status Status Status Single, Divorced Single, Married Single Married, Divorced Divorced Married Example Building phase Attribute Marital Status Categorical Categorical Continuous Class Label Training Data Set data mining classification basic concepts decision trees

  23. Status Status Status Single, Divorced Single, Married Single Married, Divorced Divorced Married Example Building phase Attribute Marital Status Gini(N1) = 1 – (2/4)2 – (2/4)2 = 0.5 Gini(N2) = 1 – (5/6)2 – (1/6)2 = 0.2778 Ginisplit = (4/10)(0.5) + (6/10)(0.2778) C0 : 2 C1 : 2 C0 : 5 C1 : 1 = 0.3167 Gini(N1) = 1 – (6/8)2 – (2/8)2 = 0.375 Gini(N2) = 1 – (1/2)2 – (1/2)2 = 0.5 Ginisplit = (8/10)(0.375) + (2/10)(0.5) = 0.4000 C0 : 6 C1 : 2 C0 : 1 C1 : 1 Gini(N1) = 1 – (3/6)2 – (3/6)2 = 0.5 Gini(N2) = 1 – (4/4)2 – (0/0)2 = 0 Ginisplit = (6/10)(0.5) + (4/10)(0) <<<<<<Attribute ที่มีค่าน้อยที่สุด = 0.3000 C0 : 3 C1 : 3 C0 : 4 C1 : 0 data mining classification basic concepts decision trees

  24. Sorted Values Split Positions Example Building phase Attribute Annual Income เนื่องจากว่า Attribute Annual Income เป็นแบบ Continuous ต้องทำการ Sort ให้เรียงลำดับกันก่อนกระจาย Split Position บนข้อมูลที่เรียงลำดับแล้ว หลังจากนั้นจึงทำการหาค่า Gini ของแต่ละ Split Position ค่าที่น้อยที่สุดจะนำไปเปรียบเทียบกับ Attribute อื่นๆ data mining classification basic concepts decision trees

  25. Example Building phase Split Attribute Categorical Categorical Continuous Class Label ? Gini(Home Owner) = 0.3429 Gini(Marital Status) = 0.3000 Gini(Annual Income) = 0.3000 หากมี 2 Attribute ที่มีค่าน้อยที่สุดเท่ากัน จะต้องเลือก Attribute ใด Attributeหนึ่งเป็น Split Attribute Training Data Set data mining classification basic concepts decision trees

  26. Status ? ? Single, Divorced Married Example Building phase เลือกให้ Marital Status เป็น Split Attribute data mining classification basic concepts decision trees

  27. Status ? Single, Divorced Married Example Building phase เลือกให้ Marital Status เป็น Split Attribute No เนื่องจากกิ่งทางด้านขวาที่แตกออกมา เป็น Class เดียวกันทั้งหมด จึงเปลี่ยนให้เป็น Leaf node data mining classification basic concepts decision trees

  28. Status ? Single, Divorced Married Example Building phase เลือกให้ Marital Status เป็น Split Attribute No เนื่องจากกิ่งซ้ายยังไม่ใช่ Class เดียวกันทั้งหมด และค่าใน Attribute ไม่เหมือนกันทั้งหมด จึงทำการ Split ต่อ data mining classification basic concepts decision trees

  29. Gini(N1) = 1 – (2/2)2 – (0/0)2 = 0 Gini(N2) = 1 – (3/4)2 – (1/4)2 = 0.3750 Ginisplit = (2/6)(0) + (4/6)(0.3750) = 0.2500 Example Building phase Attribute Home Owner data mining classification basic concepts decision trees

  30. Gini(N1) = 1 – (2/4)2 – (2/4)2 = 0.5 Gini(N2) = 1 – (1/2)2 – (1/2)2 = 0.5 Ginisplit = (4/6)(0.5) + (2/6)(0.5) = 0.5000 Example Building phase Attribute Marital Status data mining classification basic concepts decision trees

  31. Example Building phase AttributeAnnual Income data mining classification basic concepts decision trees

  32. Status ? Single, Divorced Married Example Building phase No 0.2500 Gini(Home Owner) = 0.5000 Gini(Marital Status) = 0.2500 Gini(Annual Income) = เนื่องจากมี 2 Attribute ที่มีค่าน้อยที่สุดเท่ากัน ทำการเลือก Attributeใด Attributeหนึ่งเป็น Split Attribute data mining classification basic concepts decision trees

  33. Status Owner Single, Divorced Married Example Building phase เลือกให้ Home Owner เป็น Split Attribute No N1 Yes No ? ? N2 data mining classification basic concepts decision trees

  34. Status Owner Single, Divorced Married Example Building phase เลือกให้ Home Owner เป็น Split Attribute No N1 Yes No No ? เนื่องจากกิ่งทางด้านซ้ายที่แตกออกมา เป็น Class เดียวกันทั้งหมด จึงเปลี่ยนให้เป็น Leaf node N2 data mining classification basic concepts decision trees

  35. Status Owner Income Single, Divorced Married Yes No No < 77 >= 77 No Yes Example Building phase เลือกให้ Home Owner เป็น Split Attribute No ทำกระบวนการเดิมซ้ำจะได้ Annual Income เป็น Node สุดท้าย มีค่า Split Value 77 ได้เป็นต้นไม้ดังรูป data mining classification basic concepts decision trees

  36. Overfitting Problem (ปัญหาการเข้ากันเกินไป ) • ปัญหาการ Overfitting คือการที่ Model ที่ได้จากการใช้ Training Dataset มีค่าความถูกต้องในการบ่งบอกคลาสเป้าหมายสูง แต่เมื่อนำไปใช้กับข้อมูล Test Data set ได้ค่าความถูกต้องต่ำ • กล่าวอีกนัยหนึ่งคือ ตัวแบบที่ได้เป็นการเรียนรู้ข้อมูลจาก Training Data set ดีมาก แต่ไม่สามารถนำไปใช้กับข้อมูลที่ไม่เคยพบมาก่อนได้ดี • ต้นไม้ที่แสดงลักษณะปัญหา Overfitting มักเป็นต้นไม้ที่มีการแตกกิ่งมากมาย แต่ละกิ่งมีจำนวนข้อมูลอยู่ปริมาณน้อย • วิธีการหลีกเลี่ยงปัญหา Overfitting ในต้นไม้ทำได้ 2 ลักษณะ • ตัดแต่งกิ่งระหว่างสร้าง(Pre-Pruning) หยุดการสร้างเมื่อตัววัดการแตกกิ่งมีค่าต่ำกว่าเกณฑ์ที่กำหนด เช่นข้อมูลในจุดยอดมีน้อยเกินไป • ตัดแต่งกิ่งหลังสร้าง(Post-Pruning) การลดจำนวนกิ่ง กำจัดกิ่งโดยยังคงความถูกต้องของการ Classification ในระดับที่ยอมรับได้ data mining classification basic concepts decision trees

  37. Pruning Algorithm • แก้ปัญหา Overfitting ด้วยวิธี Minimum Desciption Length (MDL) • MDL เป็นการหาต้นไม้ที่ดีที่สุดจากการเข้ารหัส (encode) ของข้อมูล ต้นไม้ที่เข้ารหัสแล้วมีขนาดสั้นที่สุดคือต้นไม้ที่ดีที่สุดนั่นเอง • การเข้ารหัส Structure ของต้นไม้ • โครงสร้างของต้นไม้จะถูกแทนที่ด้วย รหัสในแบบ prefix • Internal node แทนด้วย 1 • Leaf แทนด้วย 0 • ต้นไม้ทางด้านขวาจะถูกเข้ารหัสเป็น 11000 • ทุกๆ node จะใช้ 1 bit data mining classification basic concepts decision trees

  38. å C(s) = nilog (n/ni) i Pruning Algorithm • การเข้ารหัส การเข้ารหัส Split Attribute • ค่าที่ใช้ Spit (Csplit) มีสองส่วน คือ เข้ารหัส Attribute และค่าที่ใช้ในการ split • การเข้ารหัส Attribute ใช้log a bits เมื่อ a คือจำนวนของ Attributes • การเข้ารหัส Spit value แบ่งตามชนิดโดยที่ • Categorical ใช้ log (2v – 1)bitsเมื่อ v คือจำนวนสมาชิกของ Attribute • Numeric ใช้ log (v - 1) bits เมื่อ v คือช่วงค่าที่ใช้แบ่งของ Attribute • (v = max-min) • การเข้ารหัส ข้อมูลและ Class • n คือ จำนวนสมาชิกของทุก class ในทุกๆ nodes รวมกัน • niคือ จำนวนสมาชิกที่เป็น class i ณ โหนดหนึ่งๆ data mining classification basic concepts decision trees

  39. Pruning Algorithm • ข้อผิดพลาดของ MDL Pruning • ในการเข้ารหัสของ Csplit มีโอกาสที่จะเกิด Overfitting และ Overpruning ได้ ในบาง Data set • Numeric Attribute ถ้าข้อมูลมีจำนวนน้อยมาก หรือสูงมากจนเกินไป เช่น 0.123 ถึง -0.123 จะทำให้ค่า Csplit มีค่าน้อยมากๆ หรือ 1,000,000 - 2,000,000 ก็จะทำให้ Csplit มีค่ามากจนเกินไป • Categorical Attribute ถ้าข้อมูลมีจำนวนชนิดกลุ่มมากเกินไป ค่า Csplit จะสูงมากจนเกิดการ Overpruning • ดังนั้นการแทน Csplit ด้วยค่าคงที่ ซึ่งจะทำให้เป็นมาตรฐานสำหรับการ prune สำหรับทุก Data set และช่วยป้องกันการเกิด Overfitting และ Overpruning data mining classification basic concepts decision trees

  40. Pruning Algorithm Procedure computeCost&Prune(Node N): /* S คือ set ของข้อมูลทั้งหมดที่ Node N */ • If N is a leaf return C(S) + 1 /* N1 and N2 are N’s children */ • minCost1 = computeCost&Prune(N1); • minCost2 = computeCost&Prune(N2); • minCostN = min{C(S) + 1, Csplit(N) + 1 + minCost1 + minCost2}; • if minCostN = C(S) + 1 prune child nodes N1 and N2 from tree • return minCostN data mining classification basic concepts decision trees

  41. Status Owner Income Single, Divorced Married Yes No Example Pruning Phase If N is a leaf return C(S) + 1  no minCost1 = computeCost&Prune(N1); If N1 is a leaf return C(S) + 1 no C0 : 3 C1 : 100 • minCost1 = computeCost&Prune(N1); • If N1 is a leaf return C(S) + 1 yes • minCost2 = computeCost&Prune(N2); • If N2 is a leaf return C(S) + 1 no C0 : 100 C1 : 3 < 77 >= 77 • minCost1 = computeCost&Prune(N1); • If N1 is a leaf return C(S) + 1 yes C0 : 5 C1 : 0 C0 : 0 C1 : 2 • minCost2 = computeCost&Prune(N2); • If N2 is a leaf return C(S) + 1 yes data mining classification basic concepts decision trees

  42. Status Owner Income Single, Divorced Married Yes No Example Pruning Phase เนื่องจากเป็นฟังก์ชั่น recursive จะทำงานจากล่างขึ้นบน ดังนั้นจึงเริ่มที่ node Income C0 : 3 C1 : 100 หาค่า minCost ที่ Node Income minCostN =min{C(S) + 1, Csplit(N) + 1 + minCost1 + minCost2}; C0 : 100 C1 : 3 คำนวณหาค่า C(S) + 1 และ Csplit(N) + 1 + minCost1 + minCost2 < 77 >= 77 C0 : 5 C1 : 0 C0 : 0 C1 : 2 data mining classification basic concepts decision trees

  43. å C(s)+1 = nilog (n/ni)+1 i Example Pruning Phase C(S) + 1 = (5log(7/5) + 2log(7/2)) + 1 = (5(0.485) + 2(1.807)) + 1 = 3 + 4 + 1 = 8 Income minCostN = min{C(S) + 1, Csplit(N)+ 1 + minCost1 + minCost2}; = min{8, 10 + 1 + 1 + 1}; = 8 < 77 >= 77 Csplit(N) = log(a) + log(v-1) = log(3) + log((220-70) - 1) = 2 + 8 = 10 C0 : 5 C1 : 0 C0 : 0 C1 : 2 minCost1 = C(N1) + 1 = 5log(5/5) + 0log(5/0) + 1 = 1 minCost2 = C(N2) + 1 = (0log(2/0) + 2log(2/2)) + 1 = 1 data mining classification basic concepts decision trees

  44. Status Income Owner Single, Divorced Married Yes No Example Pruning Phase ทำการ prunechild node ออก เพราะ minCostN= C(S) + 1 C0 : 3 C1 : 100 C0 : 100 C1 : 3 node Income จะถูกเปลี่ยนเป็น leaf โดยมีค่าเป็น Class ที่จำนวนมากที่สุด < 77 >= 77 C0 : 5 C1 : 0 C0 : 0 C1 : 2 data mining classification basic concepts decision trees

  45. Status Owner Single, Divorced Married Yes No Example Pruning Phase ทำการ prunechild node ออก เพราะ minCostN= C(S) + 1 C0 : 3 C1 : 100 C0 : 100 C1 : 3 C0 : 5 C1 : 2 node Income จะถูกเปลี่ยนเป็น leaf โดยมีค่าเป็น Class ที่จำนวนมากที่สุด data mining classification basic concepts decision trees

  46. Status Owner Single, Divorced Married Yes No Example Pruning Phase ทำการ prunechild node ออก เพราะ minCostN= C(S) + 1 C0 : 3 C1 : 100 node Income จะถูกเปลี่ยนเป็น leaf โดยมีค่าเป็น Class ที่จำนวนมากที่สุด C0 : 100 C1 : 3 C0 : 5 C1 : 2 ทำการคำนวณ minCost ที่ Node Owner โดยที่ minCost2 = 10 data mining classification basic concepts decision trees

  47. Status Owner Single, Divorced Married Yes No Example Pruning Phase C(S) + 1 = (105log(110/105) + 5log(110/5)) + 1 = (105(0.067) + 5(4.459) + 1) = 8 + 23 + 1 = 32 Csplit(N) = log(3) + log(22-1) = 2 + 2 = 4 C0 : 3 C1 : 100 minCost1 = 100log(103/100) + 3log(103/3) + 1 = 100(0.0426) + 3(5.1015) + 1 = 5 + 16 + 1 = 22 C0 : 100 C1 : 3 C0 : 5 C1 : 2 = 8 minCost2 • minCostN = min{C(S) + 1,Csplit(N) + 1 + minCost1 + minCost2}; = min{32,4 + 1 + 22 + 8}; = min{32,35}; = 32 data mining classification basic concepts decision trees

  48. Status Owner C0 : 3 C1 : 100 Single, Divorced Married Yes No C0 : 100 C1 : 3 C0 : 5 C1 : 2 Example Pruning Phase ทำการ prunechild node ออก เพราะ minCostN= C(S) + 1 node Income จะถูกเปลี่ยนเป็น leaf โดยมีค่าเป็น Class ที่จำนวนมากที่สุด data mining classification basic concepts decision trees

  49. Status Single, Divorced Married Example Pruning Phase ทำการ prunechild node ออก เพราะ minCostN= C(S) + 1 C0 : 105 C1 : 5 C0 : 3 C1 : 100 node Income จะถูกเปลี่ยนเป็น leaf โดยมีค่าเป็น Class ที่จำนวนมากที่สุด data mining classification basic concepts decision trees

  50. Status Single, Divorced Married C0 : 105 C1 : 5 C0 : 3 C1 : 100 Example Pruning Phase คำนวณค่า mincost ที่จุดยอด C(S) + 1 = 108log(213/108) + 105log(213/105) + 1 = 108(0.98) + 105(1.02) = 106 + 108 = 214 Csplit(N) = log(3) + log(23-1) = 2 + 3 = 5 minCost2 = 3log(103/3) + 100log(103/100) + 1 = 3(5.101) + 100(0. 426) + 1 = 16 + 5 + 1 = 22 minCost1 = 32 • minCostN = min{C(S) + 1 ,CSplit(N)+1 + minCost1 + minCost2}; = min{214, 5+ 1 +32 +22}; =60 • ค่า mincostNไม่เท่ากับ C(S) + 1 ดังนั้นไม่ต้อง prune ที่จุดยอด (60 ไม่เท่ากับ 214) data mining classification basic concepts decision trees

More Related