# How Naive Bayes makes prediction based on scikit-learn?

I need to understand, how multinomial-naive-bayes can make prediction based on scikit-learn implementation. I saw the source code but I want to understand the math behind it. Could you please explain the math behind this prediction?

## 1 Answer

To understand the Naive Bayes ML algorithms, a good start is understanding the original Naive Bayes probability function and what conditional probability implies.

Short answer : In your training data, you can "learn" inferences such as "what is the probability of seeing the word 'money' in spams". You can create a large number of those inferences between your dependent variables (your features) and the class you are trying to predict. Probabilities allow you to combine those inferences (multiplying the probabilities) to make predictions on new data the model has never seen before, allowing to class it in a certain class.

Note : I'll add some links in the comments

• The youtube channel "Statquest" is a good data/ml channel that goes properly in some math concepts. He has good videos on Naive Bayes. Here's a link : youtube.com/watch?v=O2L2Uv9pdDA Mar 22, 2023 at 14:28
• Thanks. I know. I needed to understand how in source code it will be calculated. Mar 22, 2023 at 16:30