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

RunTest3() private method

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

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

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

            Assert.AreEqual(0, tree.Root.Branches[0].Value); // a4 = 0
            Assert.AreEqual(0, tree.Root.Branches[0].Branches.AttributeIndex); // Decide over a1
            Assert.AreEqual(2, tree.Root.Branches[0].Branches.Count);
            Assert.IsFalse(tree.Root.Branches[0].Branches[0].IsLeaf);
            Assert.IsTrue(tree.Root.Branches[0].Branches[1].IsLeaf);
            Assert.AreEqual(0, tree.Root.Branches[0].Branches[1].Output);

            Assert.AreEqual(1, tree.Root.Branches[1].Value); // a4 = 1
            Assert.AreEqual(0, tree.Root.Branches[1].Branches.AttributeIndex); // Decide over a1
            Assert.AreEqual(2, tree.Root.Branches[1].Branches.Count);
            Assert.IsFalse(tree.Root.Branches[1].Branches[0].IsLeaf);
            Assert.IsTrue(tree.Root.Branches[1].Branches[1].IsLeaf);
            Assert.AreEqual(1, tree.Root.Branches[1].Branches[1].Output);

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