06 classification 2 bayesian and instance based classification

42
สสสสสส สส.สสสสสสสสส สสสสสสสสสสสสสสส ภภภภภภภภภภภภภภภภภภภภภภภภภภภภภภภภภภภภภภภภภภภ สสสสส 6: สสสสสสสสส สสสสสสสสสสสส 2 (Classification 2) 1 Bayesian Classification & Instance- Based Classification

Upload: -

Post on 24-Jan-2015

902 views

Category:

Education


4 download

DESCRIPTION

 

TRANSCRIPT

Page 1: 06 classification 2 bayesian and instance based classification

สอนโดย ดร.หทั�ยร�ตน เกต�มณี�ชั�ยร�ตน ภาควิ�ชัาการจั�ดการเทัคโนโลย�การผล�ตและสารสนเทัศ

บทัทั�! 6: การจั"าแนกประเภทัข้%อม&ล 2 (Classification 2)

1

Bayesian Classification & Instance-Based Classification

Page 2: 06 classification 2 bayesian and instance based classification

2

Bayesian Classification

Page 3: 06 classification 2 bayesian and instance based classification

การจั"าแนกประเภทัโดยใชั%กฎข้องเบย เป็�นการจำาแนกป็ระเภทโดยใช้�หลั�กสถิ�ติ�ในการ

พยากรณ์�ความน!าจำะเป็�นของสมาช้�ก

เร%ยกว!า ทฤษฎี%ของเบย� (Bayesian theorem) เป็�นการเร%ยนร+ �เพ�,มได� : ติ�วอย!างใหม!ท%,ได�มาถิ+กนามาป็ร�บ

เป็ลั%,ยนการแจำกแจำงซึ่/,งม%ผลัติ!อการเพ�,ม / ลัดความน!าจำะเป็�น ทาให�ม%การเร%ยนร+ �ท%,เป็ลั%,ยนไป็ ว�ธี%การน%2ติ�วแบบจำะถิ+กป็ร�บเป็ลั%,ยนไป็ติามติ�วอย!างใหม!ท%,ได�โดยผนวกก�บความร+ �เด�มท%,ม%

การทานายค!าคลัาสเป็3าหมายของติ�วอย!างใช้�ความน!าจำะเป็�นมากท%,ส4ดของท4กสมมติ�ฐาน

3

Page 4: 06 classification 2 bayesian and instance based classification

ทัฤษฎ�ข้องเบย (Bayesian theorem)

ให� D แทนข�อม+ลัท%,นามาใช้�ในการคานวณ์การแจำกแจำงความน!าจำะเป็�น posteriori probability ของสมมติ�ฐาน h ค6อ P(h|D) ติามทฤษฎี%

P(h) ค6อ ความน!าจำะเป็�นก!อนหน�าของสมมติ�ฐาน hP(D) ค6อ ความน!าจำะเป็�นก!อนหน�าของช้4ดข�อม+ลัติ�วอย!าง

DP(h|D) ค6อ ความน!าจำะเป็�นของ h เม6,อร+ � DP(D|h) ค6อ ความน!าจำะเป็�นของ D เม6,อร+ � h

4

Page 5: 06 classification 2 bayesian and instance based classification

ต�วิอย,าง:: การพยากรณี อากาศ การพยากรณ์�อากาศ (Weather forecast)

ความน!าจำะเป็�นท%,เก�ดเฮอร�ร�เคนในช้�คาโก� ค6อ 0.008 ทอมม%ท�กษะในการพยากรณ์�ถิ+กติ�องป็ระมาณ์ 98% ของการ

ทานายท�2งหมด (Predict-hur) แติ!ทอมก9ม%การทานายถิ+กว!าไม!เก�ดเฮอร�ร�เคนถิ+กติ�อง 97% เช้!น

ก�น (Predict-nohur)P(hurricane) = 0.008 P(~hurricane) = 1 – P(hurricane)

= 0.992

P(~h)

P(h)

P(~h) = 1- P(h)

P(h) + P(~h) = 1

5

