OpenViSTAI · Agents · Blockchain · Crypto
Menu
AI Models

Simple Bayes

Simple Bayes is an Elixir library that implements Naive Bayes classifiers for probabilistic machine-learning classification, including text categorization. It supports multinomial, binarized multinomial and Bernoulli models, with in-memory, file-system and DETS storage options.

Independent OpenViST project profile, based on linked sources.

Simple Bayes — Text categorization using labeled examples
OpenViST project illustration. See the linked sources for product details.
Understand the project

Practical overview

When it fits

Use it when an Elixir application needs a Naive Bayes text-classification component and its documented models, text options and storage choices suit the task.

Who it is for

  • Elixir developers adding text classification to an application.
  • Teams choosing among the library's Naive Bayes model and storage options.

Documented uses

  • Train a classifier from text examples paired with category labels.
  • Return one predicted category or ranked category scores for an input text.
  • Configure text-processing options such as stop words, stemming, TF-IDF or keyword weighting where supported by the selected model.
  • Save and reload classifier state using file-system or DETS storage, or use encoded in-memory data with an application's own persistence.
Before you choose

Requirements & limits

The project is publicly available on GitHub and identified as open source.

  • Choose among multinomial, binarized multinomial and Bernoulli; the README's feature matrix shows that TF-IDF and keyword weighting are listed for multinomial only.
  • In-memory storage is the default; file-system and DETS storage require a file path.
  • Stemming requires a stem function, with Stemmer recommended as an optional dependency.
  • For Elixir 1.3 or earlier, the README documents starting the library and optional Stemmer in the application configuration.

Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.

Source-based practical guide

Train a text classifier and retrieve category scores

Add the library to an Elixir project, train labeled text examples and classify a text input.

Before you start

  • An Elixir project using Mix.
  • Add :simple_bayes version ~> 0.12 to the deps list in mix.exs.

Steps

  1. Add :simple_bayes to the project's Mix dependencies.

  2. Initialize a model with SimpleBayes.init().

  3. Train it with text examples paired with category labels using SimpleBayes.train/3.

  4. Pass text to SimpleBayes.classify/2 for category scores, or use SimpleBayes.classify_one/2 for one category.

Expected outcome

A trained in-memory classifier that returns a category prediction or a list of category scores for supplied text.

Guide limitations

  • The example uses in-memory storage; other storage configurations require their documented options.
  • Stemming requires a stem function; the README recommends the separate Stemmer package.
Source-based practical guide

Save and reload a classifier with file-system storage

Configure a file path, save a trained classifier, reload it, add more training examples and classify text.

Before you start

  • An Elixir project with :simple_bayes in its Mix dependencies.
  • A file path to configure for file-system storage.

Steps

  1. Initialize the library with storage: :file_system and a file_path.

  2. Train the model with labeled text examples and call SimpleBayes.save().

  3. Load the model using the same storage options, then continue training and save again.

  4. Load the saved model and pass text to SimpleBayes.classify/2.

Expected outcome

A classifier whose saved state can be loaded to continue training and classify text.

Guide limitations

  • The documented file-system example requires a configured file path.
  • The README describes storage options but does not specify behavior for every file-system environment.
Evidence and transparency

Sources & review

Source record details
Source availability
Active
Sources checked
15 November 2026
Original website title
fredwu/simple_bayes · Official homepage title · retained in its source language