表8.1给出的是带有标记类的元组的训练集D;
类标号属性 buys_computer有两个不同值:{yes, no}
设 类 C1 → \rightarrow → yes,C2 → \rightarrow → no;
已知:C1包含9个元组,C2包含5个元组;
从属性age计算期望信息需求:
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
信息熵:意思是一个变量的变化情况可能越多,那么它携带的信息量就越大,信息熵值越大,该系统越不稳定,存在的不定因素就越多。
信息熵的增益是指:所有属性值的信息熵和某一个属性值的信息熵的差值,增益值越大,说明其具有更高的决策性,可做为优先节点。
由于age在属性中具有最高的信息增益,所以它被选作分裂属性;
由于age → \rightarrow → middle_aged 元组属于相同的类,所以在该分支的端点创建一个树叶,并用 yes 标记;
最终决策树如下:文章来源:https://www.toymoban.com/news/detail-841335.html
参考:文章来源地址https://www.toymoban.com/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
到了这里,关于信息增益-决策树的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!