Simple Bayes

A Simple Bayes (a.k.a. Naive Bayes) implementation in Elixir.
Features
- Multinomial Naive Bayes algorithm
- No external dependencies
- Ignores English stop words
- Additive smoothing
- TF-IDF
- Optional keywords weighting
API
bayes = SimpleBayes.init
|> SimpleBayes.train(:apple, "red sweet")
|> SimpleBayes.train(:apple, "green", weight: 0.5)
|> SimpleBayes.train(:apple, "round", weight: 2)
|> SimpleBayes.train(:banana, "sweet")
|> SimpleBayes.train(:banana, "green", weight: 0.5)
|> SimpleBayes.train(:banana, "yellow long", weight: 2)
|> SimpleBayes.train(:orange, "red")
|> SimpleBayes.train(:orange, "yellow sweet", weight: 0.5)
|> SimpleBayes.train(:orange, "round", weight: 2)
bayes |> SimpleBayes.classify_one("Maybe green maybe red but definitely round and sweet.")
# => :apple
bayes |> SimpleBayes.classify("Maybe green maybe red but definitely round and sweet.")
# => [
# apple: 0.18519202529366116,
# orange: 0.14447781772131096,
# banana: 0.10123406763124557
# ]
License
Licensed under MIT