Détail du package

ml-svm

mljs241MIT2.1.2

Support Vector Machine in Javascript

super, vector, machine, data

readme

ml-svm

NPM version build status David deps npm download

Support Vector Machine in Javascript

Installation

npm install ml-svm

API

API documentation

Example

// Instantiate the svm classifier
var SVM = require('ml-svm');

var options = {
  C: 0.01,
  tol: 10e-4,
  maxPasses: 10,
  maxIterations: 10000,
  kernel: 'rbf',
  kernelOptions: {
    sigma: 0.5
  }
};

var svm = new SVM(options);

// Train the classifier - we give him an xor
var features = [[0,0],[0,1],[1,1],[1,0]];
var labels = [1, -1, 1, -1];
svm.train(features, labels);

// Let's see how narrow the margin is
var margins = svm.margin(features);

// Let's see if it is separable by testing on the training data
svm.predict(features); // [1, -1, 1, -1]

// I want to see what my support vectors are
var supportVectors = svm.supportVectors();

// Now we want to save the model for later use
var model = svm.toJSON();

/// ... later, you can make predictions without retraining the model
var importedSvm = SVM.load(model);
importedSvm.predict(features); // [1, -1, 1, -1]

Authors

License

MIT

changelog

2.1.2 (2016-08-16)

Bug Fixes

  • put iris dataset as a dev dependency (77e0c5a)

2.1.1 (2016-07-27)

2.1.0 (2016-07-26)

2.0.1 (2016-07-25)

Bug Fixes

  • don't update alpha if it has not changed much (0b951dd)

2.0.0 (2016-07-24)

Features

  • add option to provide a RNG (ae28d35)

1.0.2 (2015-07-03)