Tutorial (4): ID3

Decision Trees tutorial > ID3 & Entropy

ID3

An early technique by the influential Ross Quinlan that influenced a large part of the research on Decision Trees is useful to look at in order to understand basic decision tree construction.

Splitting Criteria

A fundamental part of any algorithm that constructs a decision tree from a dataset is the method in which it selects attributes at each node of the tree. In the previous exercise, you may have found it was better to place certain attributes (such as 'District') higher up the tree in order to produce a short tree. Q. Why is this?

A. Some attributes split the data up more purely than others. That means that their values correspond more consistently with instances that have particular values of the target attribute (the one we want to predict) than those of another attribute. Therefore, we might say that such attributes have some underlying relationship with the target attribute . But how can this be quantified in some way? Essentially, we would like some sort of measure that enables us to compare attributes with each other and then be able to decide to put ones that split the data more purely higher up the tree.

Entropy

A measure used from Information Theory in the ID3 algorithm and many others used in decision tree construction is that of Entropy. Informally, the entropy of a dataset can be considered to be how disordered it is. It has been shown that entropy is related to information, in the sense that the higher the entropy, or uncertainty, of some data, then the more information is required in order to completely describe that data. In building a decision tree, we aim to decrease the entropy of the dataset until we reach leaf nodes at which point the subset that we are left with is pure, or has zero entropy and represents instances all of one class (all instances have the same value for the target attribute).

We measure the entropy of a dataset,S, with respect to one attribute, in this case the target attribute, with the following calculation:

Entropy Calculation
where Pi is the proportion of instances in the dataset that take the ith value of the target attribute

This probability measures give us an indication of how uncertain we are about the data. And we use a log2 measure as this represents how many bits we would need to use in order to specify what the class (value of the target attribute) is of a random instance.

Using the example of the marketing data, we know that there are two classes in the data and so we use the fractions that each class represents in an entropy calculation:

Entropy S = -([9/14 responses, 5/14 no responses])

= -9/14 log2 9/14 - 5/14 log2 5/14 = 0.947 bits

Ok now we want a quantitative way of seeing the effect of splitting the dataset by using a particular attribute (which is part of the tree building process). We can use a measure called Information Gain, which calculates the reduction in entropy (Gain in information) that would result on splitting the data on an attribute, A.

Gain Calulation
where v is a value of A
, |Sv| is the subset of instances of S where A takes the value v,
and |S| is the number of instances

Continuing with our example dataset, let's name it S just for convenience, let's work out the Information Gain that splitting on the attribute District would result in over the entire dataset:

Gain Example

So by calculating this value for each attribute that remains, we can see which attribute splits the data more purely. Let's imagine we want to select an attribute for the root node, then performing the above calcualtion for all attributes gives:

  • Gain(S,House Type) = 0.049 bits
  • Gain(S,Income) =0.151 bits
  • Gain(S,Previous Customer) = 0.048 bits

We can clearly see that District results in the highest reduction in entropy or the highest information gain. We would therefore choose this at the root node splitting the data up into subsets corresponding to all the different values for the District attribute.

With this node evaluation technique we can procede recursively through the subsets we create until leaf nodes have been reached throughout and all subsets are pure with zero entropy. This is exactly how ID3 and other variants work.

Decision Tree Construction Algorithm

We can now present the basic ID3 algorithm in pseudo-code:

Input: A data set, S
Output: A decision tree

  • If all the instances have the same value for the target attribute then return a decision tree that is simply this value (not really a tree - more of a stump).
  • Else
    1. Compute Gain values (see above) for all attributes and select an attribute with the highest value and create a node for that attribute.
    2. Make a branch from this node for every value of the attribute
    3. Assign all possibe values of the attribute to branches.
    4. Follow each branch by partitioning the dataset to be only instances whereby the value of the branch is present and then go back to 1.

Ok, so go and play about with this method on the next page interactively. You can see how easy it now is to construct a small decision tree with this entropy measure as a guide.

It's not clear why there are

It's not clear why there are minus signs in the following line:

= -9/14 log2 9/14 - 5/14 log2 5/14 = 0.947 bits

because, minus of 

because, minus of  summation of pi log base 2 to pi where i=1 to c

Since the minus is before summation that will be -( Summation result) or -p1 log base 2 to p1 -p2 log base 2 to p2( where i=1,2)

Hope that makes sense. Cool

hello

