Classifier reference

August 15, 2026 ยท View on GitHub

Feature reference for the classifier gem. Every example here runs against the version in this repository.

The README gives the short tour. These pages give the detail.

Command line

PageContents
classifierTrain, classify, and manage models from the shell
keywordsTF-IDF keyword extraction and term scores

Classifiers

PageUse it for
BayesFast probabilistic classification. The default choice
Logistic RegressionLinear classification with calibrated probabilities
LSISemantic similarity, search, related documents, and summaries
k-Nearest NeighborsClassification with the nearest examples and their votes

Vectorization

PageContents
TF-IDFTerm weights, n-grams, document frequency filters

Shared behavior

PageContents
PersistenceSave, load, storage backends, and custom backends
StreamingTraining on data larger than memory
ConfigurationGlobal settings and the native extension

Which classifier

Start with Bayes. It trains in one pass, needs no fit step, and handles most text classification tasks.

  • Choose Logistic Regression when you need a probability per category, and you accept a fit step after training.
  • Choose LSI when you need similarity, search, or related documents, and not only a label.
  • Choose k-Nearest Neighbors when you want to see which examples drove the answer.
  • Choose TF-IDF when you want term weights rather than a category.