Page 6: 06 classification 2 bayesian and instance based classification

ต�วิอย,าง:: การพยากรณี อากาศ การพยากรณ์�อากาศ (Weather forecast)

ความน!าจำะเป็�นท%,เก�ดเฮอร�ร�เคนในช้�คาโก� ค6อ 0.008 ทอมม%ท�กษะในการพยากรณ์�ถิ+กติ�องป็ระมาณ์ 98% ของการ

ทานายท�2งหมด (Predict-hur) แติ!ทอมก9ม%การทานายถิ+กว!าไม!เก�ดเฮอร�ร�เคนถิ+กติ�อง 97% เช้!น

ก�น (Predict-nh)P(hurricane) = 0.008

P(predict-hur | hurricane) = 0.98P(predict-nohur | hurricane) = 0.02

P(~hurricane) = 0.992 P(hurricane)

P(predict-h)= 0.98

P(predict-nh)= 0.02

6

Page 7: 06 classification 2 bayesian and instance based classification

ต�วิอย,าง:: การพยากรณี อากาศ การพยากรณ์�อากาศ (Weather forecast)

ความน!าจำะเป็�นท%,เก�ดเฮอร�ร�เคนในช้�คาโก� ค6อ 0.008 ทอมม%ท�กษะในการพยากรณ์�ถิ+กติ�องป็ระมาณ์ 98% ของการ

ทานายท�2งหมด (Predict-hur) แติ!ทอมก9ม%การทานายถิ+กว!าไม!เก�ดเฮอร�ร�เคนถิ+กติ�อง 97% (Predict-nohur)

P(hurricane) = 0.008P(predict-h|hurricane) = 0.98P(predict-nh|hurricane) = 0.02

P(~hurricane) = 0.992P(predict-h|~hurricane) = 0.03P(predict-nh| ~hurricane) = 0.97

P(~hurricane)

P(predict-h)= 0.03

P(predict-nh) = 0.97

7

Page 8: 06 classification 2 bayesian and instance based classification

ต�วิอย,าง:: การพยากรณี อากาศ ถ้%าส�,มวิ�นข้/0นมา จัากทั�กษะทั�!ทัอมทั"านายการเก�ดเฮอร ร�เคน จัะ

เชั2!อเข้าหร2อไม,??

ควิามน,าจัะเป4นทั�!เข้าทั"านายถ้&กต%อง?

ควิามน,าจัะเป4นทั�!เข้าทั"านายผ�ด?

P(p-h|h)P(h)

P(p-h)P(h|p-h) = 0.98*0.008 0.0078==

P(hurricane) = 0.008

P(predict-h|hurricane) = 0.98

P(predict-nh|hurricane) = 0.02

P(~hurricane) = 0.992

P(predict-h|~hurricane) = 0.03P(predict-nh| ~hurricane) = 0.97

P(p-h|~h)P(~h)

P(p-h)P(~h|p-h) =

0.03*0.992 0.0298= =

8

Page 9: 06 classification 2 bayesian and instance based classification

ต�วิอย,าง:: มะเร5ง (Cancer)

คนไข้%คนหน/!งไปตรวิจัหามะเร5ง ผลการตรวิจัเป4นบวิก(+) อยากทัราบวิ,า เราควิรวิ�น�จัฉั�ยโรคคนไข้คนน�0วิ,าเป4นมะเร5งจัร�งหร2อไม,? ควิามเป4นจัร�ง ค2อ

ผลการตรวิจัเม2!อเป4นบวิกจัะให%ควิามถ้&กต%อง 98% กรณี�ทั�!ม�โรคน�0นอย&,จัร�ง

ผลการตรวิจัเม2!อเป4นลบจัะให%ควิามถ้&กต%อง 97% กรณี�ทั�!ไม,ม�โรคน�0น

0.008 ข้องประชัากรทั�0งหมดเป4นโรคมะเร5ง

จัากควิามน,าจัะเป4นข้%างต%น เราจัะทัราบวิ,าควิามน,าจัะเป4นต,อไปน�0