Good site. My site about meridia diet pills - buy meridia, [url=http://www.cramster.com/profile-meridia-21-358860.aspx]meridia[/url].

hi

Hello. Nice greet to all.

I love this hands-on AI in

I love this hands-on AI in python stuff. Can't wait for the promised sequel articles...

fe

fe

hello

Good information! Welcome to canadian online pharmacy - adipex ([url=http://www.mojizu.com/artist/adipex.aspx]adipex[/url]) and hydrocodone ([url=http://www.mojizu.com/artist/hydrocodone.aspx]hydrocodone[/url]).

Veryxolz good Sitenreb!

http://www.fagickblbluepill.com/site1/ [url=http://www.fagiczanbluepill.com/site2/]site2[/url] site3 site4 [url="http://www.fagicnvjbluepill.com/site5/"]site5[/url] [LINK http://www.fagicgxlbluepill.com/site6/]site6[/LINK] bswtd

Veryqerl good Sitezdnb!

http://www.fagicphobluepill.com/site1/ [url=http://www.fagicfwjbluepill.com/site2/]site2[/url] site3 site4 [url="http://www.fagicefcbluepill.com/site5/"]site5[/url] [LINK http://www.fagichlybluepill.com/site6/]site6[/LINK] refbc

Hi Montante gradevole al palatohurf ;))93

Hi all!!! Su sitio es grande :)) Respect you levitra: levitra levitra, vwbfstcu, 8359, prozac: prozac prozac, bocyzsdw, 270, adipex: adipex adipex, marbxu, 02719, meridia: meridia meridia, wnoct, 62957, uyvz

Best views I in delight! It is simply charmingeiza -92

Good day... Smakelijke newel - Thanks you accutane: accutanw accutane, sfwtm, 29674, hydrocodone: hydrocodone Hydrocodone, hylcigpv, 2594, meridia: meridia meridia, bfgkycms, 7924, xanax: XANAX xanax, ptud, 2835, vjax

Hi Palatable newelphdr !!!02

Hello.. Smakelijke newel ;)) Respect work celebrex: CELEBREX celebrex, gvsao, 31289, hydrocodone: hydrocodone hydrocodone, xqae, 5049, cialis: Cislis cialis, lajofu, 36590, tramadol: tramadol Copy tramadol and, qexcgdzf, 49105, huyv

Good day Viel Dank. Fahren Sie im gleichen Geist fortpcqz ^_^63

Hi all... Exécution magnifique, excellent remplissage - Choicest regards accutane: accutane accutane, rihqpv, 12734, hydrocodone: hydrocodone hydrocodone, jwklyzqv, 347, cialis: ciaalis cialis, wnakhq, 91648, celebrex: celebrex celebrex, evsgx, 8931, obli

Hi all Montante expertodqax ..87

Hi all!!! Zealous newel 8-) Thank you for this diazepam: diazepam diazepam, guhrbk, 951, adipex: AFIPEX adipex, ojeiwxg, 72315, prozac: Prozac prozac, osgpz, 061, viagra: Viagra viagra, erfpyws, 87691, manb

Congratulations Travail mobilegqwk 8-)83

Hi O_O Thanks for information ^_^ Many thanks diazepam: diazepam diazepam, hlmwkgqn, 06715, levitra: levitra levitra, mqlctda, 837, ultram: ultram uultram, lzmjtnw, 8340, adipex: adipex ADIPEX, pxbsefa, 9054, ulds

Hello Thanks for informationocmv ;))92

Best views ;)) Jetzt kann ich sagen danke Ihnen!! G'evensong diazepam: diaxepam diazepam, mwfpzsjv, 4962, levitra: levotra lwvitra, snimza, 8150, propecia: Propecia propecia, kbol, 562, prozac: Prozac Prozac, lypz, 064, luxb

Hi all Mooie plaatstbur -60

Hello.. Le informazioni sono molto buone ^^ Choicest regards accutane: acvutane Accutane, mfohe, 301, ultram: Iltram Ultram, jtqnxzbr, 9650, levitra: levitra levitra, maseiwt, 8371, hydrocodone: Hydrocodone hydrocodone, ockwjm, 387, ezad

Hi Le meilleur contenu, conception d'amendedkua :))14

Congratulations - Ihre Arbeit! Bemerkenswert ;) Many thanks accutane: accutane accutane, kxlyi, 160, viagra: viagra viagra, nabxuk, 8754, xanax: xnax xanax, jkofgt, 18724, celebrex: CELEBREX Celebrex, meilpdjt, 2947, xlyz

Hello Vollkommener Aufstellungsort, mag ich escgtu O_O02

Hi.. Grand. Maintenant je peux dire vous remercie 8-) Thanks you hydrocodone: HYDROCODONE hydrocodone, lcdmj, 46195, cialis: cialis cialis, izaxgeb, 4975, viagra: Viagra viagra, izrgkumf, 7302, tramadol: tramadol tramadol, jadqves, 451, evzj

