Naive Bayes Algorithm

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

   Diversity

 +1.732.947.4119

Digital  Life Sciences Healthcare Staffing  Company  Contact Us Knowledge Center 


HOME  BLOGS  NAIVE BAYES ALGORITHM BLOG LIST

About Us

Rang Technologies has grown to


become a global leader in
Analytics, Data Science, Artificial
Intelligence, Machine Learning,
Salesforce CRM, Cloud, DevOps,
Internet of Things - IoT,
Cybersecurity, IT Consulting and
Staffing, and Corporate Training.

Categories

• Data Science (27)


• AI / Machine Learning (6)
• Big Data (2)
AI / MACHINE LEARNING
• Cloud (5)
NAIVE BAYES ALGORITHM • Cybersecurity (4)

In a world where many manual operations are mechanized, the • Salesforce CRM (2)
definition of the word ‘manual’ is evolving. Computers can play • IoT (3)
chess, perform surgery, and develop into smarter, more • Clinical (5)
humanlike machines with the aid of machine learning
• Healthcare (4)
algorithms.
• Life Sciences (5)
What is Naive Bayes Algorithm?
• This & That (8)

The machine learning algorithm is divided into categories, in • Recruiting Strategy (16)
which Naive Bayes Algorithm falls under the umbrella of • Diversity, Equity & Inclusion (1)
supervised machine learning algorithm. It is a classification
method built on the Bayes Theorem and predicated on the
idea of predictor independence. A Naive Bayes classifier
believes that the presence of one feature in a class has nothing
to do with the presence of any other feature. For example

The Bayes model is simple to construct and especially helpful


for very big data sets. Along with being straightforward, Naive
Bayes is known to perform better than even the most complex
classification techniques.

It provides a way of calculating the posterior probability by the


given equation below:      

                                            

           

                                   
Digital  Life Sciences Healthcare Staffing  Company  Contact Us Knowledge Center 

                       Where P(c|x) = posterior probability of class (c) given
predictor (x).

                                    P(x|c) = Prior probability of predictor.

Types of Naive Bayes Algorithm

Three different Naive Bayes model types may be found in the


Scikit-Learn library which are as follows: -

Multinominal Naive Bayes

Feature vectors represent the frequencies with which certain


events have been generated by a multinomial distribution. This
is the event model that is typically used for document
classification.

Bernoulli naive bayes:

In the multivariate Bernoulli event model, features are


independent Booleans (binary variables) describing inputs. Like
the multinomial model, this model is popular used for
document classification tasks, where binary term occurrence
(i.e., a word occurs in a document or not) features are used
rather than term frequencies (i.e., frequency of a word in the
document).

Gaussian Naive Bayes:

 We assume that the values of the predictors are samples from
a gaussian distribution when they take up a continuous value
and are not discrete.

Below code can be implemented of Gaussian Naive Bayes


classifier using scikit-learn.

# load the iris dataset

from sklearn.datasets import load_iris

iris = load_iris()

# store the feature matrix (X) and response vector (y)

X = iris.data

y = iris.target

# splitting X and y into training and testing sets

from sklearn.model_selection import train_test_split

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.4,


random_state=1)

# training the model on training set

from sklearn.naive_bayes import GaussianNB

gnb = GaussianNB()

gnb.fit(X_train, y_train)

  Digital  Life Sciences Healthcare Staffing  Company  Contact Us Knowledge Center 



# making predictions on the testing set

y_pred = gnb.predict(X_test)

# comparing actual response values (y_test) with predicted response


values (y_pred)

from sklearn import metrics

print("Gaussian Naive Bayes model accuracy(in %):",


metrics.accuracy_score(y_test, y_pred)*100)

Output:

Gaussian Naive Bayes model accuracy (in %): 95.0

Applications of Naive Bayes Algorithm/Classifier

Real-time Prediction: Naive Bayes is a quick classifier that is


eager to learn. As a result, it might be applied to real-time
prediction.

Multi-class Prediction: This algorithm is very widely renowned


for its ability to predict many classes. Here, we can forecast
the likelihood of several target variable classes.

Sentiment analysis, spam filtering, and text classification:


Because they perform better in multi-class situations and
follow the independence criterion, naive Bayes classifiers are
frequently employed in text classification and have a greater
success rate than other methods. It is therefore frequently used
in Sentiment Analysis and Spam Filtering (to identify spam e-
mail) (in social media analysis, to identify positive and negative
customer sentiments)

Recommendation system:  Naive Bayes Classifier and


Collaborative Filtering work together to create a system that
filters opportunistic information and forecasts whether a user
will find a specific resource appealing or not.

Advantages of Naive Bayes Algorithm

A Naive Bayes classifier outperforms other models when


the independent predictor assumption is valid.
To estimate the test data, Naive Bayes just needs a
modest amount of training data. So, there is a shorter
training period.
It's simple to use Naive Bayes.

Disadvantages of Naive Bayes Algorithm

The main premise of Naive Bayes is that independent


predictors exist. All of the attributes are implicitly
assumed to be independent of one another by Naive
Bayes. We rarely find a set of predictors that are entirely
independent in the real world.

If a categorical variable in the test data set has a


category that wasn't included in the training data set, the
model will give it a probability of 0 (zero), and it won't be
able to predict anything. This is commonly referred to as
Zero Frequency. We can utilize the smoothing method to
resolve this. Laplace estimate is one of the simplest
Digital  Life Sciences Healthcare Staffing  Company  Contact Us Knowledge Center 

smoothing methods.
About Rang Technologies:
Headquartered in New Jersey, Rang Technologies has
dedicated over a decade delivering innovative solutions and
best talent to help businesses get the most out of the latest
technologies in their digital transformation journey. Read
More...

 BY: ISHIKA VALAND  Jul 11 2022

Rang Technologies Tweets


Inc Loading tweets by @RangTweets...

Headquartered in New Jersey,


Rang Technologies has
dedicated over a decade
delivering innovative solutions
and best talent to help
businesses get the most out of
the latest technologies in their
digital transformation journey.
Read more...

Office Locations
United India Canad

Corporate Headquarters:

Rang Technologies Inc.
15 Corporate Pl S, Suite# 356,
Piscataway, NJ 08854

Phone

+1.732.947.4119

E-mail

General Inquiries:
info@rangtech.com
Sales Inquiries:
sales@rangtech.com

Learn More Learn More

About Us Digital

© 2023 Rang Why partner with us Data Science & Analytics


Google Reviews
Technologies Inc Diversity AI & Machine Learning 4.4
All rights reserved 193 reviews
Case Studies Big Data
Digital  Life Sciences Healthcare Staffing  Company  Contact Us Knowledge Center
Provided by review-widget.net


Terms of Use Blog Cloud

Privacy Policy Events Staffing     


Follow
Cookies Policy
75,227

Update cookies preferences

You might also like