Practical overview
When it fits
Use it when you want to add a locally integrated, example-trained text-labeling component to a browser or Node.js project and can provide labeled training samples.
Who it is for
- JavaScript developers building browser applications that need text labels
- Node.js developers creating text-classification utilities
Documented uses
- Train a classifier using sample text grouped by user-defined labels.
- Predict one or more labels for new text and read the associated confidence values.
- Serialize a trained model's data for storage and later reuse.
Requirements & limits
- The documented package installation methods are npm and yarn.
- The library supports browser and Node.js use and shows both ES module and CommonJS imports.
- Single-word terms are the default; nGramMin and nGramMax configure the n-gram range.
- The README describes model serialization for storing training data and reusing it for predictions.
- The project identifies its license as MIT.
Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.
Train a classifier and predict a text label
Install the library, train it with labeled examples, and request predictions for new text.
Before you start
- A JavaScript project using npm or yarn
- Text samples grouped under labels to train the classifier
Steps
Install the package with npm install ml-classify-text or yarn add ml-classify-text.
Import Classifier using an ES module or CommonJS import.
Create a Classifier instance and call train with each group of example texts and its label.
Pass new text to predict and inspect the returned labels and confidence values.
Expected outcome
The classifier returns predicted labels, with confidence values when predictions are available.
Guide limitations
- Predictions depend on the labeled examples used for training.
- The default representation uses single-word terms; n-gram sizes can be configured when sequences of words matter.
Sources & review
Source record details
- Source availability
- Active
- Sources checked
- 15 October 2026
- Original website title
- andreekeberg/ml-classify-text-js · Official homepage title · retained in its source language

