id3算法

ID3算法 前言 阅读详情

From:http://www.cise.ufl.edu/~ddd/cap6635/Fall-97/Short-papers/2.htm 

The ID3 Algorithm

 


Abstract

This paper details the ID3 classification algorithm. Very simply, ID3 builds a decision tree from a fixed set of examples. The resulting tree is used to classify future samples. The example has several attributes and belongs to a class (like yes or no). The leaf nodes of the decision tree contain the class name whereas a non-leaf node is a decision node. The decision node is an attribute test with each branch (to another decision tree) being a possible value of the attribute. ID3 uses information gain to help it decide which attribute goes into a decision node. The advantage of learning a decision tree is that a program, rather than a knowledge engineer, elicits knowledge from an expert.

Introduction

J. Ross Quinlan originally developed ID3 at the University of Sydney. He first presented ID3 in 1975 in a book, Machine Learning, vol. 1, no. 1. ID3 is based off the Concept Learning System (CLS) algorithm. The basic CLS algorithm over a set of training instances C:

Step 1: If all instances in C are positive, then create YES node and halt.

If all instances in C are negative, create a NO node and halt.

Otherwise select a feature, F with values v1, ..., vn and create a decision node.

Step 2: Partition the training instances in C into subsets C1, C2, ..., Cn according to the values of V.

Step 3: apply the algorithm recursively to each of the sets Ci.

Note, the trainer (the expert) decides which feature to select.

ID3 improves on CLS by adding a feature selection heuristic. ID3 searches through the attributes of the training instances and extracts the attribute that best separates the given examples. If the attribute perfectly classifies the training sets then ID3 stops; otherwise it recursively operates on the n (where n = number of possible values of an attribute) partitioned subsets to get their "best" attribute. The algorithm uses a greedy search, that is, it picks the best attribute and never looks back to reconsider earlier choices.

Discussion

ID3 is a nonincremental algorithm, meaning it derives its classes from a fixed set of training instances. An incremental algorithm revises the current concept definition, if necessary, with a new sample. The classes created by ID3 are inductive, that is, given a small set of training instances, the specific classes created by ID3 are expected to work for all future instances. The distribution of the unknowns must be the same as the test cases. Induction classes cannot be proven to work in every case since they may classify an infinite number of instances. Note that ID3 (or any inductive algorithm) may misclassify data.

Data Description

 

The sample data used by ID3 has certain requirements, which are:

  • Attribute-value description - the same attributes must describe each example and have a fixed number of values.
  • Predefined classes - an example's attributes must already be defined, that is, they are not learned by ID3.
  • Discrete classes - classes must be sharply delineated. Continuous classes broken up into vague categories such as a metal being "hard, quite hard, flexible, soft, quite soft" are suspect.
  • Sufficient examples - since inductive generalization is used (i.e. not provable) there must be enough test cases to distinguish valid patterns from chance occurrences.
Attribute Selection

 

How does ID3 decide which attribute is the best? A statistical property, called information gain, is used. Gain measures how well a given attribute separates training examples into targeted classes. The one with the highest information (information being the most useful for classification) is selected. In order to define gain, we first borrow an idea from information theory called entropy. Entropy measures the amount of information in an attribute.

Given a collection S of c outcomes

 

Entropy(S) = S -p(I) log2 p(I)

 

where p(I) is the proportion of S belonging to class I. S is over c. Log2 is log base 2.

Note that S is not an attribute but the entire sample set.

Example 1

 

If S is a collection of 14 examples with 9 YES and 5 NO examples then

 

Entropy(S) = - (9/14) Log2 (9/14) - (5/14) Log2 (5/14) = 0.940

 

Notice entropy is 0 if all members of S belong to the same class (the data is perfectly classified). The range of entropy is 0 ("perfectly classified") to 1 ("totally random").

Gain(S, A) is information gain of example set S on attribute A is defined as

 

Gain(S, A) = Entropy(S) - S ((|S v| / |S|) * Entropy(S v))

 

Where:

S is each value v of all possible values of attribute A

Sv = subset of S for which attribute A has value v

|Sv| = number of elements in Sv

