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.
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.
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_bayesversion~> 0.12to thedepslist inmix.exs.
Steps
Add
:simple_bayesto the project's Mix dependencies.Initialize a model with
SimpleBayes.init().Train it with text examples paired with category labels using
SimpleBayes.train/3.Pass text to
SimpleBayes.classify/2for category scores, or useSimpleBayes.classify_one/2for 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.
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_bayesin its Mix dependencies. - A file path to configure for file-system storage.
Steps
Initialize the library with
storage: :file_systemand afile_path.Train the model with labeled text examples and call
SimpleBayes.save().Load the model using the same storage options, then continue training and save again.
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.
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

