Naïve Bayes(Machine Learning)

(IMG Credits- memegenerator)

Naïve Bayes is a classification technique based on Bayes Theorem & is one of the fastest Machine Learning algorithm to predict a class of datasets. Binary as well as Multi-class classifications can be done using it. It is easy to build.

What it does?

It assumes that the presence of particular feature in a class is unrelated to the presence of any other feature.

It works on Bayes Theorem.


  • Gaussian: It assumes that features follow a normal distribution. This means if predictors take continuous values instead of discrete, then the model assumes that these values are sampled from the Gaussian distribution.
  • Multinomial: It is used when the data is multinomial distributed. It is primarily used for document classification problems, it means a particular document belongs to which category such as Sports, Politics, education, etc.
    The classifier uses the frequency of words for the predictors.
  • Bernoulli: It works similar to the Multinomial classifier, but the predictor variables are the independent Booleans variables. Such as if a particular word is present or not in a document. This model is also famous for document classification tasks.



  • Text Classification.
  • Medical Data Classification.
  • Sentiment Analysis.
  • SPAM Filtering.
  • Object & Face Recognition.

and many more…

Using Naïve Bayes

Way 1- Directly importing from scikit learn library in Python.

Input- from sklearn.naive_bayes import GaussianNB

This imports the Gaussian model.

Input- from sklearn.naive_bayes import BernoulliNB

This imports the Bernoulli model.

Input- from sklearn.naive_bayes import MultinomialNB

This imports the Multinomial model.

Way 2- Implementing Naïve Bayes from Scratch.

This was all about Naïve Bayes Classifier.

Happy Learning Folks!

You can also visit my previous blogs by clicking on their name below-

Follow me on LinkedIn-




Bring It On!

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Analysing Data In Web3 with SQL

Cognos Analytics: Dashboards v. Reports

How To Make An Animated Data Visualisation On Tableau

Q-Fin: A Python Library

Care Disrupted!👨‍⚕️

THIS is ME — My journey as ANALYST

Think Strategically: Five Steps to Superior Data Analysis

Automatic Portfolio Optimization

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vatsal Sharma

Vatsal Sharma

Bring It On!

More from Medium

Evaluation Metrics for Classification Models in Machine Learning.

5 Core Steps to Understand Machine Learning Workflow — a Guide for beginners

Concept of Linear Regression model for newbies!!

A simple guide explaining how to use scikit learn for linear regression