Repolode
cardmagic

cardmagic/classifier

A Ruby text classification gem offering Naive Bayes, LSI, k-Nearest Neighbors, Logistic Regression and TF-IDF, with CLI tools.

Stars
741
Forks
124
Open issues
9
Last commit
7 days ago

What is it?

Classifier is a Ruby gem for text classification. It bundles five approaches: Naive Bayes, Latent Semantic Indexing (LSI), k-Nearest Neighbors, Logistic Regression, and TF-IDF vectorization, so you can pick a method that fits your data and task.

The gem includes a native C extension for LSI operations, with a pure Ruby fallback when the extension is unavailable. LSI supports incremental document addition using Brand's algorithm, avoiding a full index rebuild on each new document. Training can stream from large files, and trained models can be persisted to files, Redis, S3, SQL databases, or custom storage.

It also installs two command line tools. The `classifier` command runs pre-trained models such as spam or sentiment detection, or trains and applies your own models. The `keywords` command fits a TF-IDF vocabulary and scores term importance in text.

Key features

  • 01Five classifiers: Naive Bayes, LSI, k-Nearest Neighbors, Logistic Regression, and TF-IDF.
  • 02Incremental LSI that adds documents without a full index rebuild.
  • 03Native C extension for LSI with a pure Ruby fallback.
  • 04Streaming training for large datasets.
  • 05Pluggable persistence to file, Redis, S3, SQL, or custom storage.
  • 06Command line tools `classifier` and `keywords`, including pre-trained models.

Use cases

  • Filtering spam or classifying support messages inside a Ruby application.
  • Running sentiment or emotion detection from the command line with pre-trained models.
  • Finding similar documents with LSI for simple search or recommendation.
  • Extracting distinctive keywords from articles or corpora with TF-IDF.

Quick start

  1. 1

    Add the gem to your Gemfile

    gem 'classifier'
  2. 2

    Or install the CLI via Homebrew

    brew install classifier
  3. 3

    Classify text with a pre-trained model

    classifier -r sms-spam-filter "You won a free iPhone"

Things to know

  • The native C extension speeds up LSI, and the gem falls back to pure Ruby when it is unavailable.

In collections

Topics

#text-classification#naive-bayes#machine-learning#tf-idf#lsi#ruby-gem#nlp#classification#classification-algorithm#machine-learning-algorithms

FAQ

What is classifier?
A Ruby text classification gem offering Naive Bayes, LSI, k-Nearest Neighbors, Logistic Regression and TF-IDF, with CLI tools. Classifier is a Ruby gem for text classification. It bundles five approaches: Naive Bayes, Latent Semantic Indexing (LSI), k-Nearest Neighbors, Logistic Regression, and TF-IDF vectorization, so you can pick a method that fits your data and task.
Is classifier free to use? What license does it have?
classifier is open source under the Other license. Check the license terms before using it in commercial products.
Is classifier still maintained?
Actively maintained. The last commit to classifier was on Oct 31, 2026.
What can I use classifier for?
Filtering spam or classifying support messages inside a Ruby application. Running sentiment or emotion detection from the command line with pre-trained models. Finding similar documents with LSI for simple search or recommendation. Extracting distinctive keywords from articles or corpora with TF-IDF.
How do I install classifier?
Add the gem to your Gemfile: gem 'classifier' Or install the CLI via Homebrew: brew install classifier Classify text with a pre-trained model: classifier -r sms-spam-filter "You won a free iPhone"
Where can I get classifier?
The source code and installation instructions are on GitHub: https://github.com/cardmagic/classifier

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects