npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nlearn

v0.4.0

Published

Supervised machine learning tools for nodejs

Downloads

8

Readme

CI Status

NPM

Advantages

  • Pure JS implementation
  • .d.ts file is provided for implementing in your TypeScript project
  • Internal computations implemented with Float64Array for performance

Alternative Libraries

  • ml-js: Implements more learning models currently. However, a number of native dependencies are required
  • node-svm: Implements SVM classifier only, while nlearn is designed to provide a consistent interface for multiple classifiers
  • node-fann: Again, a single classifier type. Also depends on native libraries with special installation requirements.
  • machine_learning: Implements many supervised learning models. You might want to choose this for now until this library is robust enough.

Basic Usage

var nlearn = require("nlearn");
var Example = nlearn.Example;
var BinaryLabel = nlearn.BinaryLabel;

var data = [
            new Example(new Float64Array([1,2,3]), BinaryLabel.UP),
            new Example(new Float64Array([1,3,7]), BinaryLabel.DOWN),
            new Example(new Float64Array([4,5,8]), BinaryLabel.DOWN)
            ];

var kernel = new nlearn.RbfKernel(10);

var classifier = nlearn.SvmFactory.create(kernel);
classifier.fit(data);
var label = classifier.classify([1,2,3]); //BinaryLabel.UP

Choosing a Best Fit Classifier

Some classifiers will fit your data better than others. You can use an Optimizer to run analysis on a set of classifier parameters and choose the best fit. Note that using the optimizer will partition your training data set, so the effective training set is cut in half.

var tolerance = new nlearn.GeometricRangeIterator(new nlearn.ImmutableRange(1e-10, 1e-3), 10);
var alphaTolerance = new nlearn.GeometricRangeIterator(new nlearn.ImmutableRange(1e-10, 1e-3), 10);
var C = new nlearn.GeometricRangeIterator(new nlearn.ImmutableRange(0.1, 1000), 10);
var kernels = [new nlearn.LinearKernel(), new nlearn.RbfKernel(1), new nlearn.RbfKernel(10)];
var kernelIterator = new nlearn.ArrayIterator(kernels);
var optimizer = new nlearn.SvmOptimizer(kernelIterator, tolerance, alphaTolerance, C);

var data = [];
data.push(new Example(new Float64Array([4,4,6,8]), BinaryLabel.UP));
data.push(new Example(new Float64Array([5,4,6,8]), BinaryLabel.UP));
data.push(new Example(new Float64Array([6,4,6,8]), BinaryLabel.UP));
data.push(new Example(new Float64Array([1,4,6,8]), BinaryLabel.DOWN));
data.push(new Example(new Float64Array([2,4,6,8]), BinaryLabel.DOWN));
data.push(new Example(new Float64Array([3,4,6,8]), BinaryLabel.DOWN));
var classifier = optimizer.optimize(data);