Ticker

6/recent/ticker-posts

Implementation of Naïve Bayes classification algorithm using Iris dataset:

Naïve Bayes classification algorithm:

Naïve Bayes classification algorithm works on conditional probability based on Bayes theorem. Mostly it is used for text classification. For example, email spam filtering, sentiment analysis, weather prediction, news classification, medical diagnosis etc.

Bayes theorem:

Bayes theorem helps in determining the occurrence of an event based on the events which has already occurred or prior events. 

P(A/B) =(P(B/A). P(A))/P(B)

P(A/B) =Conditional probability of A given B

P(B/A) = Conditional probability of B given A

P(A)= Probability of A occurring

P(B)= Probability of B occurring

Types of Naïve Bayes algorithm:

a) Gaussian 

Gaussian distribution is used to classify continuous values where the features are assumed to follow normal or Gaussian distribution.

b) Multinomial

Multinomial classifier classifies the document based on the frequency of particular words which occurs in the document. For example, it classifies the document to sports, education or politics category.

c) Bernoulli

Bernoulli classifier also used in document classification, but here the feature vectors are Boolean or zeros or ones. It means whether particular word is present in the document or not.

Implementation of Naive Bayes classifier-Iris dataset:

Importing the libraries
Loading the dataset
 First five rows of the dataset
Number of rows and columns in the dataset:
Overall information of the dataset:
Statistically describing the dataset:
Checking for null values:
Independent and dependent variables:
Feature scaling using MinMaxScaler:
Splitting the dataset into train and test dataset:
Fitting into Gaussian Naive Bayes Classifier:
Predicted values:
Confusion matrix:



























Post a Comment

0 Comments