P(cancer) = P(~cancer) = P(+ | cancer) = P(- | cancer) = P(+ |~ cancer) = P(- |~

cancer) =

9

Page 10: 06 classification 2 bayesian and instance based classification

ต�วิอย,าง:: มะเร5ง (Cancer)

เราสามารถิคานวณ์ค!าความน!าจำะเป็�นของสมมติ�ฐานว!าคนไข�เป็�น / ไม!เป็�นโรคมะเร9ง เม6,อทราบผลัติรวจำเป็�นบวก โดยใช้�กฎีของเบย� ด�งน%2

ความน!าจำะเป็�นท%,คนไข�คนน%2จำะเป็�นโรคมะเร9งเม6,อผลัติรวจำเป็�นบวก เท!าก�บ

P(cancer |+) =

ความน!าจำะเป็�นท%,คนไข�คนน%2จำะไม!เป็�นโรคมะเร9งเม6,อผลัติรวจำเป็�นบวก เท!าก�บ

P(~cancer |+) =

P(+|cancer)P(cancer)

=

P(+|~cancer)P(~cancer)=

10

Page 11: 06 classification 2 bayesian and instance based classification

วิ�ธี�การเร�ยนร&%เบย อย,างง,าย (Naïve Bayesian Learning)

ว�ธี%การของ Naïve Bayesian ค6อการใช้�ว�ธี%การของเบย�พร�อมสมมติ�ฐานของการเป็�นอ�สระติ!อก�นของติ�วแป็รอ�สระท4กติ�ว

โดยแติ!ลัะ instance x ม% n แอททร�บ�วติ� หร6อ x= {A1, …, An} แลัะม% Ci เป็�น class label

Naïve Bayes Classifier = Max (P(Ci) P(Aj |Ci) )

P(A1,…, An)C = Max P’(Ci) P’(Aj |Ci) n

i=1

m

j=1

11

Page 12: 06 classification 2 bayesian and instance based classification

ต�วิอย,าง: ผ�วิไหม% (subburn)Sample ID

Hair color

Eye Color Weight Apply lotion

Sun burn

S1 black Dark overweight No -

S2 red Dark normal No +

S3 Blonde light Overweight No +

S4 Red light underweight No +

S5 Black Dark Overweight Yes -

S6 Blonde Dark Overweight No +

S7 Red light underweight Yes -

S8 Black Dark Normal No -

S9 Blonde Dark Normal Yes +

S10 Red light Normal Yes +

S11 Black light Normal Yes +

S12 Blonde light Underweight No +

S13 Red Dark Normal Yes -

S14 black light underweight no +

12

Page 13: 06 classification 2 bayesian and instance based classification

ต�วิอย,าง: ผ�วิไหม% (subburn) Instance x = <hair color= red, eye color =

dark, weight= overweight, apply lotion = no>

เพราะฉะน�2น เม6,อ instance ใหม!เข�ามาถิามว!า ผ�วจำะไหม�หร6อไม!

C1 : sun burn is + :P(+).P(red|+).P(dark|+).P(overweight|+).P(apply lotion|+)

C2 : sun burn is - :P(-).P(red|-).P(dark|-).P(overweight|-).P(apply lotion|-)

01.09

6

9

2

9

3

9

3

14

9

018.05

2

5

2

5

4

5

2

14

5 X belongs to class (“sunburn = -”)

13

Page 14: 06 classification 2 bayesian and instance based classification

ต�วิอย,าง: เล,นเทันน�ส (Play tennis)

NoStrongHighMildRainD14YesWeakNormalHotOvercastD13YesStrongHighMildOvercastD12YesStrongNormalMildSunnyD11YesWeakNormalMildRainD10YesWeakNormalCoolSunnyD9NoWeakHighMildSunnyD8YesStrongNormalCoolOvercastD7NoStrongNormalCoolRainD6YesWeakNormalCoolRainD5YesWeakHighMildRainD4YesWeakHighHotOvercastD3NoStrongHighHotSunnyD2NoWeakHighHotSunnyD1PlayTennisWindHumidit