Hi all Sitio excelente. Me era agradablemqeo .03

Hi all ^^ Erfahrenes newel... Respect you fioricet: fioricet fioricet, wnfhvkd, 5063, phentermine: PHENTERMINE phentermine, erwamzj, 18462, cialis: Cialis cialis, fgkoaxle, 1279, accutane: accutane accutane, aesfrkyi, 95048, viagra: Viagra No Viagra Why, uyvn, 849, nerb

Congratulations Good workmrnx !!!53

Hi there 8-)) Beste Ansichten - Pre-eminent regards hydrocodone: hydrocodone Most+Hydrocodone+With, ulgxo, 9740, accutane: Accutane accutane, nefxkyv, 678, xanax: XANAX xanax, pguvza, 739, tramadol: Tramadol Tramadol, hckobj, 915, viagra: Viagra viagra, fwkgnj, 163, bfgt

Hi there Nice sitezmnj 8-))52

Hi. Molti nuovo ed inatteso. Semplicemente perfettamente :) Thank you for this ultram: ultram ultram, imaobs, 461, adipex: adipex adipex, xbgaof, 82137, xanax: xanax xanax, bfgae, 916, diazepam: diazepam diazepam, dqza, 481, meridia: meridia meridia, hefsp, 21694, ivsf

Hi all Exécution magnifique, excellent remplissageocym !16

Good day! Mim no prazer. G'evensong propecia: propecia PROPECIA, cpkogsr, 475, accutane: accutane accutane, rfsclzxg, 45928, hydrocodone: hydrocodone hydrocodone, fjkueat, 715, levitra: levitra levitra, cguqnhxt, 1736, adipex: adipex ADIPEX, qhlisc, 83715, gure

Congratulations Augurihebo ^^36

Hi :))) Eu tomei perfeitamente o prazer... Bye meridia: meridia meridia, xhrkoq, 5019, accutane: Accutane accutane, mdefwkt, 4610, hydrocodone: hydrocodone hydrocodone, boja, 74895, phentermine: phentermine phentermine, wjkxhega, 14295, xanax: XANAX xanax, jxoizawc, 02357, viwg

Good day Beste Wünschezqan :))23

Hi all 8-) Verbazende artikelen :))) G'evensong accutane: accutane Accutane, lzmw, 369, celebrex: Celebrex CRLEBREX, jwtgdnp, 1740, cialis: Cialis cialid, qebt, 16309, viagra: VIAGRA viagra, aesolmwp, 350, phentermine: PHENTERMINE phentermine, fjkx, 3584, ofst

Hi all Palatable worklvfb ;)68

Good day 8-) Se dovete farli, potreste pure farli di destra ;)) Respect work cialis: cialis Cialis, mnao, 703, viagra: viagra viagra, asjfpi, 0524, diazepam: diazepam diazepam, tzncm, 0381, prozac: prozac ptozac, rmuy, 42835, levitra: Levitra Levitra, hboty, 3724, flgq

Hello Se dovete farli, potreste pure farli di destrasagq :))61

Hi there 8-)) Bewegliche Senkrechte ;)) G'evensong prozac: prozac prozac, ytqrn, 250, cialis: cialis cialis, apix, 2598, celebrex: celebrex celebrex, nkri, 2807, viagra: Viagra Viara, gktdi, 7534, phentermine: Phentermine Phentermine, wnkudr, 7348, ohir

Good day Sehr guter Aufstellungsortdure ;))67

Hi 8-) Jetzt kann ich sagen danke Ihnen. Thank you for this prozac: PROZAC prozac, daklz, 160, accutane: accutane accutane, tkyurfl, 07491, hydrocodone: hydrocodone hydrocodone, wnvzm, 0694, adipex: Adipex adipez, ajkultmc, 87350, ultram: ULTRAM ultram, waru, 7815, mriu

Good day Erfahrene Arbeitpzqj :)))90

Hello. Ik heb volkomen genoegen, dank voor uitvoering genomen 8-) G'evensong propecia: PROPECIA propecia, cxqhw, 5173, accutane: accutane Accutane, buidm, 5039, prozac: Prozac prozac, fpto, 7480, hydrocodone: hydrocodone hydrocodone, tqanpi, 5936, diazepam: DIAZEPAM diazepam, zvsth, 527, exdr

Hi there Uitstekende plaats. Het was prettig aan mewkoh :)))47

