The Machine Learning Toolkit for JavaScript

JSMLT. An open-source easy-to-use machine learning library. Programmed entirely in JavaScript. We've got supervised learning, right inside your browser! And what's even better: we've got interactive, 2-dimensional visualizations of all classical machine learning algorithms, ready for use β€” why not take it for a spin straight away?

VisualML screenshot

Getting started

Installing JSMLT is really, really easy! It's available on npm, so to use it in your project you only have to run:

npm install @jsmlt/jsmlt

A simple classifier

Now that JSMLT is installed, you're ready to run your first machine learning scenario! In this example, we'll train a linear SVM on some dummy data, and make some predictions! All in all, we just need a few lines of code for this:

// Import JSMLT library
var jsmlt = require('@jsmlt/jsmlt');

// Training data
train_X = [[-1,-1], [-1,1], [1,1], [1,-1]];
train_y = [0, 0, 1, 1];

// Testing data
test_X = [[1,2], [1,-2], [-1,-2], [-1,2]];

// Create and train classifier
var clf = new jsmlt.Supervised.SVM.SVM({
  kernel: new jsmlt.Kernel.Linear(),
});
clf.train(train_X, train_y);

// Make predictions on test data
console.log(clf.predict(test_X));
Running this code will output the predictions for our 4 test data points:
[ 1, 1, 0, 0 ]

The entire npm package for running this code is available in the JSMLT examples repository. Clone it & run it!