Everything you need to understand a Naive Bayes Classifier.

Mohamed Bakrey
5 min readJul 25, 2022

Introduction

In this article, it will be mentioned one of the most important and best algorithms that are used in machine learning. It is its components that it works on. Based on it, we will present its advantages and disadvantages, so let us go to the content in this article.

What is naive Bayes?

First, we will present a basic process of Bayes’ theory, named after Thomas Bayes from the eighteenth century AD. The Naive Bayes classifier basically works on the principle of conditional probability, as described in Bayes’ theorem. Naïve Bayes. classifier algorithm The Naïve Bayes algorithm is a supervised learning algorithm, which is based on Bayes Theorem and is used to solve classification problems. It is mainly used to classify text that includes a high-dimensional training data set. Naïve Bayes classification is one of the simple and most effective classification algorithms that help build fast machine learning models that can make fast predictions. It is a probabilistic classifier, which means that it predicts based on the probability of an object. Some common examples of the Naïve Bayes algorithm used in these parts are spam filtering, dynamic analysis, and article categorization.

Machine learning is categorized into two successive categories, those two categories are called supervised learning and unsupervised learning. Here today the Naive Bayes is supervised. Supervised learning is also divided into classification and regression, and the algorithm we are talking about today falls under classification.

Why is it called Naïve Bayes?

Here the Naïve Bayes algorithm is formed from the two words Naïve and Bayes, which are illustrated as follows:

Naïve: It is called Naïve because it assumes that the occurrence of a particular trait is independent of the occurrence of other traits. If we give an example of this where we can say if the fruit is identified on the basis of color, shape, and taste, then the red, spherical, and sweet fruit is recognized as an apple. Hence each feature individually contributes to identifying it as an apple without depending on each other.

Bayes: It is called Bayes because it is based on the principle of the Bayes Theorem.

To clarify this more, we can clarify or take a simple look at Bayes’ Theorem:

Bayes theorem is given by an English statistician, philosopher, and Presbyterian minister named Mr. Thomas Bayes in the 17th century. Bayes provides their thoughts in decision theory which is extensively used in important mathematics concepts such as Probability. Bayes theorem is also widely used in Machine Learning where we need to predict classes precisely and accurately. An important concept of the Bayes theorem named the Bayesian method is used to calculate conditional probability in Machine Learning application that includes classification tasks. Further, a simplified version of the Bayes theorem (Naïve Bayes classification) is also used to reduce computation time and the average cost of the projects

Bayes’ theorem is also known by some other names such as Bayes’ rule or Bayes’ law. Bayes’ theorem helps to determine the probability of an event occurring with random knowledge. It is used to calculate the probability of one event occurring while another has already occurred. It is the best way to relate condition probability and marginal probability.

In simple words, we can say that Bayes’ theorem helps contribute to more accurate results.

Bayes’ theorem is used to estimate the accuracy of values and provides a method for calculating conditional probability. However, it is a hypocritically simple arithmetic operation, but it is easily used to calculate the conditional probability of events in which intuition often fails. Some data scientists assume that Bayes’ theorem is widely used in the financial industries but it is not. Other than finance, Bayes’ theory is also widely applied in health, medicine, research, surveying industry, aviation sector, etc.

  • Bayes’ theorem is also known as Bayes’ Rule or Bayes’ law, which is used to determine the probability of a hypothesis with prior knowledge. It depends on conditional probability.
  • The formula for Bayes’ theorem is given as:

Where,

P(A|B) is Posterior probability: Probability of hypothesis A on the observed event B.

P(B|A) is Likelihood probability: Probability of the evidence given that the probability of a hypothesis is true.

P(A) is Prior Probability: Probability of hypothesis before observing the evidence.

P(B) is Marginal Probability: Probability of Evidence.

Types of Naïve Bayes Model:

There are three types of Naive Bayes model, which are given below:

Gaussian: The Gaussian model assumes that the features follow a normal distribution. This means that if the predictors take continuous rather than discrete values, the model assumes that these values are taken from the Gaussian distribution.

Polynomial: The Multinomial Naïve Bayes classifier is used when the data is distributed polynomials. It is mainly used for document classification problems, meaning that a particular document belongs to any category such as sports, politics, education, etc.

The classifier uses word frequency for predictions.

Bernoulli: Bernoulli classifier works similarly to a polynomial classifier, but the predictor variables are the independent logical variables. Like if a particular word is present or not in the document. This form is also popular for document classification tasks.

Advantages of Naïve Bayes Classifier:

  • Naïve Bayes is one of the fast and easy ML algorithms for predicting a class of datasets.
  • It can be used for binary labels as well as multi-class labels.
  • It works well in multi-category predictions compared to other algorithms.
  • It is the most common choice for text classification problems.
  • It is simple and easy to implement
  • Does not require a lot of training data

It handles both continuous and discrete data

  • It is highly scalable with a number of predictors and data points
  • It is fast and can be used to make real-time predictions
  • Not sensitive to unrelated features

Disadvantages of Naive Bayes classification:

  • Naive Bayes assumes that all features are independent or unrelated, so it cannot know the relationship between features.

In this article, work was done on one of the most important algorithms that are widely used in machine learning, and it is one of the simplest algorithms.

Mohamed B Mahmoud. Data Scientist.

--

--