Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Naive Bayes classifier
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
====Testing==== Below is a sample to be classified as male or female. {| class="wikitable" |- ! Person !! height (feet) !! weight (lbs) !! foot size (inches) |- | sample || 6 || 130 || 8 |} In order to classify the sample, one has to determine which posterior is greater, male or female. For the classification as male the posterior is given by <math display="block"> \text{posterior (male)} = \frac{P(\text{male}) \, p(\text{height} \mid \text{male}) \, p(\text{weight} \mid \text{male}) \, p(\text{foot size} \mid \text{male})}{\text{evidence}} </math> For the classification as female the posterior is given by <math display="block"> \text{posterior (female)} = \frac{P(\text{female}) \, p(\text{height} \mid \text{female}) \, p(\text{weight} \mid \text{female}) \, p(\text{foot size} \mid \text{female})}{\text{evidence}} </math> The evidence (also termed normalizing constant) may be calculated: <math display="block">\begin{align} \text{evidence} = P(\text{male}) \, p(\text{height} \mid \text{male}) \, p(\text{weight} \mid \text{male}) \, p(\text{foot size} \mid \text{male}) \\ + P(\text{female}) \, p(\text{height} \mid \text{female}) \, p(\text{weight} \mid \text{female}) \, p(\text{foot size} \mid \text{female}) \end{align}</math> However, given the sample, the evidence is a constant and thus scales both posteriors equally. It therefore does not affect classification and can be ignored. The [[probability distribution]] for the sex of the sample can now be determined: <math display="block">P(\text{male}) = 0.5</math> <math display="block">p({\text{height}} \mid \text{male}) = \frac{1}{\sqrt{2\pi \sigma^2}}\exp\left(\frac{-(6-\mu)^2}{2\sigma^2}\right) \approx 1.5789,</math> where <math>\mu = 5.855</math> and <math>\sigma^2 = 3.5033 \cdot 10^{-2}</math> are the parameters of normal distribution which have been previously determined from the training set. Note that a value greater than 1 is OK here β it is a probability density rather than a probability, because ''height'' is a continuous variable. <math display="block">p({\text{weight}} \mid \text{male}) = \frac{1}{\sqrt{2\pi \sigma^2}}\exp\left(\frac{-(130-\mu)^2}{2\sigma^2}\right) = 5.9881 \cdot 10^{-6}</math> <math display="block">p({\text{foot size}} \mid \text{male}) = \frac{1}{\sqrt{2\pi \sigma^2}}\exp\left(\frac{-(8-\mu)^2}{2\sigma^2}\right) = 1.3112 \cdot 10^{-3}</math> <math display="block">\text{posterior numerator (male)} = \text{their product} = 6.1984 \cdot 10^{-9}</math> <math display="block">P({\text{female}}) = 0.5</math> <math display="block">p({\text{height}} \mid {\text{female}}) = 2.23 \cdot 10^{-1}</math> <math display="block">p({\text{weight}} \mid {\text{female}}) = 1.6789 \cdot 10^{-2}</math> <math display="block">p({\text{foot size}} \mid {\text{female}}) = 2.8669 \cdot 10^{-1}</math> <math display="block">\text{posterior numerator (female)} = \text{their product} = 5.3778 \cdot 10^{-4}</math> Since posterior numerator is greater in the female case, the prediction is that the sample is female.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)