public void learn_new_method()
{
#region doc_xor_normal
// As an example, we will try to learn a decision machine
// that can replicate the "exclusive-or" logical function:
double[][] inputs =
{
new double[] { 0, 0 }, // the XOR function takes two booleans
new double[] { 0, 1 }, // and computes their exclusive or: the
new double[] { 1, 0 }, // output is true only if the two booleans
new double[] { 1, 1 } // are different
};
int[] xor = // this is the output of the xor function
{
0, // 0 xor 0 = 0 (inputs are equal)
1, // 0 xor 1 = 1 (inputs are different)
1, // 1 xor 0 = 1 (inputs are different)
0, // 1 xor 1 = 0 (inputs are equal)
};
// Now, we can create the sequential minimal optimization teacher
var learn = new SequentialMinimalOptimization<Gaussian>()
{
UseComplexityHeuristic = true,
UseKernelEstimation = true
};
// And then we can obtain a trained SVM by calling its Learn method
SupportVectorMachine<Gaussian> svm = learn.Learn(inputs, xor);
// Finally, we can obtain the decisions predicted by the machine:
bool[] prediction = svm.Decide(inputs);
#endregion
Assert.AreEqual(prediction, Classes.Decide(xor));
}