Ali
Ali

Reputation: 1678

Multi Label Support Vector Machine in Accord.NET

I am trying to make a Multi Label Support Vector Machine using Accord.NET framework (MultilabelSupportVectorMachine Class) but based on the example it's difficult to understand the encoding e.g.:

// Sample input data
double[][] inputs =
{
    new double[] { 0 },
    new double[] { 3 },
    new double[] { 1 },
    new double[] { 2 },
};

// Outputs for each of the inputs
int[][] outputs =
{
    new[] { -1,  1, -1 },
    new[] { -1, -1,  1 },
    new[] {  1,  1, -1 },
    new[] { -1, -1, -1 },
};

What if my output is a matrix which contains integer values not within the -1 and +1 range, what encoding should we use to convert the data into this format?

Upvotes: 1

Views: 518

Answers (1)

Emil Krumov
Emil Krumov

Reputation: 41

This is the format of the output the MultiLabelSupportVectorMachine would return if you compute something with it. MultiClassSupportVectorMachine returns a single int because it is used when you are sure that an example matches only a single class whereas MultiLabelSupportVectorMachine returns an array which shows which classes does the example match and is used when an example can match more classes.

It works like this: The output array length is between 0(inclusive) and the number of classes. So if you have 4 classes you'll have an output array like this:

{ -1, -1, 1, -1 }

This means that the output class is 2, because the index of 1 is 2. I hope that now you know how the output of this class works and that this gives you directions how to format your example output.

Additional info: If you want to use MultiLabelSupportVectorMachine, but you want to get only one output class you can just take the first index of 1 in the output array. I recommend this only if you are certain that One-Vs-All serves you better than One-Vs-One.

Upvotes: 1

Related Questions