naive_bayes v0.1.2 NaiveBayes
An implementation of Naive Bayes
Summary
Functions
Set the assume_uniform constant
Returns a list of probabilities of classes given a list of tokens
Initializes a new NaiveBayes agent
Allows removal of low frequency words that increase processing time and may overfit
Increase smoothing constant to dampen the effect of the rare tokens
Trains the naive bayes instance given a list of tokens and categories
Functions
Set the assume_uniform constant.
Returns {:ok}
Examples
iex> nbayes |> NaiveBayes.assume_uniform(true)
:ok
Returns a list of probabilities of classes given a list of tokens.
Examples
iex> results = nbayes |> NaiveBayes.classify( ["a", "b", "c"] )
%{"HAM" => 0.4832633319857435, "SPAM" => 0.5167366680142564}
Initializes a new NaiveBayes agent
Returns {:ok, pid}
.
Examples
iex> {:ok, nbayes} = NaiveBayes.new(binarized: false, assume_uniform: true, smoothing: 2)
{:ok, #PID<0.137.0>}
Allows removal of low frequency words that increase processing time and may overfit
Returns {:ok}
Examples
iex> nbayes |> NaiveBayes.purge_less_than(5)
:ok
Increase smoothing constant to dampen the effect of the rare tokens
Returns {:ok}
Examples
iex> nbayes |> NaiveBayes.set_smoothing(2)
:ok