Accord.Tests.MachineLearning.SequentialMinimalOptimizationTest.LearnTest2 C# (CSharp) Method

LearnTest2() private method

private LearnTest2 ( ) : void
return void
        public void LearnTest2()
        {

            double[][] inputs =
            {
                new double[] { -1, -1 },
                new double[] { -1,  1 },
                new double[] {  1, -1 },
                new double[] {  1,  1 }
            };

            int[] or =
            {
                -1,
                -1,
                -1,
                +1
            };

            // Create Kernel Support Vector Machine with a Polynomial Kernel of 2nd degree
            SupportVectorMachine machine = new SupportVectorMachine(inputs[0].Length);

            // Create the sequential minimal optimization teacher
            SequentialMinimalOptimization learn = new SequentialMinimalOptimization(machine, inputs, or);
            learn.Complexity = 1;

            // Run the learning algorithm
            learn.Run();


            int[] output = inputs.Apply(p => (int)machine.Compute(p));

            for (int i = 0; i < output.Length; i++)
            {
                bool sor = or[i] >= 0;
                bool sou = output[i] >= 0;
                Assert.AreEqual(sor, sou);
            }
        }