yTemp.OutlookDay

14

Page 15: 06 classification 2 bayesian and instance based classification

ต�วิอย,าง: เล,นเทันน�ส (Play tennis)

ออกไป็เลั!นเทนน�สได�หร6อไม! New instance x = <Sunny, Cool, High,

Strong>

P(yes)P(sunny|yes)P(cool|yes)P(high|yes)P(strong|yes)P(yes) = 9/14 = 0.64P(sunny|yes) = 2/9 = 0.22P(cool|yes) = 3/9 = 0.33P(high|yes) = 3/9 = 0.33P(strong|yes) = 3/9 = 0.33

= 0.0051

C = Max P’(Ci) P’(Aj |Ci) n

i=1

m

j=1

15

Page 16: 06 classification 2 bayesian and instance based classification

ต�วิอย,าง: เล,นเทันน�ส (Play tennis) ออกไป็เลั!นเทนน�สได�หร6อไม! New instance x = <Sunny, Cool, High,

Strong>

P(no)P(sunny|no)P(cool|no)P(high|no)P(strong|no)P(no) = 5/14 = 0.36P(sunny|no) = 3/5 = 0.6P(cool|no) = 1/5 = 0.2P(high|no) = 4/5 = 0.8P(strong|no) = 3/5 = 0.6= 0.0207

C = Max P’(Ci) P’(Aj |Ci) n

i=1

m

j=1

New instance is “play tennis = no”

16

Page 17: 06 classification 2 bayesian and instance based classification

วิ�ธี�การเร�ยนร&%เบย อย,างง,าย (Naïve Bayesian Learning) ข�อด%

ง!ายติ!อการนาไป็ใช้� เพราะใช้�การคานวณ์ท%,ง!าย ได�ผลัลั�พธี�ท%,สามารถินาไป็ป็ระย4กติ�ใช้�ได�ด%

ข�อเส%ย ใช้�ได�ก�บ attribute ท%,เป็�นอ�สระก�นเท!าน�2น

17

Page 18: 06 classification 2 bayesian and instance based classification

ต�วิจัะแนกประเภทัทั�!ด�ทั�!ส�ดแบบเบย (Bayes Optimal Classifier)

พ�จำารณ์า จำากความน!าจำะเป็�น 3 สมมติ�ฐาน

P(h1|D) = 0.4, P(h2|D) = 0.3, P(h3|D) = 0.3

ถิ�าให� new instance x เข�าไป็ถิาม จำะติอบว!าh1(x) = +, h2(x) = -, h3(x) = -

What’s hMAP(x) ? What's most probable classification of x?

18

Page 19: 06 classification 2 bayesian and instance based classification

Bayes Optimal Classifier

ติ�วอย!าง: P(h1|D) = .4, P(-|h1) = 0, P(+|h2) = 1 P(h2|D) = .3, P(-|h2) = 1, P(+|h3) = 0 P(h3|D) = .3, P(-|h3) = 1, P(+|h3) = 0,

เพราะฉะน�2น hi H P(+|hi) P(hi|D) = (1*0.4)+(0*0.3)+(0*0.3) =

0.4 hi H P( -|hi) P(hi|D) = (0*0.4)+(1*0.3)+(1*0.3)

=0.6 is MAP class

h1 h2

h3

19

Page 20: 06 classification 2 bayesian and instance based classification

20

Instance-Based Classification

Page 21: 06 classification 2 bayesian and instance based classification

Lazy & Eager Learning

Lazy learning (e.g., Instance-based learning): เป็�นการเร%ยนร+ �อย!างง!ายโดยใช้�การสารวจำช้4ดข�อม+ลัสอนคร!าวๆ แลัะรอจำนกระท�,งถิ/งเวลัาทดสอบจำ/งจำาแนกป็ระเภทข�อม+ลั

