Naive Bayes

From Rice Wiki
Revision as of 19:18, 24 May 2024 by Rice (talk | contribs) (→‎How it works)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Naive Bayes is an approach to Bayesian networks that simplify the computation of joint probability of an outcome based on high dimensional features.

Motivation

Consider binary classification output C is dependent on binary features X1~X3. By Bayes theorem, we can compute C's probability based on the features with Bayes' theorem:

Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle P(C|X_1,X_2,X_3)=\frac{P(X_1,X_2,X_3|C)P(C)}{P(X_1,X_2,X_3)} }

This, in turn, mean that we need to estimate the probability of every combination of features (0 0 0, 0 0 1...). This is computationally expensive.

How it works

By assuming that the features are independent, Naive Bayes simplifies the computation to

Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle P(C|X_1,X_2,X_3)\propto P(X_1|C)P(X_2|C)P(X_3|C) }

We can divide P(C|X) over P(notC|X) to avoid calculating P(X1,X2,X3). We can then apply a log to avoid zero denominators.