|
if u not use function "getDistinctValues" , will have error in the second call function "mountTree".
---
and
ArrayList aAttributes = new ArrayList(attributes.Length - 1);
for(int i = 0; i < attributes.Length; i++)
{
if (attributes[i].AttributeName != bestAttribute.AttributeName)
aAttributes.Add(attributes[i]);
}
------
it have a problem if data example is a little,
----> can edit :
Attribute[] aAttributes = new Attribute [attributes.Length-1];
int j = 0;
for (int i = 0; i <attributes.length; i++)<br="" mode="hold"> {
if (attributes[i].AttributeName != bestAttribute.AttributeName)
{
Attribute t=new Attribute ( attributes[i].AttributeName,(string[])getDistinctValues(childSample, attributes[i].AttributeName).ToArray(typeof(string)));
aAttributes[j] = t;
j++;
}
}
--> ok?
Huynh Ly Thanh Nhan
modified on Wednesday, December 12, 2007 3:55:54 AM
|
|
|
|
|
alslam alikum;
find duplicate item --- it is true but why i have use function "getDistinctValues"
all i need save attributes that have been used
so i used another arrayList called it usedAttributes; which hold the attributes used during the loops
so frist
ArrayList usedAttributes=new ArrayList();
then
usedAttributes.add(bestAttribute.getAttributeName());
finally
ArrayList aAttributes = new ArrayList(attributes.length - 1);
for(int i = 0; i < attributes.length-1; i++)
{
if (usedAttributes.contains(attributes[i].getAttributeName())!=true)
aAttributes.add(attributes[i]);
}
}
|
|
|
|
|
Hi coders
Had to spend more than 2 hours for the translation from Portugese to English via translate.google.com
Hope the code now makes some sense for us English Speaking people
Get the translated Code from http://kirankonathala.com/AI/ID3DecisionTree.zip
Watch this space cos' Im gonna make a Java version of this Algorithm - our evaluator demands JAVA
I need to work out an extension of this progam wherein once we build a decision tree,it should parse Test Data to predict the results.
Inducing a Decision Tree - Supplying training data and expecting an output for Test Data (makes sense,right?)
Q)How do we parse the test data?
A)Once we form an optimal Decision tree from the Training Data,we need to parse the Test Data by froming predicates (p and q and .....).
Will be posting the Test Data part very soon!!
Kiran K
|
|
|
|
|
hi,can u sent me a translated code to me? i can`s down load that form the link http://kirankonathala.com/AI/ID3DecisionTree.zip.
my email is hiwinson@gmail.com, thanks very much.
|
|
|
|
|
Please share your extended program Kiran.
|
|
|
|
|
please i want english version
my mail m_wesemy@YAHOO.COM
|
|
|
|
|
please send me the translated version with comments to jibran.javed@gmail.com
i tried to access the link but not succeed
best wishes
thankful
javed
|
|
|
|
|
Cannot access the page either. Someone upload the code somewhere else?
|
|
|
|
|
This is a trick to get you to go to his spam site!
DO NOT FOLLOW LINK!
|
|
|
|
|
Hi all!!
The comments are in Portugese,will post the translated comments if time permits
amostragem - Sampling!!
http://translate.google.com
Kiran K
I need to modify the code to suit my problem - will post here if successful!
http://kirankonathala.com
|
|
|
|
|
SPAM! DO NOT FOLLOW LINK!
HAS NOTHING TO DO WITH C# OR ID3 ALOGRITHM!
|
|
|
|
|
Hey,add Console.Redline() in main() cos' it disappears before I even look at it
|
|
|
|
|
using System;
using System.Collections;
using System.Data;
//AUTHOR: Roosevelt dos Santos Júnior
namespace ExemploID3
{
///
/// Classe que representa um atributo utilizado na
......
......
classe de decisão
///
class ID3Sample
{
public static void printNode(TreeNode root, string tabs)
{
Console.WriteLine(tabs + '|' + root.attribute + '|');
if (root.attribute.values != null)
{
for (int i = 0; i < root.attribute.values.Length; i++)
{
Console.WriteLine(tabs + "\t" + "<" + root.attribute.values[i] + ">");
TreeNode childNode = root.getChildByBranchName(root.attribute.values[i]);
printNode(childNode, "\t" + tabs);
}
}
}
static DataTable getDataTable()
{
DataTable result = new DataTable("samples");
DataColumn column = result.Columns.Add("TF");
column.DataType = typeof(string);
column = result.Columns.Add("IDF");
column.DataType = typeof(string);
column = result.Columns.Add("POS");
column.DataType = typeof(string);
column = result.Columns.Add("result");
column.DataType = typeof(bool);
result.Rows.Add(new object[] {"TF0", "IDF0", "A", false});
result.Rows.Add(new object[] {"TF9", "IDF0", "A", false});
// result.Rows.Add(new object[] {"TF9", "IDF0", "A", false});
// result.Rows.Add(new object[] {"TF0", "IDF0", "A", false});
// result.Rows.Add(new object[] {"TF0", "IDF0", "A", false});
result.Rows.Add(new object[] {"TF0", "IDF0", "N N", false});
result.Rows.Add(new object[] {"TF0", "IDF0", "N N N", false});
result.Rows.Add(new object[] {"TF0", "IDF0", "A", false});
result.Rows.Add(new object[] {"TF0", "IDF0", "N A", false});
// result.Rows.Add(new object[] {"TF0", "IDF0", "N N", false});
// result.Rows.Add(new object[] {"TF0", "IDF0", "N N", false});
result.Rows.Add(new object[] {"TF0", "IDF0", "N N A", false});
result.Rows.Add(new object[] {"TF9", "IDF0", "N N", true});
// result.Rows.Add(new object[] {"TF0", "IDF0", "N N N", false});
// result.Rows.Add(new object[] {"TF0", "IDF0", "A", false});
// result.Rows.Add(new object[] {"TF0", "IDF0", "A", false});
// result.Rows.Add(new object[] {"TF0", "IDF0", "A", false});
result.Rows.Add(new object[] {"TF0", "IDF0", "A A", false});
// result.Rows.Add(new object[] {"TF0", "IDF0", "N N N", false});
// result.Rows.Add(new object[] {"TF0", "IDF0", "N N", false});
// result.Rows.Add(new object[] {"TF0", "IDF0", "A", false});
return result;
Console.ReadLine();
}
///
/// The main entry point for the application.
///
///
[STAThread]
static void Main(string[] args)
{
Attribute TF = new Attribute("TF", new string[] {"TF0", "TF9"});
Attribute IDF = new Attribute("IDF", new string[] {"IDF0"});
Attribute POS = new Attribute("POS", new string[] {"A", "N N", "N A", "N N N", "A A", "N N A"});
Attribute[] attributes = new Attribute[] {TF, IDF, POS};
DataTable samples = getDataTable();
DecisionTreeID3 id3 = new DecisionTreeID3();
TreeNode root = id3.mountTree(samples, "result", attributes);
printNode(root, "");
}
}
}
|
|
|
|
|
when two attributes are same gain then we chose one and there are have some case positives = negatives = 0 --> gain = -1.#IND000000000 -> our decision tree error
|
|
|
|
|
English please
I can't read comments !
Tx by P.P.
|
|
|
|
|
Hi,
Can't you read comments in source code?
|
|
|
|
|
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.
|
|
|
|
|
I can't read comment you have Eng ver?
if you have it please give me one.
|
|
|
|
|
You can go to one of numerous translators on the Internet and try to translate comments by yourself. It is not too hard as it seems to.
|
|
|
|
|
Actually it's NOT easy to translate much less easy to translate TECHNICAL terms. If he wants to publish his code on a Portuguese site fine, but this is an English site and the code is worthless without good documentation.
|
|
|
|