Accord.Tests.MachineLearning.KernelSupportVectorMachineTest.ComputeTest2 C# (CSharp) Method

ComputeTest2() private method

private ComputeTest2 ( ) : void
return void
        public void ComputeTest2()
        {
            // XOR
            double[][] inputs =
            {
                new double[] { 0, 0 },
                new double[] { 0, 1 },
                new double[] { 1, 0 },
                new double[] { 1, 1 }
            };

            int[] labels =
            {
                -1,
                 1,
                 1,
                -1
            };

            KernelSupportVectorMachine machine = new KernelSupportVectorMachine(new Gaussian(0.1), inputs[0].Length);
            SequentialMinimalOptimization smo = new SequentialMinimalOptimization(machine, inputs, labels);

            smo.Complexity = 1;
            double error = smo.Run();

            Assert.AreEqual(-1, Math.Sign(machine.Compute(inputs[0])));
            Assert.AreEqual(+1, Math.Sign(machine.Compute(inputs[1])));
            Assert.AreEqual(+1, Math.Sign(machine.Compute(inputs[2])));
            Assert.AreEqual(-1, Math.Sign(machine.Compute(inputs[3])));

            Assert.AreEqual(error, 0);
        }