public void LearnTest5()
{
double[][] inputs =
{
new double[] { -1, -1 },
new double[] { -1, 1 },
new double[] { 1, -1 },
new double[] { 1, 1 }
};
int[] positives =
{
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, positives);
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 = positives[i] >= 0;
bool sou = output[i] >= 0;
Assert.AreEqual(sor, sou);
}
}