# Naive Bayes Example

• We are trying to determine if its time to PlayTennis given that $⟨\mathrm{Outlook}=\mathrm{sunny},\mathrm{Temp}=\mathrm{cool},\mathrm{Humid}=\mathrm{high},\mathrm{Wind}=\mathrm{strong}⟩$
• We want to compute ${v}_{\mathrm{NB}}={argmax}_{{v}_{j}\in V}P\left({v}_{j}\right)\prod _{i}P\left({a}_{i}\phantom{\rule{thinmathspace}{0ex}}|\phantom{\rule{thinmathspace}{0ex}}{v}_{j}\right)$
• Given this set of examples we can calculate that $P\left(\mathrm{PlayTennis}=\mathrm{yes}\right)=\frac{9}{14}=.64$ $P\left(\mathrm{PlayTennis}=\mathrm{no}\right)=\frac{5}{14}=.36$ similarly $P\left(\mathrm{Wind}=\mathrm{strong}\phantom{\rule{thinmathspace}{0ex}}|\phantom{\rule{thinmathspace}{0ex}}\mathrm{PlayTennis}=\mathrm{yes}\right)=\frac{3}{9}=.33$ $P\left(\mathrm{Wind}=\mathrm{strong}\phantom{\rule{thinmathspace}{0ex}}|\phantom{\rule{thinmathspace}{0ex}}\mathrm{PlayTennis}=\mathrm{no}\right)=\frac{3}{5}=.6$ using these and few more similar probabilities we can calculate $P\left(\mathrm{yes}\right)\cdot P\left(\mathrm{Outlook}=\mathrm{sunny}\phantom{\rule{thinmathspace}{0ex}}|\phantom{\rule{thinmathspace}{0ex}}\mathrm{yes}\right)\cdot P\left(\mathrm{Temperature}=\mathrm{cool}\phantom{\rule{thinmathspace}{0ex}}|\phantom{\rule{thinmathspace}{0ex}}\mathrm{yes}\right)\cdot P\left(\mathrm{Humidity}=\mathrm{high}\phantom{\rule{thinmathspace}{0ex}}|\phantom{\rule{thinmathspace}{0ex}}\mathrm{yes}\right)\cdot P\left(\mathrm{Wind}=\mathrm{strong}\phantom{\rule{thinmathspace}{0ex}}|\phantom{\rule{thinmathspace}{0ex}}\mathrm{yes}\right)=.005$ $P\left(\mathrm{no}\right)\cdot P\left(\mathrm{Outlook}=\mathrm{sunny}\phantom{\rule{thinmathspace}{0ex}}|\phantom{\rule{thinmathspace}{0ex}}\mathrm{no}\right)\cdot P\left(\mathrm{Temperature}=\mathrm{cool}\phantom{\rule{thinmathspace}{0ex}}|\phantom{\rule{thinmathspace}{0ex}}\mathrm{no}\right)\cdot P\left(\mathrm{Humidity}=\mathrm{high}\phantom{\rule{thinmathspace}{0ex}}|\phantom{\rule{thinmathspace}{0ex}}\mathrm{no}\right)\cdot P\left(\mathrm{Wind}=\mathrm{strong}\phantom{\rule{thinmathspace}{0ex}}|\phantom{\rule{thinmathspace}{0ex}}\mathrm{no}\right)=.021$
• So ${v}_{\mathrm{NB}}=\mathrm{no}$