【正文】
點(diǎn) ? 屬性都是種類字段 (如果是連續(xù)的,將其離散化 ) ? 所有記錄用所選屬性遞歸的進(jìn)行分割 ? 屬性的選擇是基于一個(gè)啟發(fā)式規(guī)則或者一個(gè)統(tǒng)計(jì)的度量 (如 , information gain) ? 停止分割的條件 ? 一個(gè)節(jié)點(diǎn)上的數(shù)據(jù)都是屬于同一個(gè)類別 ? 沒(méi)有屬性可以再用于對(duì)數(shù)據(jù)進(jìn)行分割 偽代碼 (Building Tree) Procedure BuildTree(S) 用數(shù)據(jù)集 S初始化根節(jié)點(diǎn) R 用根結(jié)點(diǎn) R初始化隊(duì)列 Q While Q is not Empty do { 取出隊(duì)列 Q中的第一個(gè)節(jié)點(diǎn) N if N 不純 (Pure) { for 每一個(gè)屬性 A 估計(jì)該節(jié)點(diǎn)在 A上的信息增益 選出最佳的屬性 , 將 N分裂為 N N2 } } 屬性選擇的統(tǒng)計(jì)度量 ? 信息增益 ——Information gain (ID3/) ? 所有屬性假設(shè)都是種類字段 ? 經(jīng)過(guò)修改之后可以適用于數(shù)值字段 ? 基尼指數(shù) ——Gini index (IBM IntelligentMiner) ? 能夠適用于種類和數(shù)值字段 信息增益度度量 (ID3/) ? 任意樣本分類的期望信息: ? I(s1,s2,……,s m)=- ∑Pi log2(pi) (i=1..m) ?其中,數(shù)據(jù)集為 S, m為 S的分類數(shù)目, Pi ? Ci為某分類標(biāo)號(hào), Pi為任意樣本屬于 Ci的概率, si為分類 Ci上的樣本數(shù) ? 由 A劃分為子集的熵: ?E(A)= ∑(s1j+ ……+ smj)/s * I(s1j+ ……+ smj) ? A為屬性,具有 V個(gè)不同的取值 ?信息增益: Gain(A)= I(s1,s2,……,sm) - E(A) ||||SSi?訓(xùn)練集 (舉例 ) a g e i n co me st u d e n t cre d i t _ ra t i n g b u ys_ co mp u t e r=3 0 h i g h no f a i r no=3 0 h i g h no e x ce l l e n t no3 0 …4 0 h i g h no f a i r ye s4 0 me d i u m no f a i r ye s4 0 l o w ye s f a i r ye s4 0 l o w ye s e x ce l l e n t no3 1 …4 0 l o w ye s e x ce l l e n t ye s=3 0 me d i u m no f a i r no=3 0 l o w ye s f a i r ye s4 0 me d i u m ye s f a i r ye s=3 0 me d i u m ye s e x ce l l e n t ye s3 1 …4 0 me d i u m no e x ce l l e n t ye s3 1 …4 0 h i g h ye s f a i r ye s4 0 me d i u m no e x ce l l e n t noID3算法 使用信息增益進(jìn)行屬性選擇 ? Class P: buys_puter = “yes” ? Class N: buys_puter = “no” ? I(p, n) = I(9, 5) = ? Compute the entropy for age: Hence Similarly age p i n i I ( p i, n i)=3 0 2 3 0 .9 7 13 0 …4 0 4 0 04 0 3 2 0 .9 7 19 7 )2,3(145)0,4(144)3,2(145)(????IIIa g eE)_(