
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
A simple and dependency-free support vector machine (SVM) library
npm install inferrer --save
First, require the module:
const Inferrer = require("inferrer")
Or using the import
spec:
import Inferrer from "inferrer"
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()
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
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
Basic information regarding support vector machines and this library
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, 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.
Sequential Minimal Optimization, John C. Platt
Support Vector Machines Succinctly, Alexandre Kowalczyk
Gaussian (Radial Basis Function) Kernel, University of Wisconsin
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.
MIT © Cody Moncur
FAQs
A simple and dependency-free support vector machine (SVM) library
The npm package inferrer receives a total of 10 weekly downloads. As such, inferrer popularity was classified as not popular.
We found that inferrer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.