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

inferrer

v0.3.0

Published

A simple and dependency-free support vector machine (SVM) library

Downloads

21

Readme

inferrer

A simple and dependency-free support vector machine (SVM) library

Build Status Coverage Status dependencies Status

Table of Contents

Installation

npm install inferrer --save

Using inferrer

First, require the module: const Inferrer = require("inferrer")

Or using the import spec: import Inferrer from "inferrer"

Basic Usage Example

Instantiate a new SVM, and train the SVM using training examples that can be classified in a binary fashion:

// The options passed to the SVM class are optional. Details below.
const XOR = new Inferrer({ kernel: "gaussian", gamma: 2 })

XOR.train([
  { input: [ 0, 0 ], classification: -1 },
  { input: [ 0, 1 ], classification: 1 },
  { input: [ 1, 0 ], classification: 1 },
  { input: [ 1, 1 ], classification: -1 }
])

It's important to note that all training/testing inputs must be lists of the same length, and every training input must have a classification thereunto pertaining.

Once the SVM is trained, classifying test inputs is accomplished thusly, using the classify method:

XOR.classify([ 0, 1 ])
// => 1
XOR.classify([ 0, 0 ])
// => -1

The classifyList method can be used to classify a list of test values:

XOR.classifyList([ [ 0, 0 ], [ 0, 1 ], [ 1, 0 ], [ 1, 1 ] ])
// => [ -1, 1, 1, -1 ]

The hyperplane/offset that results from the training inputs can be accessed using the following methods, respectively:

XOR.hyperplane()
XOR.offset()

Options

  • kernel: The type of SVM to be used. Defaults to linear.
    • linear: Best for data that is linearly separable.
    • gaussian: Best for noisy or oddly formed datasets.
  • c: "Strictness" of the SVM. Larger values create a stricter hyperplane. If data is noisy, it may be best to drop the value of c to create a hyperplane that best classifies the dataset. Defaults to 3

Advanced Options

  • tolerance: Tolerance of the SVM. Defaults to 0.001
  • gamma: This defines the "spread" of gaussian kernels. The larger the gamma value, the tighter the hyperplane will wrap positive values. Defaults to 0.1

To Do

  • [x] Basic Functionality
    • [x] Sequential Minimal Optimization Algorithm
    • [x] Classify, Hyperplane, and Offset Methods
    • [x] Defaults Values
    • [x] Classification on a List of Values
  • [ ] Kernel Functions
    • [x] Linear Kernel
    • [x] Gaussian Kernel (RBF)
    • [ ] Polynomial Kernel
  • [ ] Complete Test Suite

About

Basic information regarding support vector machines and this library

What is a SVM?

A support vector machine is a machine learning tool used primarily for binary classification and regression. It is a "supervised" machine learning technique, meaning the SVM requires training data to base classifications on. In many cases, a SVM is a more accurate classifier than an artificial neural network.

SMO

SMO, or sequential minimal optimization, is an algorithm for solving SVMs devised by John C. Platt. The original research paper is linked in the sources section. This library utilizes the SMO algorithm for training SVMs. The SMO algorithm was chosen because it is less memory intensive and requires less computing power than other SVM algorithms.

Sources

Sequential Minimal Optimization, John C. Platt

Support Vector Machines Succinctly, Alexandre Kowalczyk

Gaussian (Radial Basis Function) Kernel, University of Wisconsin

Contribute

I encourage opening issue tickets using the issue tracker. Please open a ticket on the issues page before submitting any pull requests to address said issue! For features and enhancements, please open a detailed, well formatted pull request outlining the necessity and benefit, as well as basic usage examples.

License

MIT © Cody Moncur