How does Bayesian Filtering work in spam detection?

 Bayesian analysis breaks down email text into tokens and checks how often these appear in both spam and legitimate messages. Based on Bayes’ theorem, it assigns a score. If the score exceeds a threshold, the message is flagged as spam.