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

clustex

v1.1.3

Published

Clustex is a lightweight text classification package designed to efficiently categorize text based on similarity metrics and learned token weights.

Readme

Clustex Documentation

Clustex is a lightweight text classification package designed to efficiently categorize text based on similarity metrics and learned token weights.

Constructor

new Classifier(classifications: string[], learningRate?: number, threshold?: number)

Creates a new classifier instance.

  • Parameters:
    • classifications (string[]): An array of classification labels.
    • learningRate (number, optional): Influences how quickly token weights adjust. Default is 1.
    • threshold (number, optional): The minimum similarity score for tokens to influence classification. Default is 0.8.

Example:

const classifier = new Classifier(["positive", "negative"], 0.5, 0.9);

Methods

classify(text: string) → string

Determines the most probable classification for the provided text.

  • Parameters:
    • text (string): The input text to be classified.
  • Returns:
    • The classification label with the highest probability.

Example:

const classifier = new Classifier(["positive", "negative"]);
classifier.example("This is amazing!", "positive");
console.log(classifier.classify("Such a wonderful day!")); 
// Output: "positive"

chance(text: string) → Object

Returns an object with classification probabilities for the given text.

  • Parameters:
    • text (string): The input text to analyze.
  • Returns:
    • An object mapping classification labels to their probabilities.

Example:

const classifier = new Classifier(["spam", "normal"]);
classifier.example("Buy now!", "spam");
console.log(classifier.chance("Limited-time offer!"));
// Output: { spam: 0.85, normal: 0.15 }

example(text: string, classification: string) → Classifier

Trains the classifier with an example sentence and its corresponding classification.

  • Parameters:
    • text (string): The example sentence.
    • classification (string): The label associated with the sentence.
  • Returns:
    • The classifier instance (this) for method chaining.

Example:

const classifier = new Classifier(["positive", "negative"]);
classifier
  .example("This is fantastic!", "positive")
  .example("I hate this.", "negative");

stable(stableLearning: StableLearning) → Classifier

Applies a new config from a StableLearning instance to the instance.

  • Parameters:
    • stableLearning (StableLearning): StableLearning instance.
  • Returns:
    • The classifier instance (this) for method chaining.

Example:

const classifier = new Classifier(["positive", "negative"]);
const stable = new Classifier.StableLearning(classifier);
stable
  .example("This is fantastic!", "positive")
  .example("I hate this.", "negative");
classifier.stable(stable);

dataset(name: string, iterations: number = 1) → Classifier

Loads a predefined dataset and trains the classifier using its entries.

  • Parameters:
    • name (string): The dataset name.
    • iterations (number, optional): Number of training iterations. Defaults to 1.
  • Returns:
    • The classifier instance (this) for method chaining.

Example:

const classifier = new Classifier();
classifier.dataset("news", 3).classify("Breaking: new policy announced");

datasets

A static array listing available dataset names.

Example:

console.log(Classifier.datasets);
// Output: ["news", "spam", "tone", "importance"]

StableLearning

Classifier.StableLearning

A wrapper class that maintains a reversible training dataset and reinforces classifier stability through repeated forward and reverse passes.

Constructor:

new Classifier.StableLearning(classifier: Classifier)

Method:

example(text: string, classification: string) → this

Trains on an example while replaying all past examples (forward and reverse) to reinforce learning.

License

MIT License