Simple Bayes v1.0.0 SimpleBayes.Classifier.Probability

Link to this section Summary

Functions

Calculates the probabilities for the categories based on the training set

Link to this section Functions

Link to this function for_collection(data, model, categories_map)

Calculates the probabilities for the categories based on the training set.

Examples

iex> SimpleBayes.Classifier.Probability.for_collection(
iex>   %SimpleBayes{
iex>     categories: %{
iex>       cat: [trainings: 1, tokens: %{"nice" => 1, "cute" => 1, "cat" => 1}],
iex>       dog: [trainings: 3, tokens: %{"nice" => 2, "dog" => 3, "cute" => 3}]
iex>     },
iex>     trainings: 4,
iex>     tokens: %{"nice" => 3, "cute" => 4, "cat" => 1, "dog" => 3},
iex>     tokens_per_training: %{
iex>       {:cat, %{"nice" => 1, "cute" => 1, "cat" => 1}} => nil,
iex>       {:dog, %{"nice" => 2, "dog" => 2}} => nil,
iex>       {:dog, %{"cute" => 1, "dog" => 1}} => nil,
iex>       {:dog, %{"cute" => 2}} => nil
iex>     }
iex>   },
iex>   :multinomial,
iex>   %{"cute" => 4, "good" => 0}
iex> )
%{cat: 0.013944237739606595, dog: 0.10054155931755744}