|S| = number of elements in S

Example 2

 

Suppose S is a set of 14 examples in which one of the attributes is wind speed. The values of Wind can be Weak or Strong. The classification of these 14 examples are 9 YES and 5 NO. For attribute Wind, suppose there are 8 occurrences of Wind = Weak and 6 occurrences of Wind = Strong. For Wind = Weak, 6 of the examples are YES and 2 are NO. For Wind = Strong, 3 are YES and 3 are NO. Therefore

 

Gain(S,Wind)=Entropy(S)-(8/14)*Entropy(Sweak)-(6/14)*Entropy(Sstrong)

 

= 0.940 - (8/14)*0.811 - (6/14)*1.00

= 0.048

Entropy(Sweak) = - (6/8)*log2(6/8) - (2/8)*log2(2/8) = 0.811

Entropy(Sstrong) = - (3/6)*log2(3/6) - (3/6)*log2(3/6) = 1.00

For each attribute, the gain is calculated and the highest gain is used in the decision node.

Example of ID3

 

Suppose we want ID3 to decide whether the weather is amenable to playing baseball. Over the course of 2 weeks, data is collected to help ID3 build a decision tree (see table 1).

The target classification is "should we play baseball?" which can be yes or no.

The weather attributes are outlook, temperature, humidity, and wind speed. They can have the following values:

outlook = { sunny, overcast, rain }

temperature = {hot, mild, cool }

humidity = { high, normal }

wind = {weak, strong }

Examples of set S are:

Day

Outlook

Temperature

Humidity

Wind

Play ball

D1Sunny HotHigh WeakNo
D2Sunny HotHigh StrongNo
D3Overcast HotHigh WeakYes
D4Rain MildHigh WeakYes
D5Rain CoolNormal WeakYes
D6Rain CoolNormal StrongNo
D7Overcast CoolNormal StrongYes
D8Sunny MildHigh WeakNo
D9Sunny CoolNormal WeakYes
D10Rain MildNormal WeakYes
D11Sunny MildNormal StrongYes
D12Overcast MildHigh StrongYes
D13Overcast HotNormal WeakYes
D14Rain MildHigh StrongNo

 

Table 1

 

We need to find which attribute will be the root node in our decision tree. The gain is calculated for all four attributes:

Gain(S, Outlook) = 0.246

Gain(S, Temperature) = 0.029

Gain(S, Humidity) = 0.151

Gain(S, Wind) = 0.048 (calculated in example 2)

Outlook attribute has the highest gain, therefore it is used as the decision attribute in the root node.

Since Outlook has three possible values, the root node has three branches (sunny, overcast, rain). The next question is "what attribute should be tested at the Sunny branch node?" Since we=92ve used Outlook at the root, we only decide on the remaining three attributes: Humidity, Temperature, or Wind.

Ssunny = {D1, D2, D8, D9, D11} = 5 examples from table 1 with outlook = sunny

Gain(Ssunny, Humidity) = 0.970

Gain(Ssunny, Temperature) = 0.570

Gain(Ssunny, Wind) = 0.019

Humidity has the highest gain; therefore, it is used as the decision node. This process goes on until all data is classified perfectly or we run out of attributes.

The final decision = tree

The decision tree can also be expressed in rule format:

IF outlook = sunny AND humidity = high THEN playball = no

IF outlook = rain AND humidity = high THEN playball = no

IF outlook = rain AND wind = strong THEN playball = yes

IF outlook = overcast THEN playball = yes

IF outlook = rain AND wind = weak THEN playball = yes

ID3 has been incorporated in a number of commercial rule-induction packages. Some specific applications include medical diagnosis, credit risk assessment of loan applications, equipment malfunctions by their cause, classification of soybean diseases, and web search classification.

Conclusion

The discussion and examples given show that ID3 is easy to use. Its primary use is replacing the expert who would normally build a classification tree by hand. As industry has shown, ID3 has been effective.

Bibliography

"Building Decision Trees with the ID3 Algorithm", by: Andrew Colin, Dr. Dobbs Journal, June 1996

