Accord.NET (logo) MulticlassSupportVectorMachine Class Accord.NET Framework
Online Show table of contents (goes to the online documentation index).
One-against-one Multi-class Kernel Support Vector Machine Classifier.
Inheritance Hierarchy

Online System Object
  Accord.MachineLearning.VectorMachines MulticlassSupportVectorMachine

Namespace: Accord.MachineLearning.VectorMachines
Assembly: Accord.MachineLearning (in Accord.MachineLearning.dll) Version: (

public class MulticlassSupportVectorMachine : ISupportVectorMachine, 
	IEnumerable<KeyValuePair<Tuple<int, int>, KernelSupportVectorMachine>>, 
	IEnumerable, IDisposable

The Support Vector Machine is by nature a binary classifier. One of the ways to extend the original SVM algorithm to multiple classes is to build a one- against-one scheme where multiple SVMs specialize to recognize each of the available classes. By using a competition scheme, the original multi-class classification problem is then reduced to n*(n/2) smaller binary problems.

Currently this class supports only Kernel machines as the underlying classifiers. If a Linear Support Vector Machine is needed, specify a Linear kernel in the constructor at the moment of creation.



// Sample data 
//   The following is simple auto association function 
//   where each input correspond to its own class. This 
//   problem should be easily solved by 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 with one input, 
//  using the linear kernel and for 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();
See Also