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

@hazeljs/ml

v2.0.7

Published

Machine Learning & Model Management for HazelJS framework

Readme

@hazeljs/ml

Machine Learning & Model Management for HazelJS - training, prediction, model registry, built-in classical algorithms, metrics, feature store, experiments, and drift monitoring.

npm version npm downloads License: Apache-2.0

Features

  • Built-in algorithms – TF-IDF, Naive Bayes, Logistic Regression, Isolation Forest, Cosine k-NN, Item-Item CF (pure TypeScript, zero ML deps)
  • Built-in models@Model wrappers ready for MLModule.forRoot({ models: [...] })
  • Model registry – Register/discover models by name@version; optional JSON artifact persistence
  • Decorators@Model, @Train, @Predict, @Experiment
  • TrainingTrainerService runs named PipelineService pipelines from @Train({ pipeline }) and auto-logs @Experiment runs
  • InferencePredictorService + BatchService
  • Metrics – accuracy/P/R/F1, confusion matrix, MAE/MSE/RMSE/R², ROC-AUC, Brier
  • Feature store / experiments / drift – wired into MLModule (PSI, KS, JSD, Wasserstein, chi², concept-shift helper)
  • Framework-agnostic – bring your own TensorFlow.js / ONNX / Transformers.js model class; the package does not bundle those runtimes

Installation

npm install @hazeljs/ml @hazeljs/core
# optional: validate/profile training data with @hazeljs/data
npm install @hazeljs/data

Quick Start (built-in text classifier)

import { HazelApp } from '@hazeljs/core';
import { MLModule, TextNaiveBayesModel, TrainerService, PredictorService } from '@hazeljs/ml';

const app = new HazelApp({
  imports: [
    MLModule.forRoot({
      models: [TextNaiveBayesModel],
      artifactDir: './models',
      experiments: { storage: 'memory' },
    }),
  ],
});

app.listen(3000);

// Train
await trainer.train('text-naive-bayes', {
  samples: [
    { text: 'great product', label: 'positive' },
    { text: 'terrible quality', label: 'negative' },
  ],
});

// Predict
const result = await predictor.predict('text-naive-bayes', { text: 'I love this' });

Built-in models

| Model name | Class | Use case | | -------------------------- | ----------------------------- | --------------------------------- | | text-naive-bayes | TextNaiveBayesModel | Ticket/chat routing, spam, intent | | text-logistic-regression | TextLogisticRegressionModel | Binary/multi-class text | | isolation-forest | IsolationForestModel | Fraud / outlier detection | | cosine-knn | CosineKnnModel | Similar tickets / k-NN | | item-item-cf | ItemItemCFModel | Recommendations | | entity-resolver | EntityResolverModel | Duplicate customers / fuzzy match | | holt-winters | HoltWintersModel | Demand / wait-time forecast | | kmeans | KMeansModel | Segmentation / clustering | | decision-tree | DecisionTreeModel | Interpretable tabular classify |

Algorithms are also exported directly (TfidfVectorizer, NaiveBayesClassifier, jaroWinkler, HoltWinters, KMeans, DecisionTreeClassifier, …) for use without decorators.

Training pipelines vs @hazeljs/data

PipelineService in @hazeljs/ml is preprocess-only (normalize/filter samples before train). For production ETL (connectors, quality, sinks), use @hazeljs/data PipelineRunner / PipelineBuilder, then pass cleaned samples to TrainerService via prepareTrainingData().

Training with @hazeljs/data

import { Schema, QualityService } from '@hazeljs/data';
import { prepareTrainingData, TrainerService } from '@hazeljs/ml';

const SampleSchema = Schema.object({
  text: Schema.string().min(1),
  label: Schema.string().oneOf(['positive', 'negative']),
});

const prepared = await prepareTrainingData(
  { samples },
  { schema: SampleSchema, qualityService: new QualityService(), failOnQuality: true }
);
await trainer.train('text-naive-bayes', prepared.data);

API summary

| Service | Purpose | | --------------------- | ------------------------------------------- | | ModelRegistry | Register/lookup models; save/load artifacts | | TrainerService | Invoke @Train (+ pipeline + experiment) | | PredictorService | Invoke @Predict | | PipelineService | Preprocess-only training pipelines | | BatchService | Ordered concurrent batch prediction | | MetricsService | Evaluation + metric history | | FeatureStoreService | Online/offline feature retrieval | | ExperimentService | Experiment/run/metric tracking | | DriftService | Distribution drift detection | | MonitorService | Periodic drift/accuracy alerts + webhooks |

Examples

Links