Esempio n. 1
0
        public void ID3_runmodel_case_5()
        {
            Dasmic.MLLib.Algorithms.DecisionTree.BuildID3 id3 = new Dasmic.MLLib.Algorithms.DecisionTree.BuildID3();
            ModelBase model = (ModelBase)id3.BuildModel(_trainingData,
                                                        _attributeHeaders,
                                                        _indexTargetAttribute);

            // Data will be in format "Outlook","Temperature","Humidity","Wind","PlayTennis"
            double[] data  = { 2, 1, 1, 1 };
            double   value = model.RunModelForSingleData(data);

            Assert.AreEqual(value, 0);
        }
Esempio n. 2
0
        public void ID3_maketree_check_root_node()
        {
            Dasmic.MLLib.Algorithms.DecisionTree.BuildID3 id3 = new Dasmic.MLLib.Algorithms.DecisionTree.BuildID3();
            ModelBase model = (ModelBase)id3.BuildModel(_trainingData,
                                                        _attributeHeaders,
                                                        _indexTargetAttribute);

            model.getPrintedTree();

            //Check Nodes
            Assert.IsTrue(model.Root.AttributeName.Equals("Outlook"));
            Assert.IsTrue(model.Root.getChildWithValue(0).AttributeName.Equals("Humidity"));
            Assert.IsTrue(model.Root.getChildWithValue(1).AttributeName.Equals("PlayTennis"));
            Assert.IsTrue(model.Root.getChildWithValue(2).AttributeName.Equals("Wind"));
        }
Esempio n. 3
0
        public void ID3_maketree_check_final_nodes()
        {
            string output;

            Dasmic.MLLib.Algorithms.DecisionTree.BuildID3 id3 =
                new Dasmic.MLLib.Algorithms.DecisionTree.BuildID3();
            ModelBase model = (ModelBase)id3.BuildModel(_trainingData,
                                                        _attributeHeaders,
                                                        _indexTargetAttribute);

            output = model.getPrintedTree();

            //Check Tree Nodes
            Assert.IsTrue(model.Root.getChildWithValue(0).getChildWithValue(0).Value == 1); //Humidity
            Assert.IsTrue(model.Root.getChildWithValue(0).getChildWithValue(1).Value == 0);

            Assert.IsTrue(model.Root.getChildWithValue(1).Value == 1);

            Assert.IsTrue(model.Root.getChildWithValue(2).getChildWithValue(0).Value == 1); //Humidity
            Assert.IsTrue(model.Root.getChildWithValue(2).getChildWithValue(1).Value == 0);
        }