"Incremental Induction of Decision Trees", by Paul E. Utgoff, Kluwer Academic Publishers, 1989

"Machine Learning", by Tom Mitchell, McGraw-Hill, 1997 pp. 52-81

"C4.5 Programs for Machine Learning", by J. Ross Quinlan, Morgan Kaufmann, 1993

"Algorithm Alley Column: C4.5", by Lynn Monson, Dr. Dobbs Journal, Jan 1997

v

ID3算法应用举例 利用ID3算法实现从数据集归纳出决策树。 背景: 张三想要买一套房,可能左右他是否愿意购买这套房主要有四个方面的因素,这四种因素及可能出现的值如下表所示: 院子 车库数 楼层数 地理位置 大/小 1/2/3 2/3 城郊/市中心 张三看了14套房子,以下是这些房子具备的属性以及张三对于购买这些房子的意愿: 院子 车库数 楼层数 地理位置 是否愿意购买 大 3 2 城郊 是 小 2 3 市中心 是 小 1 3 市中心 否 小 2 3 城郊 是 大 3 3 阅读详情

相关推荐

ID3算法的weka实现

ID3:归纳决策树(Induction Decision Tree Version 3)  ID3算法一种由数据构造递归的的过程。选择一个属性作为根节点,按照其他属性将数据集分类,每一个子节点得到一个数据集。对这种划分的质量进行评估,递归执行该过程,直至全部节点不能再进行划分。某节点不能划分的条件有2:一个是节点具有单类,二是节点具有单一属性。 质量评估的标准为: ①信息增益:根节点的信息值

Lux_Veritas的专栏 5112

ID3算法的简单示例

ID3(Iterative Dichotomiser 3)是一种自上而下、贪心、基于信息增益的决策树生成算法。它由J. Ross Quinlan在1986年提出,用于解决分类问题。ID3算法通过构建一棵决策树来进行学习,树的结构取决于数据集中的特征。在构建过程中,ID3选择能够最好地将数据集进行分类的特征作为节点的判断标准。

东方佑 1619

论文代码复现 | 无人机与卡车联合配送(Python+Gurobi)(The flying sidekick traveling salesman problem)

无人机配送-代码复现The flying sidekick traveling salesman problem-Part 1文献笔记:(无人机配送-代码复现)The flying sidekick traveling salesman problem-Part 1摘要论文主要图标摘录数值实验算例结果参考文献 文献笔记:(无人机配送-代码复现)The flying sidekick traveling salesman problem-Part 1 摘要 Once limited to the milit

HsinglukLiu的博客 3万+

决策树——ID3算法

前言 我们在使用数据挖掘的时候,完成数据的“清洗”等一系列繁琐的步骤,就可以对数据进一步地进行“挖掘”——对数据进行分类的建立、预测、聚类分析等等的操作。在分类和预测的过程中,有一系列的算法得以脱颖而出——“回归分析”、“决策树”、“人工神经网络”等等 那么今天我就来介绍一下”决策树“——ID3算法 一、ID3算法 ID3作为一种经典的决策树算法,是基于信息熵来选择最佳的测试属性,其选择了当前样本集中具有最大信息增益值的属性作为测试属性。 样本集的划分则依据了测试属性的取值进行,测试属性有多少种取值

eli的博客 1万+

半监督的医学分割数据集(LA, Pancreas, ACDC和PROMISE12)分享

这篇文章提供了四个常用的半监督医学分割数据集,所有数据集都已经被处理成了.h5文件。下载之后就可以直接使用

qq_45691955的博客 4174

区块链技术在碳足迹数据存证与溯源中的应用深度解析

消费者扫描产品上的二维码,即可通过区块链浏览器查询到该产品的数字碳标签,并追溯其从茶园到货架的每一步碳足迹数据,以及这些数据是如何被智能合约自动计算和认证的,从而建立起强大的品牌信任。如果说哈希链解决了数据的“存”与“证”的问题,那么智能合约则解决了数据“用”与“管”的自动化问题。综上所述,虽然针对“碳足迹数据可追溯性”这一特定应用场景的公开、标准化的性能基准案例尚不丰富,但现有研究和企业级解决方案(特别是联盟链)已经证明,通过合理的技术选型和架构设计,区块链的性能可以满足实际商业需求。

