public void BuildTree(string fileName, string outputDirectory = "Output")
        {
            var data             = LoadDataFromfCSV(fileName);
            var decisionTreeName = Path.GetFileNameWithoutExtension(fileName);

            var algorithm = new C45Algorithm();
            var fixedData = TableFixedData.FromTableData(data);

            if (!Directory.Exists(outputDirectory))
            {
                Directory.CreateDirectory(outputDirectory);
            }

            var decisionalTree = algorithm.BuildConditionalTree(fixedData, new TreeOptions());

            var decisionTreeRenderer = new DecisionTreeRenderer();
            var bitmap = decisionTreeRenderer.RenderTree(decisionalTree, new Size(100, 50));
            var decisionTreeFileName = Path.Combine(outputDirectory, string.Format("{0}.jpg", decisionTreeName));

            bitmap.Save(decisionTreeFileName, ImageFormat.Jpeg);

            var img = new BitmapImage(new Uri(decisionTreeFileName, UriKind.RelativeOrAbsolute));

            img.Freeze();
            //img.EndInit();
            //mainGrid.Children.Remove(tree);
            tree.Source = img;
            tree.UpdateLayout();

            //tree = new Image {Source = img};
            //mainGrid.Children.Add(tree);
            //Grid.SetRow(tree,1);
            //Grid.SetColumn(tree, 1);
            txtMessage.Text = decisionalTree.ToPseudocode();
        }
Beispiel #2
0
        public static void TestC45()
        {
            var data = LoadDataFromfCSV("Data2.csv");


            var algorithm = new C45Algorithm();
            var fixedData = TableFixedData.FromTableData(data);



            var decisionalTree = algorithm.BuildConditionalTree(fixedData, new TreeOptions());

            var decisionTreeRenderer = new DecisionTreeRenderer();
            var bitmap = decisionTreeRenderer.RenderTree(decisionalTree, new Size(100, 50));

            bitmap.Save("test.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

            var pseudocode = decisionalTree.ToPseudocode();

            using (var textString = new StreamReader(@"C:\Research\Kaggle\Expedia\trainData\train.csv"))
            {
                while (!textString.EndOfStream)
                {
                    var line = textString.ReadLine();
                }
            }
        }
Beispiel #3
0
        public static void TestC45()
        {
            var data = LoadDataFromfCSV("Data2.csv");

            var algorithm = new C45Algorithm();
            var fixedData = TableFixedData.FromTableData(data);

            var decisionalTree = algorithm.BuildConditionalTree(fixedData, new TreeOptions());

            var decisionTreeRenderer = new DecisionTreeRenderer();
            var bitmap = decisionTreeRenderer.RenderTree(decisionalTree, new Size(100, 50));
            bitmap.Save("test.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

            var pseudocode = decisionalTree.ToPseudocode();

            using (var textString = new StreamReader(@"C:\Research\Kaggle\Expedia\trainData\train.csv"))
            {
                while (!textString.EndOfStream)
                {
                    var line = textString.ReadLine();
                }
            }
        }
        public void BuildTree(string fileName, string outputDirectory = "Output")
        {
            var data = LoadDataFromfCSV(fileName);
            var decisionTreeName = Path.GetFileNameWithoutExtension(fileName);

            var algorithm = new C45Algorithm();
            var fixedData = TableFixedData.FromTableData(data);

            if (!Directory.Exists(outputDirectory))
            {
                Directory.CreateDirectory(outputDirectory);
            }

            var decisionalTree = algorithm.BuildConditionalTree(fixedData, new TreeOptions());

            var decisionTreeRenderer = new DecisionTreeRenderer();
            var bitmap = decisionTreeRenderer.RenderTree(decisionalTree, new Size(100, 50));
            var decisionTreeFileName = Path.Combine(outputDirectory, string.Format("{0}.jpg", decisionTreeName));
            bitmap.Save(decisionTreeFileName, ImageFormat.Jpeg);

            var img = new BitmapImage(new Uri(decisionTreeFileName, UriKind.RelativeOrAbsolute));

            img.Freeze();
            //img.EndInit();
            //mainGrid.Children.Remove(tree);
            tree.Source = img;
            tree.UpdateLayout();

            //tree = new Image {Source = img};
            //mainGrid.Children.Add(tree);
            //Grid.SetRow(tree,1);
            //Grid.SetColumn(tree, 1);
            txtMessage.Text = decisionalTree.ToPseudocode();
        }