Accord.Tests.MachineLearning.ID3LearningTest.RunTest2 C# (CSharp) Method

RunTest2() private method

private RunTest2 ( ) : void
return void
        public void RunTest2()
        {
            DecisionTree tree;
            int[][] inputs;
            int[] outputs;

            CreateMitchellExample(out tree, out inputs, out outputs);

            Assert.AreEqual(0, tree.Root.Branches.AttributeIndex); // Outlook
            Assert.AreEqual(3, tree.Root.Branches.Count);
            Assert.IsNull(tree.Root.Output);
            Assert.IsNull(tree.Root.Value);

            Assert.AreEqual(0, tree.Root.Branches[0].Value); // Outlook = Sunny
            Assert.AreEqual(2, tree.Root.Branches[0].Branches.AttributeIndex); // Decide over Humidity
            Assert.AreEqual(2, tree.Root.Branches[0].Branches.Count);
            Assert.IsTrue(tree.Root.Branches[0].Branches[0].IsLeaf);
            Assert.IsTrue(tree.Root.Branches[0].Branches[1].IsLeaf);

            Assert.AreEqual(1, tree.Root.Branches[1].Value); // Outlook = Overcast
            Assert.IsNotNull(tree.Root.Branches[1].Branches);
            Assert.AreEqual(0, tree.Root.Branches[1].Branches.Count);
            Assert.IsTrue(tree.Root.Branches[1].IsLeaf);

            Assert.AreEqual(2, tree.Root.Branches[2].Value); // Outlook = Rain
            Assert.AreEqual(3, tree.Root.Branches[2].Branches.AttributeIndex); // Decide over Wind
            Assert.AreEqual(2, tree.Root.Branches[2].Branches.Count);
            Assert.IsTrue(tree.Root.Branches[2].Branches[0].IsLeaf);
            Assert.IsTrue(tree.Root.Branches[2].Branches[1].IsLeaf);

            Assert.AreEqual(0, tree.Root.Branches[0].Branches[0].Value); // Humidity = High
            Assert.IsTrue(tree.Root.Branches[0].Branches[0].IsLeaf);

            Assert.AreEqual(1, tree.Root.Branches[0].Branches[1].Value); // Humidity = Normal
            Assert.IsTrue(tree.Root.Branches[0].Branches[1].IsLeaf);

            Assert.AreEqual(0, tree.Root.Branches[2].Branches[0].Value); // Wind = Weak
            Assert.IsTrue(tree.Root.Branches[2].Branches[0].IsLeaf);

            Assert.AreEqual(1, tree.Root.Branches[2].Branches[1].Value); // Wind = Strong
            Assert.IsTrue(tree.Root.Branches[2].Branches[1].IsLeaf);
        }