百态·数智思维 | 聚焦大数据、量化与未来AI 1106

ID3算法简单实例(代码)

参考链接: http://blog.csdn.net/yangliuy/article/details/7322015  问题描述:这里有17个属性,背景是美国选举,然后我们需要做的就是根据除了Class Name的16个属性判断这个人是哪个党派。 std::string temp[17] = { "Class Name", "handicapped-infants", "wa

chomo的专栏 4330

图像特征(一)——颜色特征(颜色直方图,颜色矩,颜色集,颜色聚合向量和颜色相关图)

本文主要是为了更好地理解图像特征,理解各方法的原理。转载请注明出处https://mp.csdn.net/console/editor/html/105090183 图像模式识别的一般步骤为:输入图像--图像预处理--特征提取--特征选择--图像分类--输出结果。 图像特征主要有:颜色特征、形状特征、纹理特征和空间关系特征。 本文主要介绍颜色特征,并给出matlab上实现的demo。 颜...

gloria_iris的博客 3万+

决策树(ID3算法)

决策树学习笔记1、决策树的概念    顾名思义,决策树是用来:根据已知的若干条件,来对事件作出判断。从根节点到叶子节点,是将不同特征不断划分的过程,最后将类别分出。    在理论学习前,先了解下面一个例子:    如下图所示,根据“不浮出水面是否可以生存”和“是否有脚蹼”两种特征来判断该海洋动物是否鱼类。图中有5个样本,样本中有两种是鱼类,三种不是鱼类。    可建立的特征向量如下:_data_s...

知难行更难 3万+

数字IC后端笔记-libcell命名规则与标准单元库介绍

ND3D1BWP13T40P140HVTND3D1BWP13T40P140HVTTSMC两种工艺,Metalization Stack的截面示意图:还有一层AP用来走RDL,RDL这层是最厚的一层,一般用于连接IO的bump,信号线基本上不会用这层绕线。

sinat_41774721的博客 2463

SpringCloud Alibaba - Seata 实现高可用和异地容灾

这里不仅仅要实现高可用,还需要实现异地容灾. 异地容灾就是说,如果你整了好几个节点部署起来,全部放到一个机房里面,那么如果这个机房出了故障,就意味着整个集群就完了,所以对于一个大型的集群来讲,都会把这些服务异地部署.问题2:如果我们要实现异地容灾,也就说某一个机房挂了,需要快速的切换到另一个可用的机房,但是这个配置在配置文件中写死了,如果要改配置文件,还需要重启服务器,这是我们不希望看到的,怎么办?进入 seata/bin 目录,运行 seata-server.bat 文件,默认端口为 8091。

CYK_byte的博客 975

决策树之ID3算法

今天,我来讲解的是决策树。对于决策树来说,主要有两种算法:ID3算法和C4.5算法。C4.5算法是 对ID3算法的改进。今天主要先讲ID3算法,之后会讲C4.5算法和随机森林等。   Contents        1. 决策树的基本认识      2. ID3算法介绍      3. 信息熵与信息增益      4. ID3算法的C++实现     1. 决策树的基本认识

ACdreamer 8万+

Python爬虫实战:使用最新技术爬取GitHub Trending项目

本文将详细介绍如何使用Python最新技术栈构建一个高效的GitHub Trending爬虫。我们将使用异步请求库httpx、HTML解析库parsel、数据存储方案以及反反爬技术,完整实现一个能够稳定获取GitHub Trending数据的爬虫系统。文章包含5000余字详细教程,从环境搭建到代码实现,再到数据处理和存储,最后部署运行,提供全方位指导。GitHub Trending页面展示了GitHub上当前最受欢迎的项目,对于开发者了解技术趋势、发现优秀项目非常有价值。

2201_76125261的博客 735

ID3算法原理详解

本文介绍了ID3算法详细原理,并举例说明。

blinkyou001的博客 8980

黑猫带你学UFS协议第12篇:UFS标志(Flags)和属性(Atrributes)详解