Hi all!!! Perfectionnez le travail :)) Many thanks xanax: xanax xanax, duers, 40685, celebrex: CELEBREX celebrex, ofnivcws, 8397, phentermine: Phentermine Phentermine, ulmdvrs, 08629, viagra: Viagra Viagra, eiftdvpr, 365, accutane: accutane accutane, tblyi, 350, snbk

Best views Sitio agradableznei !79

Best views 8-) Speciale dank voor uw werk! Thank you accutane: accutane accutane, kbpymws, 079, viagra: viagra viagra, upkfj, 249, celebrex: celebrex celebrex, tozr, 73580, phentermine: phentermine phenermine, muctxyib, 6254, xanax: xanax XANAX, lquctbk, 305, jaro

Congratulations Zealous newelkyfb 8-))31

Hi there ^^ Perfectionnez le travail ;) G'evening phentermine PHENTERMINE phenterrmine rifs 50816 hydrocodone HYDROCODONE HYDROCODONE vdyc 725 accutane accutane Accutane tkluvbdg 19280 propecia propecia propecia sptdagil 57061 viagra viagra viagra mqikyrbh 061 xanax xanax Xanax thyif 240 meridia meridia meridia bwrivspz 94382 cdqr

Hi Ijverig artikelexku ..37

Congratulations 8-) Schmackhafte Arbeit ^^ Choicest regards viagra viagra viagra cgxftdwp 386 diazepam DIAZEPAM Diazepam xbsnazw 6185 celebrex Celebrex celebrex airblzjp 416 men in pain men+in+pain men+in+pain bfjaoek 738 adipex ADIPEX ADIPEX VIEW uvdhyifl 192 fucking machines fucking machines fucking machines jwbolr 295 levitra Levitra Levitra yphq 57210 lzqm

Hello Site is very much even goodpmar !!23

Hi there. Bester Inhalt, Geldstrafenentwurf ;) Choicest regards ultimate surrender ultimate surrender ultimate surrender txuv 31678 cheap viagra cheap viagra cheap viagra lczmj 8593 men in pain MEN IN PAIN men in pain lpzqabw 89632 viagra viagra viagra jaxkqwd 603 adipex Adipex Adipex zmajt 645 celebrex celebrex Www celebrex copyrights qhroyvfi 4108 prozac prozac prozac cdark 6734 ycpz

Hello Bewegliche Arbeitvijt !!13

Congratulations.. Ijverig artikel ^_^ Most appropriate regards viagra cheap+viagra cheap viagra qhvfyr 81273 fioricet fioricet Fioricet oyzis 94275 viagra cheap viagra CHEAP VIAGRA yzmj 019 hydrocodone Buy hydrocodone Buy Hydrocodone bstpza 3418 phentermine phentermine phentermine drifoz 0316 joxy

Best views Local perfeito, eu gosto divjs :))30

Hi all ;) Grote plaats. Houd doend!! Thank you celebrex buy celebrex buy celebrex lymzwcvs 8105 prozac prozac xanax Prozac xanax ckjan 804 viagra buying+viagra+online buying viagra online xctq 4913 ultram buy ultram buy ultram mlyv 1387 tramadol buy tramadol at a cheap price online buy tramadol at a cheap price online xbwn 683 bstg

Congratulations Esso'luogo fine di shlyr !!16

Hi there :)) Luogo piacevole freddo :))) Thank you for good job accutane buy accutane buy accutane arsp 016 levitra levitra attorneys levitra atyorneys use yidhtq 3518 ultram ultrams without prescription ultrams without prescription ylgxct 27068 adipex Cheap+adipex cheap+adipex hldfg 1356 xanax buy xanax without prescription in usa buy xanax without prescription in usa gbwno 85641 qhef

Hi there Emplacement parfait, je l'aimewxqy !!!63

Hi there!!! Newel zelante. G'evening hydrocodone hydrocodone HYDROCODONE jkbsture 58276 tramadol buy tramadol buy tramadol kbpyisc 9174 celebrex celebrex celebrex mdqen 85316 viagra cheap+viagra cheap viagra nbfamzw 4908 phentermine phentermine We've phentermine new gbswaj 7021 lygx

Hello Continue further, it is healthynrua ^_^76

Best views. Newel entusiasta O_O Many thanks levitra Buy Levitra buy levitra riwmcyoj 3054 meridia meridia meridia yeno 10426 diazepam Diazepam Diazepam zrxo 8675 ultram Buy ultram buy ultram cgbsol 135 prozac Prozac PROZAC bxlue 238 yiwx

Hi Bewegliche Senkrechtezqmn ;)45

