决策树。weka。信息增益

首先举出打网球的例子。

 

Day

Outlook

Temperature

Humidity

Wind

Play Tennis

1

sunny

hot

high

weak

no

2

sunny

hot

high

strong

no

3

overcast

hot

high

weak

yes

4

rain

mild

high

weak

yes

5

rain

cool

normal

weak

yes

6

rain

cool

normal

strong

no

7

overcast

cool

normal

strong

yes

8

sunny

mild

high

weak

no

9

sunny

cool

normal

weak

yes

10

rain

mild

normal

weak

yes

11

sunny

mild

normal

strong

yes

12

overcast

mild

high

strong

yes

13

overcast

hot

normal

weak

yes

14

rain

mild

high

strong

no

 

         数据集中包含14个样本,其中9个正样本(yes),5个负样本(no)。则这些元组的期望信息(即熵)为:

 

Info(D) = - 9/14 * log2(9/14) - 5/14 * log2(5/14) = 0.940

 

         现在观察每个属性的期望信息需求。在属性Outlook中,对于sunny,正样本数为2,负样本数为3;对于overcast,正样本数为4,负样本数为0;对与rain,正样本数为3,负样本数为2

按照Outlook划分样例得到的期望信息为:

 

5/14 * ( - 2/5log22/5 – 3/5log23/5) + 4/15 * ( - 4/4log24/4) + 5/14 * ( - 3/5log23/5 – 2/5log22/5)=0.694

 

         即其信息增益为:

 

Gain(outlook) = 0.940 – 0.694 = 0.246

 

         Gain(Temperature) = 0.029

         Gain(Humidity) = 0.151

         Gain(Wind) = 0.048

 



 

 

 

         继续信息增益的计算,最终得到如下的决策树:

 

 

        

 

sunny,mild,normal,FALSE作为测试集,使用决策树,得出其结论为yes

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值