public void RunTest()
{
Accord.Math.Random.Generator.Seed = 0;
// Sample data
// The following is a simple auto association function
// in which each input correspond to its own class. This
// problem should be easily solved using a Linear kernel.
// Sample input data
double[][] inputs =
{
new double[] { 0 },
new double[] { 3 },
new double[] { 1 },
new double[] { 2 },
};
// Output for each of the inputs
int[] outputs = { 0, 3, 1, 2 };
// Create a new Linear kernel
IKernel kernel = new Linear();
// Create a new Multi-class Support Vector Machine for one input,
// using the linear kernel and four disjoint classes.
var machine = new MulticlassSupportVectorMachine(1, kernel, 4);
// Create the Multi-class learning algorithm for the machine
var teacher = new MulticlassSupportVectorLearning(machine, inputs, outputs);
// Configure the learning algorithm to use SMO to train the
// underlying SVMs in each of the binary class subproblems.
teacher.Algorithm = (svm, classInputs, classOutputs, i, j) =>
new SequentialMinimalOptimization(svm, classInputs, classOutputs);
// Run the learning algorithm
double error = teacher.Run();
Assert.AreEqual(0, error);
Assert.AreEqual(0, machine.Compute(inputs[0]));
Assert.AreEqual(3, machine.Compute(inputs[1]));
Assert.AreEqual(1, machine.Compute(inputs[2]));
Assert.AreEqual(2, machine.Compute(inputs[3]));
}