UFS中的标志其实就是一些开关,布尔型,非0即1,打开或者关闭。这些标志可以用来使能或者禁止UFS设备的一些功能、模式或者状态。 简单来说,flag和attribute、discriptor一样,都是ufs的寄存器罢了。只不过spec将这些寄存器分类了,分成这三种大的类型了而已。 标志可以被清除、复位、设置、触发、读。 主机也是通过设备管理器的Query Request UPIU来读取或者写标志。

黑猫奥利奥的博客 2083

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

ID3算法思想以及实现

数据挖掘中的分类主要包括基于决策树的分类、基于规则的分类、基于神经网络的分类、基于支持向量机的分类、基于朴素贝叶斯的分类等。

NLP工程化 1万+

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

分类算法 -- 决策树ID3算法

决策树算法是非常常用的分类算法,其分类的思路非常清晰,简单易懂。并且它也是一个很基础的算法,集成学习和随机森林算法是以其为基础的。 算法简介 对于决策树算法,其输入是带有标签的数据,输出是一颗决策树。其非叶节点代表的是逻辑判断;叶节点代表的是分类的子集。 决策树算法原理是通过训练数据形成if-then的判断结构。从树的根节点到叶节点的每一条路径构成一个判断规则。我们需要选择合适的特征作为判断节点,...

海军上将光之翼的博客 2万+

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

id3算法流程图_决策树之ID3算法

初识决策树假设我们现在有这样一个数据集,记录了每次打篮球的时候,当天的天气、温度、湿度、刮风等情况然后根据历史的数据集,我们用决策树算法生成了如下的图形:这幅图相信大家很容易看懂,就是当天气是晴天的时候,打篮球;小雨的时候,不打篮球;如果是阴天,那就再看一下温度,温度低的话不打篮球,温度中的话打篮球。如果用if else来描述这幅图就是很多人写过类似if else的判断语句。但是你有没有想过,有这...

weixin_36018748的博客 5217

【Python】ID3算法的实现

ID3算法的实现ID3实现首先定义一个ID3DTree类来封装算法数据导入函数执行决策树函数决策树主方法构建决策树:创建决策树主程序计算出现次数最多的类别标签计算最优特征计算信息熵划分数据集训练决策树 ID3实现 首先定义一个ID3DTree类来封装算法 # coding:utf-8 #Python3.7.2 from numpy import * import math import copy...

qq_45587822的博客 6375

ID3分类算法

ID3分类算法由Quinlan于1986年提出来的,使用信息增益作为属性选择标准。首先检测所有属性,选择信息增益值最大的属性产生决策树节点,由该属性的不同取值建立分支,在对各分支的子集递归调用该方法建立决策树节点的分支,直到所有子集仅包含同一类别的数据为止,最后得到一棵决策树,用来对新的样本进行分类。 1.信息熵 熵(entropy,也叫信息熵)用来度量一个属性的信息量。假定S为...

4624

python实现ID3决策树分类算法

所有的分类与回归算法中心思想大致是一样的,那就是根据现有带标签的数据集训练一个分类器模型,然后对待未知的样本,根据训练好的分类模型来判定它属于哪个类。分类与回归的区别在我看来就是标签连续与否的区别,若标签连续,则是回归,若标签离散,则是分类。 数据集中的每个样本的特征都是相同维度的,生活中我们常遇到的是根据某个样本少量的特征就可以确定这个样本属于哪个类,比如可以根据一个人的长相、身高、文凭、收入...

aoanng的博客 3万+

ID3算法流程

ID3是一棵多叉树,这一棵树采用递归的方式构造 第一步根节点的构造,遍历所有特征,找到那个使分类信息增益最大的特征,将其设置为根节点,并且讲这个feature删除掉 由于根节点已经将数据分叉,递归的方式寻找每个分枝的最优特征 #ID3算法 def ID3_chooseBestFeatureToSplit(dataset): numFeatures=len(dataset[0])-1...

luoganttcc的博客 6823
上一篇: 风里的影子[十]
下一篇: id3 学习总结
KevenJava
博客等级 码龄24年 5粉丝 30原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值