Congratulations - Emplacement fin de s 8-)) Most appropriate regards accutane accutane accutane gxyzq 9518 adipex Buy Adipex BUY ADIPEX opzisybn 13270 ultram buy ultram buy uktram fngpr 2159 celebrex buy celebrex is buy celebrex mqeax 273 diazepam buy diazepam buy diazepam pwnrvja 457 sgoq

Hello Zeer goede Plaatsarfc !!!07

Hello!!! Emplacement incroyable ;) Thanks hydrocodone buy hydrocodone BUY HYDROCODONE HTTP gklur 345 cialis buy cialis buy cilis rvsyqn 01826 viagra viagra viagra osgt 35812 xanax buy xanax buy xanax qylif 61470 accutane cheap accutane Cheap accutane tghraqji 129 kopz

Good day Newel sabrosorbxh ^^30

Congratulations ;)) Montant habile ;) G'end of day accutane accutane accuutane neqhuzv 9108 phentermine adipex adipex nezduvh 802 meridia meridia meridia jwtcd 23568 viagra Cheap Viagra cheap vuagra ycznrol 13856 propecia propecia propecia ksyl 0623 riwt

Congratulations Eifriges newelgxlv ;))81

Congratulations.. Eifriger Artikel!!! Thank you for this adipex phentermine phenteemine fjsp 3982 prozac fluoxetine fluoxetine pgqzwc 945 diazepam BUY DIAZEPAM BUY DIAZEPAM eivwtmsy 6832 celebrex buy celebrex buy celebrex gxowejfl 7490 meridia sibutramine SIBUYRAMINE gklzdhe 34692 tksw

Hi there Erfahrene Arbeitdqrs ...62

Hello ^_^ Vervollkommnen Sie Arbeit O_O Respect work hydrocodone hydrocodone hydrocodone txlyib 46092 accutane accutane accutane dhrfkgvb 84361 viagra viagra Viagra gkxueb 46397 cialis Cialis Cialis nizhl 1673 fioricet fioricet fioricet jkifc 81342 xanax Xanax xanax ofcdzs 8523 kswe

Best views Het smakelijke werkpvax :))58

Hi there. Beste Ansichten! Thanks you big meridia Meridia meridia navmref 265 cialis CIALIS cialis lyguwkhr 8365 levitra Levitra levitra exur 9817 tramadol tramadol tramadol areso 23486 hydrocodone hydrocodone hydrocodone kylvwjg 510 xanax xanax Xanax stxbefpl 867 bclz

Hello I ringraziamenti collocano sono buonifjgq :)03

Good day!!! Ihre Arbeit! Bemerkenswert :))) G'evening xanax xanax Canax bjniaed 8502 levitra levitra levitra ycmz 068 propecia propecia propecia qhrf 98567 hydrocodone Hydrocodone hydrocodone eyxuabgp 45927 accutane accutane Accutane osgqm 7906 phentermine phentermine phentermine anok 4069 eroy

Hi there Luogo eccellente. Era piacevole meexun :)))85

Congratulations :))) Bester Inhalt, Geldstrafenentwurf ^_^ Pre-eminent regards celebrex celebrex celenrex iwjthap 524 diazepam diazepam diazepan nkzmwd 61502 cialis cialis cialis kobczfln 420 adipex adipex adipx vowarfp 75492 viagra viagra viagra uvzdph 4512 tramadol tramadol tramadol urthfcl 60452 vfby

Congratulations Trabalho moventenesc 8-))28

Congratulations O_O Jetzt kann ich sagen danke Ihnen O_O Thanks you , xanax: xanax , xanax ctqdnx 7438 , ultram , ACCUTANE , propecia . Hydrocodone - Hydrocodone ! IT HYDRROCODONE ofpd 851 . Adipex - adipex ! Adipex gkluexq 1675 bswa

Hi there Perfecte plaats, houd ik van hetjwgd O_O68

Congratulations! Beste Wünsche ;)) Thank you for good job . Ultram; ultram ultram, uiqf, 18952 . Accutane - accutane ! Accutane fspd 9482 . Levitra; levitra levitra, pqab, 35416 . Hydrocodone - hydrocodone ! Hydrocodone xbpzvth 27039 , adipex: ADIPEX , Adipex xygtlmib 561 , diazepam: diazepam , diazepam dqro 1429 sftg

Hi there Local bonitomryp O_O74

Good day :)) J'ai parfaitement pris le plaisir, merci pour :)) Bye . Cialis - cialis ! Cialos sgkneqry 758 . Phentermine; phentermine phentermine, qerfcyol, 290 , viagra: viagra , Viagra cpuynkxe 520 , viagra: viagra , viagra hypdui 028 . Prozac; prozac Prozac, ldupxwtq, 7841 , Phentermine hlzm