4. ทฤษฎีของเบย์ (Bayesian theorem)
ให้ D แทนข้อมูลที่นามาใช้ในการคานวณการแจกแจงความน่าจะเป็น
posteriori probability ของสมมติฐาน h คือ P(h|D) ตามทฤษฎี
P(h) คือ ความน่าจะเป็นก่อนหน้าของสมมติฐาน h
P(D) คือ ความน่าจะเป็นก่อนหน้าของชุดข้อมูลตัวอย่าง D
P(h|D) คือ ความน่าจะเป็นของ h เมื่อรู้ D
P(D|h) คือ ความน่าจะเป็นของ D เมื่อรู้ h
4
11. วิธีการเรียนรู้เบย์อย่างง่าย (Naïve Bayesian Learning)
วิธีการของ Naïve Bayesian คือการใช้วิธีการของเบย์พร้อมสมมติฐานของการ
เป็นอิสระต่อกันของตัวแปรอิสระทุกตัว
โดยแต่ละ instance x มี n แอททริบิวต์ หรือ 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
12. ตัวอย่าง: ผิวไหม้ (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
13. ตัวอย่าง: ผิวไหม้ (subburn)
Instance x = <hair color=red, eye color = dark, weight= overweight, apply lotion = no>
เพราะฉะนั้น เมื่อ instance ใหม่เข้ามาถามว่าผิวจะไหม้หรือไม่
C1 : sun burn is + :
P(+).P(red|+).P(dark|+).P(overweight|+).P(applylotion|+)
C2 : sun burn is - :
P(-).P(red|-).P(dark|-).P(overweight|-).P(applylotion|-)
01.0
9
6
9
2
9
3
9
3
14
9
018.0
5
2
5
2
5
4
5
2
14
5
X belongs to class (“sunburn = -”)
13
35. ตัวอย่าง:
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
( ) ( ) ( )ˆ( )q
w f x w f x w f x
f x
w w w
168.0
)
12
1
()
8.12
1
()
18.11
1
(
)1(*)
12
1
()0(*)
8.12
1
()1(*)
18.11
1
(
)(
222
222
qxf
35
38. Locally Weighted Regression
f1 (simple regression)
ข้อมูลสอน (Trainingdata)
ใช้ทานายโดยใช้สมการเชิงเส้นแบบแบ่งส่วน( Predictedvalue using locally weighted (piece-wise)regression)
ใช้ทานายโดยใช้สมการเชิงเส้นอย่างง่าย(Predictedvalue using simple regression)
Locally-weighted regression (f2)
Locally-weighted regression (f4)
38
39. HW#6
39
What is Bayesian Classification?
What is Naïve Bayesian Learning?
What is Instance-Based Classification?
Please explain Lazy & Eager Learning?
40. HW#6
40
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.