Eager learning (e.g. Decision trees): ใช้�เวลัาในการเร%ยนร+ �จำากช้4ดข�อม+ลัสอนก!อนเป็�นเวลัานาน แติ!หลั�งจำากท%,ทาการเร%ยนร+ �เร%ยบร�อยแลั�ว สามารถินาช้4ดทดสอบจำาแนกป็ระเภทได�เวลัาอ�นรวดเร9ว

Its very similar to aDesktop!!

Lazy

Desktop

Eager Survey before

21

Page 22: 06 classification 2 bayesian and instance based classification

Lazy Learner: Instance-Based Methods

เทคน�คท%,ใช้�สาหร�บ Instance-Based Methods ม%ช้6,อว!า k-nearest neighbor

การหาป็ระเภทของข�อม+ลัโดยให�การว�ดการระยะห!างท%,เร%ยกว!า Euclidean Distance

Locally weighted regressionหาสมการเช้�งเส�นติ�ดเพ6,อว�ดจำ4ดใกลั�เค%ยง

22

Page 23: 06 classification 2 bayesian and instance based classification

ข้�0นตอนวิ�ธี�ส"าหร�บ k-Nearest Neighbor (k-NN)

Key idea: ม%ข�อม+ลัช้4ดการสอน (Training data)ให�เข%ยนอย+!ในร+ป็ <xi, f(xi)> เช้!น

Humidity temperature Run

30 25 +

48 40 -

80 64 -

28 30 +

50 60 -

x1 x2

f(x)

<x1, x2, f(x)> ต�วิอย,างเชั,น <30, 25, +>

23

Page 24: 06 classification 2 bayesian and instance based classification

ข้�0นตอนวิ�ธี�ส"าหร�บ k-Nearest Neighbor (k-NN)

Discrete-valued หมายถิ/ง ค!าป็3ายบอกฉลัากเป็�นท%,แบ!งป็ระเภทช้�ดเจำน เช้!น ว�,ง หร6อ ไม!ว�,ง ใช้! หร6อ ไม!ใช้! เป็�นติ�น ด�งน�2นหาช้4ด xq, ท%,ใกลั�เค%ยงท%,ส4ดสาหร�บช้4ดข�อม+ลัสอนมาเป็�นติ�ว

ป็ระมาณ์ค!าสาหร�บ xn

Real-valued หมายถิ/ง ค!าป็3ายบอกฉลัากเป็�นติ�วเลัขทศน�ยม เช้!น การพยากรณ์�ป็ร�มาณ์น2าฝน อ4ณ์หภ+ม� เป็�นติ�น

24

Page 25: 06 classification 2 bayesian and instance based classification

ต�วิอย,าง

• ในการติ�ดส�นผลัไม�ท%,ไม!เคยเห9นน�,นค6อ แอป็เป็=2 ลั น�,นค6อเลั6อกพ�จำารณ์าภาพผลัไม�จำานวน K ท%,ใกลั�เค%ยงมากท%,ส4ด ด�งน�2น การจำาแนกป็ระเภทผลัไม�ท%,ไม!ทราบจำะใช้�จำานวนผลัโวติของผลัไม�แติ!ลัะป็ระเภทว!าค6อ แอป็เป็=2 ลั25

Page 26: 06 classification 2 bayesian and instance based classification

ต�วิอย,าง

•ถิ�า k=5, น�,นหมายถิ/ง เลั6อกภาพผลัไม� 5 ภาพท%,ใกลั�เค%ยงมากท%,ส4ด เพ6,อบ!งบอกป็ระเภทของติ�นไม�ท%,ติ�องการแบ!งกลั4!ม•ด�งน�2นจำากภาพจำะเห9นได�ว!า ผลัไม�ท�2ง 5 ภาพส!วนใหญ่!เป็�นภาพของ แอป็เป็=2 ลั ด�งน�2นจำ/งติอบผลัไม�น%2ว!า เป็�นแอบเป็=2 ลั

26

Page 27: 06 classification 2 bayesian and instance based classification

Nearest Neighbor Example: Run Outside (+) or Inside (-)

Humidity

Temperature

0

100

0 100

+

+

+

+

--

-

-

-

-

-

+

+

•Noisy data•Not linearly separable

