data mining - 实用机器学习工具与技术 读书笔记 ( 五)

关于 Decision Tree 的构建,有两种方法 , ID3 C4.5 .

ID3 的基本概念,可以从 wikipedia 上得到一个大概的了解:
http://en.wikipedia.org/wiki/ID3_algorithm

ID3 C4.5 的老祖宗,有三种实现方法:
1 ) 计算每一个 Attribute 在 data set S 中的 Entropy, 按照 Entropy 最小的来拆分。 因为 Entropy 最小的 Attribute 带来的信息量最少,可以最精确的定性。
2) 如果按照 Entropy 来拆分,到最后都没有唯一确定性的 Attribute 值来定性,那么就以这最后一层的最常见的 Attribute 值来定性
3) 如果有一个 Attribute ,在它下面有一个值,sample 中没有对应的可以拆分的 Attribute, 那么就以这个 parent Attribute 值最为最后的定性值。比如 age < 20, age[20,100) , age > 100, 假如 age > 100 底下没有对应的 sample data. 那么就只能以 age >100 来定性了。

所以,显然有两个公式在计算 ID3 时是必须要引用到的。
1) 求 Entropy :

H(S)=iXp(xi)log2(p(xi))

2) 求 IG(A,S), information gain, 在 S 中,以 A Node 下得到多少信息含量
IG(A,S)=H(S)tTp(t)H(t)

在这里, 假设:
S: 是一整个事件发生的集合
X:表示其中一个 Attribute
xi: 表示 X 中一个值
p(xi): 表示 xi 在 S 中所占的比例
T: 表示在将 A 分拆之后,剩下的集合

所以 IG(A,S) 越大,表示定性结果越准确,H(S) 越小,表示噪点小,适合选择作为分拆的点。

关于 C4.5 , 是建立在几个基础假设之上的:
http://en.wikipedia.org/wiki/C4.5_algorithm
C4.5 builds decision trees from a set of training data in the same way as ID3, using the concept of information entropy. The training data is a set S = {s_1, s_2, …} of already classified samples. Each sample s_i consists of a p-dimensional vector (x_{1,i}, x_{2,i}, …,x_{p,i}) , where the x_j represent attributes or features of the sample, as well as the class in which s_i falls.

假设 1 - 在开始构建 Decision Tree 之前,都已经将所有的事件分成各个小类了

At each node of the tree, C4.5 chooses the attribute of the data that most effectively splits its set of samples into subsets enriched in one class or the other. The splitting criterion is the normalized information gain (difference in entropy). The attribute with the highest normalized information gain is chosen to make the decision. The C4.5 algorithm then recurs on the smaller sublists.

假设 2 - 使用 information gain 来做拆分依据

This algorithm has a few base cases.

All the samples in the list belong to the same class. When this happens, it simply creates a leaf node for the decision tree saying to choose that class.
- 假如所有的 sample 数据都归属于同一个 class 了,就可以创建页级节点。
None of the features provide any information gain. In this case, C4.5 creates a decision node higher up the tree using the expected value of the class.(这里不知道)
Instance of previously-unseen class encountered. Again, C4.5 creates a decision node higher up the tree using the expected value.(这里不知道)

Pseudocode[edit]
In pseudocode, the general algorithm for building decision trees is:[2]

  1. Check for base cases
  2. For each attribute a
    2.1 Find the normalized information gain ratio from splitting on a
  3. Let a_best be the attribute with the highest normalized information gain
  4. Create a decision node that splits on a_best
  5. Recur on the sublists obtained by splitting on a_best, and add those nodes as children of node

有关 ID3 , C4.5 的异同点,有时间再回过头来研究。这一篇未完待续。。。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

dbLenis

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值