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

ConsistencyTest1_automatic() private method

private ConsistencyTest1_automatic ( ) : void
return void
        public void ConsistencyTest1_automatic()
        {
            int n = 10000;
            int[,] random = Matrix.Random(n, 10, 0.0, 11.0).ToInt32();

            int[][] samples = random.ToJagged();
            int[] outputs = new int[n];

            for (int i = 0; i < samples.Length; i++)
            {
                if (samples[i][0] > 8)
                    outputs[i] = 1;
            }

            ID3Learning teacher = new ID3Learning();

            var tree = teacher.Learn(samples, outputs);

            double error = teacher.ComputeError(samples, outputs);

            Assert.AreEqual(0, error);

            Assert.AreEqual(11, tree.Root.Branches.Count);
            for (int i = 0; i < tree.Root.Branches.Count; i++)
                Assert.IsTrue(tree.Root.Branches[i].IsLeaf);
        }