37
DATA ANALYTICS Wanida Saetang Ph.D (candidate) King Mongkut's University of Technology North Bangkok

DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree

DATA ANALYTICS

Wanida Saetang Ph.D (candidate)King Mongkut's University of Technology North Bangkok

Page 2: DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree

Agenda

Data Analytics Predictive analytics

Data Mining Techniques Decision Tree K-means

Apply Model & Validation Model

Rapid Miner Studio

Workshop

Page 3: DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree

Data Analytics predictive analytics

Page 4: DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree

The Progression of Analytics

Page 5: DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree

Predictive Analytics

carried out in an attempt to determine the outcome of an event that might occur in the future.

the models used for predictive analytics have implicit dependencies on the conditions under which the past events occurred.

Page 6: DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree

Data Mining Techniques Decision tree

K-Means

Page 7: DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree

CRISP-DM

http://mlwiki.org/index.php/CRISP-DM

Page 8: DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree

ประเภทของขอมล

ประเภทขอมล

(type of data)

เชงปรมาณ(Numerical/

Quantitative Data)

Discreat Data

Continuous Data

เชงคณภาพ(Category/

Qualitative Data)

Nominal Data

Ordinal Data

ขอมลทไดจากการนบ เชน จ านวนลกคา

ชอมลทไดจากการวด เชน น าหนก, สวนสง

ขอมลทแบงออกเปนกลมๆ ไมสามารถน ามาค านวณได เชน เพศ

ขอมลทแบงออกเปนกลมๆ สามารถบอกล าดบของกลมได เชน ระดบการศกษา

Page 10: DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree

ClassificationDecision Tree

Page 11: DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree

Decision Tree

ตนไมตดสนใจ (decision tree) เปนการจ าแนกกลมโดยททราบจ านวนกลมปลายทาง เปาหมายของการจ าแนก คอ ท านายคา หรอตวแปรเปาหมาย (class/label) ตนไมตดสนใจเปนเหมอนกราฟ หรอแผนผง มลกษณะเปนตนไมกลบหว ประกอบดวย Node (โหนด) โดยแตละโหนด แทนตวแปรอนพต (input attribute) ตาง ๆ ในชดขอมล และEdge (เสนเชอม) แทนคาของตวแปร (numerical attributes) โหนดบนสดเรยกวา root node หรอโหนดราก และแตกกงออกมาเปน leaf node หรอโหนดใบ

Page 12: DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree

Decision Tree: Information Gain

ข นตอนการสราง decision tree จะท าการค านวณเลอกแอตทรบวตทมความสมพนธกบคลาสมาใชงาน คา Information Gain สามารถค านวณไดจากสมการ ดานลางน

Information Gain = Entropy(initial) – [P(c1) × Entropy(c1) + P(c2) × Entropy(c2) + …]

โดยท Entropy(c1) = –P(c1) log 2P(c1)

และ P(c1) คอ คาความนาจะเปน (probability) ของ c1

Page 13: DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree

Decision Tree: spam e-mail classification

Page 14: DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree

Decision Tree: Information Gain

ID Type

1 spam

2 spam

5 spam

6 spam

8 spam

3 normal

4 normal

7 normal

9 normal

10 normal

P(spam) = 5/10 = 0.5P(normal) = 5/10 = 0.5Entropy (initial) = - [P(spam) × log2 P(spam) + P(normal) × log2 P(normal)]

Entropy(initial) = - [0.5 x log2 (0.5) + 0.5 x log2 (0.5)]= - [0.5 x (-1) + 0.5 x (-1) ]= 1

Page 15: DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree

Decision Tree: Information Gain

ID Free Type

1 Y spam

5 Y spam

6 Y spam

2 N spam

3 N normal

4 N normal

7 N normal

8 N spam

9 N normal

10 N normal

P(spam) = 3/3 = 1.0P(normal) = 0/3 = 0.0Entropy(Free = Y) = -[1.0 x log2 (1.0) + 0.0 x log2 (0.0)]

= -[1.0 x 0 + 0.0 x 0 ]= 0

P(spam) = 2/7 = 0.29P(normal) = 5/7 = 0.71Entropy(Free = N) = -[0.29 x log2 (0.29) + 0.71 x log2 (0.71)]

= -[0.29 x (-1.79) + 0.71 x (-0.49) ]= 0.87

Information Gain (Free) = Entropy(initial) – [P (Free = Y) × Entropy(Free = Y) + P(Free = N) × Entropy(Free = N) ]= 1 – [0.3 × 0 + 0.7 × 0.87]= 0.39