Decision tree boundary (not very good...)

?

?

??

-

-

?

?

?

27

Page 28: 06 classification 2 bayesian and instance based classification

Voronoi Diagram

.

_+

_ xq

+

_ _+

_

_

+

.

..

. .

28

Page 29: 06 classification 2 bayesian and instance based classification

ต�วิอย,าง: K-Nearest Neighbor ก�บ Voronoi

(Discrete-valued)k=11-NN classifies xq as +k=55-NN classifies xq as −

(real-valued target function)

29

Page 30: 06 classification 2 bayesian and instance based classification

เม2!อไหร,ถ้/งจัะใชั% k-Nearest Neighbor

เม6,อช้4ดข�อม+ลัสามารถิแป็ลังให�อย+!ระนาบของม�ติ�ได� ℜn

ม% Attribute น�อยว!า 20 ติ�ว ม%ข�อม+ลัช้4ดการสอน (Training data) เป็�นจำานวนมาก ข�อด%

สอน (training) เร9วมาก สามารถิเร%ยนร+ �ก�บฟั@งก�ช้�นท%,ซึ่�บซึ่�อนได� ไม!ส+ญ่เส%ยข�อม+ลัอ6,น

ข�อเส%ย ช้�าเวลัาจำาแนกป็ระเภทข�อม+ลั จำะโง!เม6,อม%การค�ด attribute ท%,ไม!เก%,ยวข�อง

30

Page 31: 06 classification 2 bayesian and instance based classification

การก"าหนดต�วิแปร K ไม!ควรเลั6อก K เลั9กเก�นไป็ เพราะจำะทาให�เบ%,ยงเบนส+ง ไม!ควรเลั6อก K ใหญ่!เก�นไป็ เพราะจำะทาให�ข�อม+ลัเก�นความลัาเอ%ยง เพราะฉะน�2นการเลั6อกค!า K ข/2นอย+!ก�บข�อม+ลั ติ�องม%การป็ร�บค!าการ

ป็ระเม�น เช้!น Cross-validation

ระยะทางท%,ใช้�ว�ด ค6อ ถิ�า x ป็ระกอบไป็ด�วย Attribute <a1(x), a2(x), …, an(x)> ด�ง

น�2น ar(x) ด�งกลั!าวจำ/งแทนด�วยค!าในด�วย xค!าระยะทางท%,ใช้� เร%ยกว!า Euclidean Distance

n

rjrirji xaxaxxd

1

