Machine Learning Project 14 — Naive Bayes Classifier — Step by Step

Omair Aasim
9 min readSep 14, 2019

If you are like me and enjoy Mathematics, then you’ll definitely enjoy this article. Before getting into the Naive Bayes Classifier, let’s look at the Bayes Theorem.

#100DaysOfMLCode #100ProjectsInML

Bayes Theorem

To understand the Bayes theorem, let’s walk through a simple probability example.

Let’s say we have 2 factories Factory 1 and Factory 2 manufacturing laptops. The laptops are labelled so we know which laptop came from which factory.
During the testing phase, we find some defective laptops.

This is the information that is given to us.

  1. Factory 1 produces 30 laptops per hour.
  2. Factory 2 produces 20 laptops per hour.
  3. 1% of all laptops are defective.
  4. 50% of defective laptops came from Factory 1.
  5. 50% of defective laptops came from Factory 2.

What is the probability that a laptop manufactured by Factory 2 is defective?

A question like this can be answered using Bayes Theorem.

--

--

Omair Aasim

Passionate about building products — An advocate of AI, a software engineer by profession — an entrepreneur at heart and a sports enthusiast.