Page 16: DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree

สรางโมเดล (Classification model)

http://dataminingtrend.com/2014/data-mining-techniques/ensemble-model/

classification model

Page 17: DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree

ClusteringK-means

Page 18: DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree

Clustering การท า Clustering คอ การแบงกลมหรอจดกลมขอมล โดยไมทราบจ านวนกลมปลายทาง

ขอมลทมลกษณะคลาย ๆ กน จะอยกลมเดยวกน ขอมลทมลกษณะทแตกตางกนมาก ๆ จะถกจดใหอยคนละกลมกน โดยแตละกลมจะเรยกวา คลสเตอร (cluster)

คลสเตอร A

คลสเตอร B

คลสเตอร C

Page 19: DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree

Clustering

การจดขอมลใหอยในกลมตาง ๆ จะตองมการวดคาความคลายคลง (similarity) หรอคาระยะหาง (distance) ระหวางขอมลแตละตว (example)

วธการค านวณคาระยะหางทนยมใช เชน ระยะหางยคลเดยน (Euclidean distance)

P1 (x1,y1)

P2 (x2,y2)

𝐶 = 𝑥1 − 𝑥22 + 𝑦1 − 𝑦2

2

Page 20: DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree

Clustering

ในการท า Clustering มพารามเตอรทตองก าหนด คอ จ านวนกลมทตองการแบง หรอจ านวนคลสเตอร แทนดวยตวแปร K

ขนตอนการท างาน

1. เลอกจ านวนของคลสเตอร (K)

2. สมเลอกจดศนยกลาง (centroid) ข นมาตามจ านวนคลสเตอร

3. ก าหนดใหขอมลอยในคลสเตอรทใกลทสด

4. ค านวณหาจดศนยกลางแตละคลสเตอรใหม

5. ท าซ าขอ 3 และ 4 ซ า จนกระทง centroid ไมมการเปลยนแปลง

Page 21: DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree

Apply ModelValidation Model

Page 22: DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree

การประยกตใชโมเดล (Apply model)

http://dataminingtrend.com/2014/data-mining-techniques/ensemble-model/

สรางโมเดล

น าโมเดลไปใชงาน

Page 23: DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree

Validate Model

Self Consistency Test

Split-validation

Cross-validation

Page 24: DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree

http://dataminingtrend.com/2014/data-mining-techniques/cross-validation/

Page 25: DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree

http://dataminingtrend.com/2014/data-mining-techniques/cross-validation/

Page 26: DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree

http://dataminingtrend.com/2014/data-mining-techniques/cross-validation/

Page 27: DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree

http://dataminingtrend.com/2014/data-mining-techniques/cross-validation/

Page 28: DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree

http://dataminingtrend.com/2014/data-mining-techniques/cross-validation/

Page 29: DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree

http://dataminingtrend.com/2014/data-mining-techniques/cross-validation/

Page 30: DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree
Page 31: DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree

Repository

Operators

Process Parameters

Help

Page 32: DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree

Rapid Miner Studio

Input Ports (inp)example set (exa)training set (tra)

Output Ports (res)Output (out)model (mod) example set (exa)

Page 33: DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree

Workshop Decision tree

K-Means

Page 34: DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree

การเตรยมขอมล

Training Data Testing Data Unknown Data

Page 35: DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree

Preprocessing

(cleansing)

สรางโมเดล

Modeling

ประยกตใชโมเดล

Apply model

ทดสอบโมเดล

Validation

วดประสทธภาพ

โมเดล

Performance

Blending Ex. Select attributes (เลอกคอลมน)Filter examples (เลอกแถว)

Cleansing Ex. Replace missing values (เตมขอมลทเปนmissing values ดวยคาอน)

ModelingEx. Decision tree, Random Forest, k-means, Rules Induction, Deep learning

ScoringEx. Apply model

ValidationEx. Performance classification, Cluster Distance Performance

ValidationEx. Cross validation, Split validation

Modeling Process

Page 36: DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree

Workshop 1 Decision Tree

Lab2

Lab1

Lab3

Lab4

Validate Model

Test Model

Apply Model

Decision Tree

Page 37: DATA ANALYTICS164.115.41.179/d756/sites/default/files/Data Analytics.pdf · 2018. 12. 25. · Apriori algorithm Eclat algorithm FP-growth algorithm. Classification Decision Tree

Workshop 2 K-means

• Lab1 K-means • Lab2 Apply Model

• Lab3 Test Model • Lab4 Validate Model