Naive Bayes for Beginners: Simplifying Classification with Bayes’ Theorem

Aishwarya
2 min readJan 4, 2025

--

Naive Bayes is a generative classification algorithm that uses probabilistic modeling to classify data. The name of the algorithm comes from the ‘naive’ assumption that features are independent of each other, combined with the use of Bayes’ theorem to calculate the probability of each class.

Classifiers can be broadly categorized into two types:

  1. Generative Classifier Models:
    These models learn a joint distribution of the data, which includes the features and the class. Given an observation, they predict which class is most likely to have generated it. In other words, a generative model learns how the data for each class is generated and models the joint probability of the features and the class label.
    Example: Naive Bayes is a generative model.
  2. Discriminative:
    These models focus on learning the decision boundary between classes. They identify the features that best discriminate between classes, without modeling the distribution of the data. Essentially, discriminative models directly model the conditional probability of the class given the input features, P(y∣X), rather than modeling the joint distribution of the features and classes.
    Example: Logistic Regression, Support Vector Machines (SVMs) are discriminative models.

Understand with an analogy: Imagine trying to distinguish between apples and oranges

Figure 1: This image displays a collection of oranges and apples, each exhibiting various features such as color, size, and shape. The generative model would focus on learning the distribution of features for each fruit, such as the color and shape patterns of apples versus oranges, to calculate the probability of a new fruit being an apple or an orange. The discriminative model would instead focus on the boundaries between the two classes, learning key features (like the presence of leaves) that best differentiate apples from oranges.

A generative model focuses on modeling how the data is generated by learning the underlying distribution of each class — in this case, apples and oranges. It examines the features of the fruits, such as color, size, shape, and texture, and learns the characteristics associated with each fruit type. For instance, the model might learn that apples are typically red or green and have a certain shape, while oranges are generally orange and round.

A discriminative model focuses on learning the decision boundary that separates different classes. Instead of modeling the data distribution for each class, the discriminative model directly learns which features can best distinguish apples from oranges. For example, it might learn that apples tend to have leaves attached to them, while oranges do not

--

--

Aishwarya
Aishwarya

Written by Aishwarya

Data Science Practioner | Machine Learning Enthusiast

No responses yet