Click here to Skip to main content
15,946,988 members
Articles / Programming Languages / C#
Article

ID3 Decision Tree Algorithm in C#

Rate me:
Please Sign up or sign in to vote.
3.05/5 (44 votes)
21 Oct 20031 min read 310.2K   20.2K   58   56
Sample of ID3 Decision Tree Algorithm in C#

Image 1

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


Written By
Web Developer iddi
Brazil Brazil
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionBUG Pin
Member 1278277018-Jun-17 23:08
Member 1278277018-Jun-17 23:08 
BugThere is an error. totalAmount Pin
Member 1045453319-Jan-17 19:17
Member 1045453319-Jan-17 19:17 
QuestionId3 decision tree Pin
Member 1285792118-Nov-16 1:38
Member 1285792118-Nov-16 1:38 
QuestionUrgent help - null attribute Pin
Member 1232661616-Feb-16 5:04
Member 1232661616-Feb-16 5:04 
Generalhelp me on project for internet advertisement prediction Pin
Member 1131005414-Dec-14 7:24
Member 1131005414-Dec-14 7:24 
Questiondecision tree algorithm code Pin
Member 109256204-Jul-14 17:57
Member 109256204-Jul-14 17:57 
QuestionHi, can anyone help me to fix these errors? Pin
Kaushik Sampath Kumar24-Mar-13 7:54
Kaushik Sampath Kumar24-Mar-13 7:54 
QuestionUrgent Help Pin
nidhalhameed11-Nov-12 6:55
nidhalhameed11-Nov-12 6:55 
Questionneed help in ID3 Decision Tree Algorithm in C# Pin
ramireddyrasagna6-Feb-12 17:29
ramireddyrasagna6-Feb-12 17:29 
Questionhelp in id3 decision tree algorithm in c# Pin
ramireddyrasagna5-Feb-12 11:26
ramireddyrasagna5-Feb-12 11:26 
GeneralNice code....but this code just for two class decision Pin
Moch Lutfi27-Jul-11 2:24
Moch Lutfi27-Jul-11 2:24 
GeneralRe: Nice code....but this code just for two class decision Pin
Muneer Safi15-Oct-12 21:03
Muneer Safi15-Oct-12 21:03 
GeneralRe: Nice code....but this code just for two class decision Pin
Member 109256204-Jul-14 17:54
Member 109256204-Jul-14 17:54 
Generalhelp,id3 decision tree Pin
dhanyamc7-Jun-11 21:06
dhanyamc7-Jun-11 21:06 
Generalhelp id3 decision tree Pin
dhanyamc7-Jun-11 8:22
dhanyamc7-Jun-11 8:22 
GeneralRebuilt based on this code Pin
Tim Claason1-Feb-11 7:28
Tim Claason1-Feb-11 7:28 
Generalspliting criterion Pin
jamilehy2-Oct-10 12:04
jamilehy2-Oct-10 12:04 
QuestionHow you defined new attributes in main? Pin
jamilehy30-Sep-10 17:28
jamilehy30-Sep-10 17:28 
AnswerRe: How you defined new attributes in main? Pin
pol_chu2-Oct-10 9:31
pol_chu2-Oct-10 9:31 
GeneralRe: How you defined new attributes in main? Pin
jamilehy2-Oct-10 11:40
jamilehy2-Oct-10 11:40 
GeneralRe: How you defined new attributes in main? Pin
pol_chu2-Oct-10 19:16
pol_chu2-Oct-10 19:16 
GeneralAn error report [modified] Pin
pol_chu9-Sep-10 22:44
pol_chu9-Sep-10 22:44 
Generalerror Pin
lqht25-Apr-10 8:05
lqht25-Apr-10 8:05 
GeneralError Pin
strepto125-Apr-10 6:21
strepto125-Apr-10 6:21 
Generalhi Pin
rodalyn15-Mar-10 18:15
rodalyn15-Mar-10 18:15 

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

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