表8.1給出的是帶有標(biāo)記類的元組的訓(xùn)練集D;
類標(biāo)號屬性 buys_computer有兩個(gè)不同值:{yes, no}
設(shè) 類 C1 → \rightarrow → yes,C2 → \rightarrow → no;
已知:C1包含9個(gè)元組,C2包含5個(gè)元組;
從屬性age計(jì)算期望信息需求:
age:{‘youth’, ‘middle_aged’, ‘senior’}
youth | middle_aged | senior | |
---|---|---|---|
yes | 2 | 4 | 3 |
no | 3 | 0 | 2 |
對于
y
o
u
t
h
youth
youth 來說:
D
j
D_{j}
Dj? =
2
+
3
=
5
2+3=5
2+3=5
I
n
f
o
Info
Info(
D
j
D_{j}
Dj?) = -
2
/
5
2/5
2/5 *
log
?
2
\log_{2}
log2?(
2
/
5
2/5
2/5) -
3
/
5
3/5
3/5 *
log
?
2
\log_{2}
log2?(
3
/
5
3/5
3/5)
即,
即,按年齡劃分的信息增益:
G
a
i
n
(
a
g
e
)
=
I
n
f
o
(
D
)
Gain(age) = Info(D)
Gain(age)=Info(D) -
I
n
f
o
a
g
e
(
D
)
Info_{age}(D)
Infoage?(D) = 0.94-0.694 = 0.246
同理,
G
a
i
n
(
i
n
c
o
m
e
)
=
0.029
Gain(income) = 0.029
Gain(income)=0.029,
G
a
i
n
(
s
t
u
d
e
n
t
)
=
0.151
Gain(student) = 0.151
Gain(student)=0.151,
G
a
i
n
(
c
r
e
d
i
t
Gain(credit
Gain(credit_
r
a
t
i
n
g
)
=
0.048
rating) = 0.048
rating)=0.048
信息熵:意思是一個(gè)變量的變化情況可能越多,那么它攜帶的信息量就越大,信息熵值越大,該系統(tǒng)越不穩(wěn)定,存在的不定因素就越多。
信息熵的增益是指:所有屬性值的信息熵和某一個(gè)屬性值的信息熵的差值,增益值越大,說明其具有更高的決策性,可做為優(yōu)先節(jié)點(diǎn)。
由于age在屬性中具有最高的信息增益,所以它被選作分裂屬性;
由于age → \rightarrow → middle_aged 元組屬于相同的類,所以在該分支的端點(diǎn)創(chuàng)建一個(gè)樹葉,并用 yes 標(biāo)記;
最終決策樹如下:文章來源:http://www.zghlxwxcb.cn/news/detail-841335.html
參考:文章來源地址http://www.zghlxwxcb.cn/news/detail-841335.html
- https://blog.csdn.net/Time_Memory_cici/article/details/132915003
- https://blog.csdn.net/m0_50989510/article/details/122395804
- https://blog.csdn.net/weixin_44606139/article/details/127049701
到了這里,關(guān)于信息增益-決策樹的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!