Naive bayes theorem is applied assuming that each word is strongly independent and doesn't depend on occurrences of other words. • We find the posterior probability of each word given to test, based on the previously known probabilities and prior. • Prior is the chance whether an arbitrary mail is spam or non-spam, based on how frequently we receive them.