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 🙏

© 2026 – Pkg Stats / Ryan Hefner

ai-workbench.js

v1.0.0

Published

Dependency-free machine-learning algorithms, preprocessing, semi-supervised learning, and finite-MDP reinforcement learning for JavaScript.

Readme

ai-workbench.js

CI npm version license zero dependencies

A dependency-free machine-learning library for JavaScript, Node.js, and modern browsers. It provides 70 algorithms, tabular preprocessing, model evaluation, CSV tools, 20 datasets, and 10 finite-MDP control environments through a consistent API.

ai-workbench.js is designed for teaching, transparent experimentation, engineering prototypes, browser applications, and projects that need readable implementations without a native-code toolchain.

Highlights

  • 18 regression, 17 classification, 8 clustering, and 7 anomaly-detection estimators
  • 9 semi-supervised classifiers for partially labeled data
  • 11 reinforcement-learning and dynamic-programming algorithms
  • Numeric scalers and mixed-type preprocessing with imputation and one-hot encoding
  • Train/test splitting, cross-validation, metrics, CSV parsing, and dataset loading
  • CommonJS, ESM, TypeScript declarations, and a standalone browser bundle
  • Deterministic random seeds and independent estimator instances
  • No runtime dependencies

Installation

npm install ai-workbench.js

Node.js 18 or later is supported. The browser build works in current evergreen browsers.

Focused entry points

The root package exposes the complete API. Applications can also import a focused module to make dependencies and intent explicit:

import { RandomForestClassifier } from 'ai-workbench.js/estimators';
import { StandardScaler } from 'ai-workbench.js/preprocessing';
import { accuracyScore } from 'ai-workbench.js/metrics';
import { trainTestSplit } from 'ai-workbench.js/model-selection';
import { RLAgent } from 'ai-workbench.js/reinforcement';

Available subpaths are estimators, preprocessing, metrics, model-selection, csv, datasets, pipeline, semi-supervised, reinforcement, and registry.

Quick start

ESM

import {
  StandardScaler,
  LogisticRegression,
  accuracyScore,
  trainTestSplit
} from 'ai-workbench.js';

const X = [
  [0.1, 1.2], [0.2, 0.9], [0.4, 1.1],
  [2.7, 3.1], [3.0, 2.8], [3.2, 3.4]
];
const y = ['normal', 'normal', 'normal', 'fault', 'fault', 'fault'];

const split = trainTestSplit(X, y, {
  testSize: 0.33,
  randomState: 42,
  stratify: true
});

const scaler = new StandardScaler().fit(split.XTrain);
const model = new LogisticRegression({ randomState: 42 })
  .fit(scaler.transform(split.XTrain), split.yTrain);

const prediction = model.predict(scaler.transform(split.XTest));
console.log(accuracyScore(split.yTest, prediction));

CommonJS

const ai = require('ai-workbench.js');

const model = new ai.RandomForestRegressor({
  n_estimators: 120,
  max_depth: 10,
  randomState: 7
});

model.fit(XTrain, yTrain);
console.log(model.predict(XTest));

Browser

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/ai-workbench.js"></script>
<script>
  const model = new AIWorkbench.KMeans({
    n_clusters: 3,
    n_init: 10,
    randomState: 42
  });

  const labels = model.fitPredict([
    [0.0, 0.1], [0.2, -0.1],
    [5.0, 5.1], [5.2, 4.9],
    [10.0, 0.0], [10.2, 0.1]
  ]);

  console.log(labels);
</script>

Mixed-type records

import { TabularPipeline, RandomForestClassifier } from 'ai-workbench.js';

const rows = [
  { temperature: 65, vibration: 0.12, machine: 'A', state: 'normal' },
  { temperature: 89, vibration: 0.83, machine: 'B', state: 'fault' },
  { temperature: 70, vibration: null, machine: 'A', state: 'normal' },
  { temperature: 94, vibration: 0.91, machine: 'B', state: 'fault' }
];

const pipeline = new TabularPipeline(
  new RandomForestClassifier({ n_estimators: 80, randomState: 42 }),
  { preprocessing: { scaler: 'standard' } }
);

pipeline.fit(rows, 'state');
console.log(pipeline.predictOne({ temperature: 92, vibration: 0.88, machine: 'B' }));

Semi-supervised learning

Use null, undefined, an empty string, ?, or -1 for an unknown label.

import { SemiSupervisedClassifier } from 'ai-workbench.js';

const model = new SemiSupervisedClassifier('knn_label_spreading', {
  n_neighbors: 8,
  alpha: 0.2,
  max_iter: 100
});

model.fit(X, ['A', null, null, 'B', null, 'B']);
console.log(model.transducedLabels);
console.log(model.predict([[0.3, 0.7]]));

Reinforcement learning

import { RLAgent } from 'ai-workbench.js';

const agent = new RLAgent('q_learning', {
  episodes: 1200,
  alpha: 0.15,
  gamma: 0.95,
  epsilon: 0.2,
  seed: 42
}).fit('maintenance');

console.log(agent.getPolicy());
console.log(agent.evaluate({ seed: 100 }));

Custom finite Markov decision processes are supported through createFiniteMDP(). See Reinforcement learning.

Algorithm catalog

| Area | Count | |---|---:| | Regression | 18 | | Classification | 17 | | Clustering | 8 | | Anomaly detection | 7 | | Semi-supervised learning | 9 | | Reinforcement learning and planning | 11 | | Total | 70 |

Use the registry at runtime:

import { listAlgorithms, getAlgorithmInfo, listEnvironments } from 'ai-workbench.js';

console.table(listAlgorithms({ task: 'classification' }));
console.log(getAlgorithmInfo('random_forest', 'classification'));
console.table(listEnvironments());

The complete catalog and default parameters are listed in Algorithms.

Validation

The release process includes:

  • catalog tests that instantiate and run every algorithm;
  • API, preprocessing, browser-bundle, dataset, semi-supervised, and RL tests;
  • selected numerical comparisons with scikit-learn using identical data and splits;
  • known-result checks for deterministic finite MDPs;
  • package, metadata, and browser-global checks.

Run everything locally:

npm ci
npm run check

The Version 1.0.0 release passed 82 automated tests and 16 selected external or analytical checks. Reference validation is selective rather than a claim that every implementation is numerically identical to another library. See Validation for methods and limitations and the release validation report for the recorded results.

Documentation

Scope and limitations

ai-workbench.js uses dense in-memory arrays and prioritizes inspectable implementations and broad browser compatibility. It is well suited to small and medium tabular problems, demonstrations, engineering prototypes, and algorithm study. For very large datasets, sparse high-dimensional data, distributed training, GPU acceleration, or safety-critical deployment, use a specialized numerical stack and an independent verification process.

Model snapshots reconstruct a fitted estimator from its stored training data and parameters. They are deterministic reconstruction records, not a compact binary model format. See the API reference for details.

Project history

The numerical engines were originally developed for AI-Engineer Workbench and reorganized into this standalone library so they can be imported independently, tested outside the website, and extended by other developers.

Contributing

Bug reports, validation cases, documentation improvements, and new algorithms are welcome. Read CONTRIBUTING.md before opening a pull request.

Citation

Research and teaching users may cite the software using CITATION.cff.

License

The source code is available under the MIT License. Bundled datasets may have separate attribution or reuse terms. See DATA_LICENSES.md before redistributing dataset files.