emel v0.3.0 Emel.Ml.NaiveBayes View Source
A simple probabilistic classifier based on applying Bayes’ theorem with naive independence assumptions between the features. It makes classifications using the maximum posteriori decision rule in a Bayesian setting.
Link to this section Summary
Functions
Returns the function that classifies an item by using the Naive Bayes Algorithm
Link to this section Functions
Returns the function that classifies an item by using the Naive Bayes Algorithm.
Examples
iex> f = Emel.Ml.NaiveBayes.classifier([
...> %{outlook: "Sunny", temperature: "Hot", humidity: "High", wind: "Weak", decision: "No"},
...> %{outlook: "Sunny", temperature: "Hot", humidity: "High", wind: "Strong", decision: "No"},
...> %{outlook: "Overcast", temperature: "Hot", humidity: "High", wind: "Weak", decision: "Yes"},
...> %{outlook: "Rain", temperature: "Mild", humidity: "High", wind: "Weak", decision: "Yes"},
...> %{outlook: "Rain", temperature: "Cool", humidity: "Normal", wind: "Weak", decision: "Yes"},
...> %{outlook: "Rain", temperature: "Cool", humidity: "Normal", wind: "Strong", decision: "No"},
...> %{outlook: "Overcast", temperature: "Cool", humidity: "Normal", wind: "Strong", decision: "Yes"},
...> %{outlook: "Sunny", temperature: "Mild", humidity: "High", wind: "Weak", decision: "No"},
...> %{outlook: "Sunny", temperature: "Cool", humidity: "Normal", wind: "Weak", decision: "Yes"},
...> %{outlook: "Rain", temperature: "Mild", humidity: "Normal", wind: "Weak", decision: "Yes"},
...> %{outlook: "Sunny", temperature: "Mild", humidity: "Normal", wind: "Strong", decision: "Yes"},
...> %{outlook: "Overcast", temperature: "Mild", humidity: "High", wind: "Strong", decision: "Yes"},
...> %{outlook: "Overcast", temperature: "Hot", humidity: "Normal", wind: "Weak", decision: "Yes"},
...> %{outlook: "Rain", temperature: "Mild", humidity: "High", wind: "Strong", decision: "No"}
...> ], [:outlook, :temperature, :humidity, :wind], :decision)
...> f.(%{outlook: "Sunny", temperature: "Mild", humidity: "Normal", wind: "Strong"})
"Yes"