Skip to content

Wrong prediction #3

@eveningkid

Description

@eveningkid

Hello,

I am trying to make a simple classification using SVM with the following snippet:

const SVM = require('ml-svm');

const X = [[-1, -1], [-2, -1], [1, 1], [2, 1]];
const y = [1, 1, 2, 2];

const model = new SVM({
  C: 1.0,
  tol: 0.0001,
});

model.train(X, y);
model.predict([[-0.8, -1]]);
// => sometimes -1 (wrong), sometimes 1 (correct)

I don't understand why it sometimes predict -1, which is not even an available class...
It happens randomly so I thought it may be related to whether or not the algorithm converged?

I really hope to use this library as it runs in React Native using plain JS (which libsvm doesn't)! :(

Do you know what could be the problem?

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions