Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string[] lines = Resources.nursery.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
- DataTable table = new DataTable("Nursery");
- table.Columns.Add("parents", "has_nurs", "form", "children",
- "housing", "finance", "social", "health", "output");
- foreach (var line in lines)
- table.Rows.Add(line.Split(','));
- // Create learning data
- Codification codebook = new Codification(table);
- DataTable symbols = codebook.Apply(table);
- double[][] inputs = symbols.ToArray("parents", "has_nurs", "form", "children", "housing", "finance", "social", "health");
- int[] outputs = symbols.ToIntArray("output").GetColumn(0);
- // Create tree
- DecisionVariable[] attributes =
- {
- new DecisionVariable("parents", 3),
- new DecisionVariable("has_nurs", 5),
- new DecisionVariable("form", 4),
- new DecisionVariable("children", 4),
- new DecisionVariable("housing", 3),
- new DecisionVariable("finance", 2),
- new DecisionVariable("social", 3),
- new DecisionVariable("health", 3),
- };
- DecisionTree tree = new DecisionTree(attributes, 5);
- // Create C45 and learn the tree
- C45Learning c45 = new C45Learning(tree);
- double error = c45.Run(inputs, outputs);
- var exp = tree.ToExpression();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement