cardmagic/classifier
A general classifier module to allow Bayesian and LSI classifications.
What it solves
It provides a set of tools for text classification and term importance scoring in Ruby, allowing developers to categorize text (such as detecting spam or sentiment) or extract key terms without needing to build complex machine learning pipelines from scratch.
How it works
The library implements five different algorithms to handle various classification needs:
- Bayesian: Fast, single-pass training for general classification.
- Logistic Regression: Provides calibrated probabilities for each category.
- LSI (Latent Semantic Indexing): Focuses on similarity and search, utilizing a native C extension for high performance and Brand's algorithm for incremental updates without full index rebuilds.
- k-Nearest Neighbors (KNN): Classifies based on the most similar training examples.
- TF-IDF: Scores the importance of terms relative to a corpus rather than assigning a category.
It includes a command-line interface (CLI) for instant classification using pre-trained models and a pluggable persistence system to save models to files, Redis, S3, or SQL databases.
Who it’s for
- Ruby developers needing to integrate text classification into their applications.
- Users who want a simple CLI tool to analyze text or extract keywords without writing code.
- Developers working with large datasets who require streaming training support to avoid memory exhaustion.
Highlights
- Multiple Algorithms: Supports Bayes, Logistic Regression, LSI, KNN, and TF-IDF.
- High Performance: Native C extensions make LSI operations 5-50x faster than pure Ruby.
- Incremental LSI: Ability to add new documents to an LSI index without rebuilding the entire index.
- Streaming Support: Can train on multi-gigabyte datasets by streaming data instead of loading it all into memory.
- Flexible Persistence: Pluggable storage options including S3, Redis, and SQL.
Related
- Project
- Project
- Project
- Project
- Project