Click here to Skip to main content
11,501,968 members (61,893 online)
Click here to Skip to main content

ID3 Decision Tree Algorithm in C#

, 21 Oct 2003 192.5K 12.1K 56
Rate this:
Please Sign up or sign in to vote.
Sample of ID3 Decision Tree Algorithm in C#

Introduction

The algorithm ID3 (Quinlan) uses the method top-down induction of decision trees. Given a set of classified examples a decision tree is induced, biased by the information gain measure, which heuristically leads to small trees. The examples are given in attribute-value representation. The set of possible classes is finite. Only tests, that split the set of instances of the underlying example languages depending on the value of a single attribute are supported.

Details

Depending on whether the attributes are nominal or numerical, the tests either

  • have a successor for each possible attribute value, or
  • split according to a comparison of an attribute value to a constant, or depending on if an attribute value belongs to a certain interval or not.

The algorithm starts with the complete set of examples, a set of possible tests and the root node as the actual node. As long as the examples propagated to a node do not all belong to the same class and there are tests left,

  • a test with highest information gain is chosen,
  • the corresponding set of successors is created for the actual node,
  • each example is propagated to the successor given by the chosen test,
  • ID3 is called recursively for all successors.

How it works

The core of sample is builded with 3 classes (Attribute, TreeNode and DecisionTreeID3).

  • TreeNode - are the nodes of the decision tree;
  • Attribute - is the class with have a name e any possible values;
  • DecisionTreeID3 - is the class what get a data samples and generate a decision tree.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Roosevelt
Web Developer iddi
Brazil Brazil
No Biography provided
Follow on   Twitter

Comments and Discussions

 
Generalhelp me on project for internet advertisement prediction Pin
Member 1131005414-Dec-14 7:24
memberMember 1131005414-Dec-14 7:24 
Questiondecision tree algorithm code Pin
Member 109256204-Jul-14 17:57
memberMember 109256204-Jul-14 17:57 
QuestionHi, can anyone help me to fix these errors? Pin
Kaushik Sampath Kumar24-Mar-13 7:54
memberKaushik Sampath Kumar24-Mar-13 7:54 
QuestionUrgent Help Pin
nidhalhameed11-Nov-12 6:55
membernidhalhameed11-Nov-12 6:55 
Questionneed help in ID3 Decision Tree Algorithm in C# Pin
ramireddyrasagna6-Feb-12 17:29
memberramireddyrasagna6-Feb-12 17:29 
Questionhelp in id3 decision tree algorithm in c# Pin
ramireddyrasagna5-Feb-12 11:26
memberramireddyrasagna5-Feb-12 11:26 
GeneralNice code....but this code just for two class decision [modified] Pin
h4ckm03d27-Jul-11 2:24
memberh4ckm03d27-Jul-11 2:24 
GeneralRe: Nice code....but this code just for two class decision Pin
Muneer Safi15-Oct-12 21:03
memberMuneer Safi15-Oct-12 21:03 
GeneralRe: Nice code....but this code just for two class decision Pin
Member 109256204-Jul-14 17:54
memberMember 109256204-Jul-14 17:54 
Generalhelp,id3 decision tree Pin
dhanyamc7-Jun-11 21:06
memberdhanyamc7-Jun-11 21:06 
Generalhelp id3 decision tree Pin
dhanyamc7-Jun-11 8:22
memberdhanyamc7-Jun-11 8:22 
GeneralRebuilt based on this code Pin
Tim Claason1-Feb-11 7:28
memberTim Claason1-Feb-11 7:28 
Generalspliting criterion Pin
jamilehy2-Oct-10 12:04
memberjamilehy2-Oct-10 12:04 
QuestionHow you defined new attributes in main? Pin
jamilehy30-Sep-10 17:28
memberjamilehy30-Sep-10 17:28 
AnswerRe: How you defined new attributes in main? Pin
pol_chu2-Oct-10 9:31
memberpol_chu2-Oct-10 9:31 
GeneralRe: How you defined new attributes in main? Pin
jamilehy2-Oct-10 11:40
memberjamilehy2-Oct-10 11:40 
GeneralRe: How you defined new attributes in main? Pin
pol_chu2-Oct-10 19:16
memberpol_chu2-Oct-10 19:16 
GeneralAn error report [modified] Pin
pol_chu9-Sep-10 22:44
memberpol_chu9-Sep-10 22:44 
Generalerror Pin
lqht25-Apr-10 8:05
memberlqht25-Apr-10 8:05 
GeneralError Pin
strepto125-Apr-10 6:21
memberstrepto125-Apr-10 6:21 
Generalhi Pin
rodalyn15-Mar-10 18:15
memberrodalyn15-Mar-10 18:15 
Generalhelp:id3 decision tree Pin
std_112-Mar-10 1:34
memberstd_112-Mar-10 1:34 
GeneralRe: help:id3 decision tree Pin
SamBarakaba15-Oct-10 22:36
memberSamBarakaba15-Oct-10 22:36 
GeneralRe: help:id3 decision tree Pin
leavetrace24-Oct-10 23:08
memberleavetrace24-Oct-10 23:08 
GeneralRe: help:id3 decision tree Pin
leavetrace24-Oct-10 23:13
memberleavetrace24-Oct-10 23:13 
GeneralRe: help:id3 decision tree Pin
leavetrace24-Oct-10 23:16
memberleavetrace24-Oct-10 23:16 
GeneralRe: help:id3 decision tree Pin
leavetrace24-Oct-10 23:18
memberleavetrace24-Oct-10 23:18 
GeneralMy vote of 1 Pin
Code Deamon20-Apr-09 4:27
memberCode Deamon20-Apr-09 4:27 
Questioncan not work with more than two class Pin
leavetrace1-Jan-09 18:50
memberleavetrace1-Jan-09 18:50 
GeneralI think there's a mistake, correct me if i'm wrong Pin
rock_me1-Jul-08 6:56
memberrock_me1-Jul-08 6:56 
QuestionDo u interested in association rule? Pin
alice_nhan27-Nov-07 4:39
memberalice_nhan27-Nov-07 4:39 
Answerfind duplicate item in childsample [modified] Pin
alice_nhan27-Nov-07 4:34
memberalice_nhan27-Nov-07 4:34 
GeneralRe: find duplicate item in childsample Pin
leavetrace12-Jan-09 11:36
memberleavetrace12-Jan-09 11:36 
GeneralTranslated Version (English) of this Algorithm Pin
kirankonathala20-Apr-07 10:16
memberkirankonathala20-Apr-07 10:16 
GeneralRe: Translated Version (English) of this Algorithm Pin
kroket30-Dec-07 0:40
memberkroket30-Dec-07 0:40 
GeneralRe: Translated Version (English) of this Algorithm Pin
jingweidu25-Mar-08 0:58
memberjingweidu25-Mar-08 0:58 
GeneralRe: Translated Version (English) of this Algorithm Pin
Vaasugi16-Aug-08 21:16
memberVaasugi16-Aug-08 21:16 
GeneralRe: Translated Version (English) of this Algorithm Pin
wesemy19-Aug-08 3:51
memberwesemy19-Aug-08 3:51 
GeneralRe: Translated Version (English) of this Algorithm Pin
mikaal10018-Mar-09 6:49
membermikaal10018-Mar-09 6:49 
GeneralRe: Translated Version (English) of this Algorithm Pin
u06050943-Apr-09 16:47
memberu06050943-Apr-09 16:47 
GeneralRe: Translated Version (English) of this Algorithm Pin
Code Deamon20-Apr-09 4:16
memberCode Deamon20-Apr-09 4:16 
GeneralComments in Portugese Pin
kirankonathala19-Apr-07 12:59
memberkirankonathala19-Apr-07 12:59 
GeneralRe: Comments in Portugese Pin
Code Deamon20-Apr-09 4:17
memberCode Deamon20-Apr-09 4:17 
GeneralConsole.Readline() missing in main function! Pin
kirankonathala19-Apr-07 12:44
memberkirankonathala19-Apr-07 12:44 
GeneralIt error when excute, expect reply Pin
nvttuan841798-Jul-06 7:43
membernvttuan841798-Jul-06 7:43 
Generalhelp me Pin
nvttuan841798-Jul-06 7:19
membernvttuan841798-Jul-06 7:19 
GeneralEngl. Pin
prokopp29-Apr-06 12:17
memberprokopp29-Apr-06 12:17 
GeneralRe: Engl. Pin
Roosevelt2-May-06 2:28
memberRoosevelt2-May-06 2:28 
RantRe: Engl. Pin
Code Deamon20-Apr-09 4:24
memberCode Deamon20-Apr-09 4:24 
GeneralComment can't read Pin
Rei0011-Feb-06 19:28
memberRei0011-Feb-06 19:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150520.1 | Last Updated 22 Oct 2003
Article Copyright 2003 by Roosevelt
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid