public void LearnTest4()
{
double[][] inputs =
{
new double[] { -1, -1 },
new double[] { -1, 1 },
new double[] { 1, -1 },
new double[] { 1, 1 }
};
int[] negatives =
{
-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, negatives);
learn.Complexity = 1;
// Run the learning algorithm
double error = learn.Run();
Assert.AreEqual(0, error);
int[] output = inputs.Apply(p => (int)machine.Compute(p));
for (int i = 0; i < output.Length; i++)
{
bool sor = negatives[i] >= 0;
bool sou = output[i] >= 0;
Assert.AreEqual(sor, sou);
}
}