2))()((),(

31

Page 32: 06 classification 2 bayesian and instance based classification

Euclidean DistanceHumidity temperature Run

30 25 +

48 40 -

80 64 -

28 30 +

50 60 -

x = <humidity, temperature>New instance xq = <40, 30, run=?? > We can

run inside(+) or outside (-)

n

rjrirji xaxaxxd

1

2))()((),(

18.11)2530()3040(),( 221 xxd q

80.12)4030()4840(),( 222 xxd q

5.52)6430()8040(),( 223 xxd q

1-NN (x1) Answer run inside (+)

2-NN (x1,x4) Answer run inside (+)

3-NN (x1,x2,x4) Answer run inside (+)

4-NN (x1,x2,x4,x5) Answer run inside (+)

5-NN Answer run inside (-)

12)3030()2840(),( 224 xxd q

62.31)6030()5040(),( 225 xxd q

Discrete values

32

Page 33: 06 classification 2 bayesian and instance based classification

Euclidean DistanceHumidity temperature Rainfall

30 25 5.1

48 40 15.5

80 64 20.2

28 30 3.2

50 60 12.0

x = <humidity, temperature>New instance xq = <40, 30, Rainfall =??

>

n

rjrirji xaxaxxd

1

2))()((),(

18.11)2530()3040(),( 221 xxd q

80.12)4030()4840(),( 222 xxd q

5.52)6430()8040(),( 223 xxd q

1-NN (x1)Rainfall = 5.1

2-NN (x1,x4)Rainfall = (5.1+3.2)/2 = 4.15

3-NN (x1,x2,x4)Rainfall = (5.1+15.5+3.2)/3= 7.9

4-NN (x1,x2,x4,x5)Rainfall = (5.1+15.5+3.2+12.0)/4 = 8.95

5-NN (x1,x2,x3, x4,x5)Rainfall = (5.1+15.5+3.2+20.2+12.0)/5 = 11.2

12)3030()2840(),( 224 xxd q

62.31)6030()5040(),( 225 xxd q

Real values

33

Page 34: 06 classification 2 bayesian and instance based classification

Distance-Weighted kNN (แบบละเอ�ยด)

ถิ�าติ�องการให�ม%การป็ระมาณ์ค!าได�รายลัะเอ%ยดมากข/2น ด�งน�2นจำ/งติ�องคานวณ์ค!าน2าหน�กสาหร�บการแบ!งป็ระเภท ด�งติ!อไป็น%2

34

Page 35: 06 classification 2 bayesian and instance based classification

ต�วิอย,าง: Humidity temperature Run

30 25 1

48 40 0

80 64 0

28 30 1

50 60 0

x = <humidity, temperature>New instance xq = <40, 30> We can run inside(+) or outside (-) , by k=3 1 1 2 2 3 3

1 2 3

( ) ( ) ( )ˆ ( )qw f x w f x w f x

f xw w w

168.0)

121

()8.12

1()

18.111

(

)1(*)12

1()0(*)

8.121

()1(*)18.111

()(

222

222

qxf

35

Page 36: 06 classification 2 bayesian and instance based classification

Locally Weighted Regression

แนวความค�ด: มาจำาก k-NN ท%,ค�นหาการป็ระมาณ์ค!าโดยใช้�พ62นท%,ใกลั�

เค%ยงในการป็ระมาณ์ ทาไมติ�องอย+!ในร+ป็การใช้�สมการเช้�งเส�น เพราะ

ลัดค!า error ในการกาหนดค!า K ลัดค!า error สาหร�บการให�ค!าน2าหน�กสาหร�บการหา

distance

36

Page 37: 06 classification 2 bayesian and instance based classification

Locally Weighted Regression

Local linear function: f^(x)=β0+ β1a1(x)+…+ βnan(x)

Error criterions:

qxofnbrsnearestkx

q xfxfxE____

21 ))()((

2

1)(

)),(())()((2

1)( 2

2 xxdKxfxfxE qDx

q

37

Page 38: 06 classification 2 bayesian and instance based classification

Locally Weighted Regression

f1 (simple regression)

ข�อม+ลัสอน (Training data)

ใช้�ทานายโดยใช้�สมการเช้�งเส�นแบบแบ!งส!วน ( Predicted value using locally weighted (piece-wise) regression)

ใช้�ทานายโดยใช้�สมการเช้�งเส�นอย!างง!าย (Predicted value using simple regression)

Locally-weighted regression (f2)

Locally-weighted regression (f4)

38

Page 39: 06 classification 2 bayesian and instance based classification

39

HW#6 What is Bayesian Classification? What is Naïve Bayesian Learning? What is Instance-Based Classification? Please explain Lazy & Eager Learning?

Page 40: 06 classification 2 bayesian and instance based classification

40

HW#6 Predicting a class label using naïve Bayesian

classification. We wish to predict the class label of a tuple using naïve Bayesian classification, given the training data as in the table below. The data tuples are described by the attributes age, income, student and credit_rating. The class label attribute, buy_computer, has two distinct values (namely, {yes, no}). Let C1 correspond to the class buys_computer = yes and C2 correspond to buys_computer = no. The tuple we wish to classify is

X = (age=youth, income=medium, student=yes, credit_rating = fair)

We need to maximize P(X|Ci)P(Ci), for i=1,2. P(Ci), the probability of each class, can be computed based on the training tuples.

Page 41: 06 classification 2 bayesian and instance based classification

41

Page 42: 06 classification 2 bayesian and instance based classification

42

LAB 6 Use weka program to construct a baysian

network classification and instance base classification from the given file.

Labor.arff