# Naïve Bayes(Machine Learning)

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.

# Types

**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.

*(Reference- javatpoint.com)*

# Applications

- 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-

- Google Colab
- Pandas
- NumPy
- Matplotlib
- OpenCV
- Data Preprocessing
- Linear Regression
- Decision Tree & Random Forest
- K-Nearest Neighbors
- Logistic Regression
- Support Vector Machine

Follow me on *LinkedIn*- *https://www.linkedin.com/in/imvat18/*