大家好,欢迎来到IT知识分享网。
数据分类算法中,我们遵循“简单高效”,而最简单高效的算法就是1R
什么是1R
1R 就是 1-rule,称为1 规则,也就是产生一层的决策树,用一个规则集的形式,只在某个特定的属性上进行测试。1R是一个简单廉价的方法,但却常常能得到令人吃惊的准确率。
1R 算法
1R是一个非常简单的方法,就是对每一个属性逐个测试并且从中选择一个准确率最高的属性作为决策属性。大致的流程为:
对所有的属性进行遍历 对该属性,按照如下方式产生一条规则 计算每个类别出现的次数 找出最频繁的类别 产生一条规则,将该类别分配给该属性值 计算规则产生的误差 选择误差最小的规则
举例说明
有一组数据
NO. | outlook | temperature | humidity | windy | play |
1 | sunny | hot | high | false | no |
2 | sunny | hot | high | true | no |
3 | overcaset | hot | high | false | yes |
4 | rainy | mild | high | false | yes |
5 | rainy | cool | normal | false | yes |
6 | rainy | cool | normal | true | no |
7 | overcaset | cool | normal | true | yes |
8 | sunny | mild | high | false | no |
9 | sunny | cool | normal | false | yes |
10 | rainy | mild | normal | false | yes |
11 | sunny | mild | normal | true | yes |
12 | overcaset | mild | high | true | yes |
13 | overcaset | hot | normal | false | yes |
14 | rainy | mild | high | true | no |
根据1R算法则是要对每一个属性进行分析,并产生一条规则,且需要计算误差
对于属性outlook:
sunny总共有5天,其中3天no,两天yes,则sunny应该判定为no。
overcaset 判定为yes
rainy 判定为yes
错误率为4/14
对于属性temperature:
hot yes和no相同,随机为no
mild 为yes
cool 为yes
错误率为5/14
对于属性humidity
high 为no
normal 为yes
错误率为4/14
对于属性windy
false 为 yes
true 随机为no
错误率为5/14
四个属性分析后,outlook和humidity中任意选一个。从得出的结论可以看出这个游戏只有在雨天才能进行,晴天好像并不适合。从而得知,也许这是一项室内活动。
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://haidsoft.com/155895.html