public void LearnTest()
{
double[][] inputs =
{
new double[] { -1, -1 },
new double[] { -1, 1 },
new double[] { 1, -1 },
new double[] { 1, 1 }
};
int[] xor =
{
-1,
1,
1,
-1
};
// Create Kernel Support Vector Machine with a Polynomial Kernel of 2nd degree
KernelSupportVectorMachine machine = new KernelSupportVectorMachine(new Polynomial(2), inputs[0].Length);
// Create the Least Squares Support Vector Machine teacher
LeastSquaresLearning learn = new LeastSquaresLearning(machine, inputs, xor);
learn.Complexity = 10;
// Run the learning algorithm
learn.Run();
int[] output = inputs.Apply(p => Math.Sign(machine.Compute(p)));
for (int i = 0; i < output.Length; i++)
Assert.AreEqual(System.Math.Sign(xor[i]), System.Math.Sign(output[i]));
}