Question

I have been trying to use jlibSVM I want to use it for multi output regression.

for example my : feature set / inputs will be x1,x2,x3 and outputs/target values will be y1,y2

Is this possible using the libSVM library ?

The API docs are not clear and there is not example app showing the use of jlibsvm so I tried to modify the code inside lexecyexec/svm_train.java

The author has originally just created the app to use one output/target value only .

this is seen in this part where the author tries to read the training file :

private void read_problem() throws IOException
    {
    BufferedReader fp = new BufferedReader(new FileReader(input_file_name));
    Vector<Float> vy = new Vector<Float>();
    Vector<SparseVector> vx = new Vector<SparseVector>();
    int max_index = 0;

    while (true)
        {
        String line = fp.readLine();
        if (line == null)
            {
            break;
            }

        StringTokenizer st = new StringTokenizer(line, " \t\n\r\f:");

        vy.addElement(Float.parseFloat(st.nextToken()));
        int m = st.countTokens() / 2;
        SparseVector x = new SparseVector(m);
        for (int j = 0; j < m; j++)
            {
            //x[j] = new svm_node();
            x.indexes[j] = Integer.parseInt(st.nextToken());
            x.values[j] = Float.parseFloat(st.nextToken());
            }
        if (m > 0)
            {
            max_index = Math.max(max_index, x.indexes[m - 1]);
            }
        vx.addElement(x);
        }

I tried to modify it so that the vector vy accepts a sparse vector with 2 values.

The program gets executed but the model file seems to be wrong.

Can anyone please verify if they have used jlibsvm for multiple output svm regression???

If yes can someone please explain how they achieved this ??

If no then does someone know of a similar svm implementation in Java ??

Was it helpful?

Solution

The classic SVM algorithm does not support multi dimensional outputs. One way to work around this would be to have a SVM model for each output dimension.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top