Click here to Skip to main content
15,867,194 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 307.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

 
GeneralComments in Portugese Pin
kirankonathala19-Apr-07 12:59
kirankonathala19-Apr-07 12:59 
GeneralRe: Comments in Portugese Pin
Code Deamon20-Apr-09 4:17
Code Deamon20-Apr-09 4:17 
GeneralConsole.Readline() missing in main function! Pin
kirankonathala19-Apr-07 12:44
kirankonathala19-Apr-07 12:44 
GeneralIt error when excute, expect reply Pin
nvttuan841798-Jul-06 7:43
nvttuan841798-Jul-06 7:43 
Generalhelp me Pin
nvttuan841798-Jul-06 7:19
nvttuan841798-Jul-06 7:19 
GeneralEngl. Pin
prokopp29-Apr-06 12:17
prokopp29-Apr-06 12:17 
GeneralRe: Engl. Pin
Roosevelt2-May-06 2:28
professionalRoosevelt2-May-06 2:28 
RantRe: Engl. Pin
Code Deamon20-Apr-09 4:24
Code Deamon20-Apr-09 4:24 
No, they are in Portuguese. As much as some may not like it English is the international language for programmers so writing comments in anything but English ON AN ENGLISH LANGUAGE SITE is pretty silly.

In fact most technical words are in English. Just ask anyone in Brazil to tell you the name of the software/hardware that protects your network from the bad people on the Inter-web and they will tell you, "Um firewall." But if you ask them if they have a good "uma parede de fogo" or "um incêndio parede" they will look at you strangely.
GeneralComment can't read Pin
Rei0011-Feb-06 19:28
Rei0011-Feb-06 19:28 
GeneralRe: Comment can't read Pin
papa_valera_ii12-Jul-06 3:20
papa_valera_ii12-Jul-06 3:20 
RantRe: Comment can't read Pin
Code Deamon20-Apr-09 4:26
Code Deamon20-Apr-09 4:26 

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.