Exemple #1
0
        private void button7_Click(object sender, EventArgs e)
        {
            //properties
            StringBuilder sb = new StringBuilder();

            sb.Append("PROPERTIES\n\n");
            sb.Append("Veurma Decision Tree Classifier. Machine Learning - Supervised Learning\n");
            sb.Append("Date: " + DateTime.Now.ToString() + "\n");
            sb.Append("Training data: " + filePath + "\n");
            sb.Append("Learning Algorithm: " + LA.ToString(learningAlgorithm) + "\n");
            sb.Append("Attribute Types: " + Attribute.ToString(decisionVariableType) + "\n");
            sb.AppendLine();
            sb.Append("Tree Size: " + tree.GetEnumerable().Count());
            sb.AppendLine();
            sb.Append("Number of leaves: " + tree.GetLeaves());
            sb.AppendLine();
            sb.Append("Classification Time: " + elapsedTime + " milliseconds \n");
            sb.Append("Number of Records: " + outputs.Length + "\n");
            sb.Append("\nATTRIBUTES \n");
            for (int i = 0; i < queryList.Count; i++)
            {
                sb.Append(queryList[i].QueryName + " -- ");
                if (queryList[i].Options.Count == 1)
                {
                    sb.Append(queryList[i].Options[0] + "\n");
                }
                else
                {
                    sb.Append("{ ");
                    foreach (string option in queryList[i].Options)
                    {
                        sb.Append(option + " , ");
                    }
                    sb.Append("} \n");
                }
            }
            sb.Append("\nCLASSES \n");
            string classes = attributes.Keys.ElementAt(attributes.Count - 1);

            foreach (string _class in attributes[classes].Inputs)
            {
                sb.Append(_class + " , ");
            }

            richTextBox1.Text = sb.ToString().Replace(", }", "}");
        }
Exemple #2
0
        private void drawTree()
        {
            IEnumerable <Node> traversal = tree.GetEnumerable();
            int counter = 0;

            foreach (Node node in traversal)
            {
                counter++;
                if (node.IsLeaf)
                {
                    graph.AddEdge(Revert(node.Parent + ""), decode(node + "", node.Comparison, node.Value), Revert(node + "") + " " + counter);
                    Microsoft.Msagl.Drawing.Node found = graph.FindNode(Revert(node + "") + " " + counter);

                    found.Attr.FillColor = Microsoft.Msagl.Drawing.Color.Aqua;
                    found.Attr.Shape     = Shape.Ellipse;
                    found.LabelText      = decodeClass(node.Output + "");
                }
                else if (node.IsRoot)
                {
                    Microsoft.Msagl.Drawing.Node rootNode = new Microsoft.Msagl.Drawing.Node(Revert(node + ""));
                    graph.AddNode(rootNode);
                    rootNode.LabelText      = attributes.ElementAt(node.Branches.Index).Key;
                    rootNode.Attr.FillColor = Microsoft.Msagl.Drawing.Color.LightPink;
                    rootNode.Attr.Shape     = Shape.Box;
                }
                else
                {
                    graph.AddEdge(Revert(node.Parent + ""), decode(node + "", node.Comparison, node.Value), Revert(node + ""));
                    Microsoft.Msagl.Drawing.Node found = graph.FindNode(Revert(node + ""));
                    found.LabelText      = attributes.ElementAt(node.Branches.Index).Key;
                    found.Attr.FillColor = Microsoft.Msagl.Drawing.Color.LightPink;
                    found.Attr.Shape     = Shape.Box;
                }
            }

            //bind the graph to the viewer
            viewer.Graph     = graph;
            viewer.BackColor = System.Drawing.Color.White;
            viewer.ForeColor = viewer.BackColor;
            //associate the viewer with the form

            viewer.Dock = DockStyle.Fill;
            this.Controls.Add(viewer);
        }