Simple Bayes v0.7.1 SimpleBayes.Accumulator

Summary

Functions

Accumulates the values from the map

Accumulates the number of maps containing the specified key

Accumulates the values of the given keys from the map

Functions

all(map)

Accumulates the values from the map.

Examples

iex> SimpleBayes.Accumulator.all(%{"nice" => 3, "cute" => 1, "cat" => 1, "dog" => 2})
7

iex> SimpleBayes.Accumulator.all(%{"nice" => 3.5, "cute" => 1, "cat" => 1, "dog" => 2.2})
7.7

iex> SimpleBayes.Accumulator.all(%{})
1
occurance(meta_map, key)

Accumulates the number of maps containing the specified key.

Examples

iex> SimpleBayes.Accumulator.occurance(%{
iex>   {:cat, %{"nice" => 1, "cute" => 1, "cat" => 1}} => nil,
iex>   {:dog, %{"nice" => 2, "dog" => 2}} => nil
iex> }, "cute")
1

iex> SimpleBayes.Accumulator.occurance(%{
iex>   {:cat, %{"nice" => 1, "cute" => 1, "cat" => 1}} => nil,
iex>   {:dog, %{"nice" => 2, "dog" => 2}} => nil
iex> }, "nice")
2
only(map, keys)

Accumulates the values of the given keys from the map.

Examples

iex> SimpleBayes.Accumulator.only(%{"nice" => 3, "cute" => 1, "cat" => 1, "dog" => 2}, ["nice", "cute"])
4

iex> SimpleBayes.Accumulator.only(%{"nice" => 3.5, "cute" => 1, "cat" => 1, "dog" => 2.2}, ["nice", "cute"])
4.5