0% found this document useful (0 votes)
23 views

DSBDAL_Assignment No 6

The document outlines an experiment on implementing the Naïve Bayes classification algorithm using the iris.csv dataset in Python/R, including steps for data splitting, conditional probability calculation, and confusion matrix display. It explains Bayes' Theorem and the Naïve Bayes classifier's applications in real-time prediction, multi-class prediction, text classification, and recommendation systems. The conclusion emphasizes the study of the Naïve Bayes classification algorithm and poses several related questions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

DSBDAL_Assignment No 6

The document outlines an experiment on implementing the Naïve Bayes classification algorithm using the iris.csv dataset in Python/R, including steps for data splitting, conditional probability calculation, and confusion matrix display. It explains Bayes' Theorem and the Naïve Bayes classifier's applications in real-time prediction, multi-class prediction, text classification, and recommendation systems. The conclusion emphasizes the study of the Naïve Bayes classification algorithm and poses several related questions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Experiment No: 6

Data Analytics III


1. Implement Simple Naïve Bayes classification algorithm using Python/R on iris.csv
dataset. Compute Confusion matrix to find TP, FP, TN, FN, Accuracy, Error rate,
Precision, Recall on the given dataset.

Implement a classification algorithm that is Naïve Bayes. Implement the


following operations:
1. Split the dataset into Training and Test dataset.
2. Calculate conditional probability of each feature in training dataset.
3. Classify sample from a test dataset.
4. Display confusion matrix with predicted and actual values.

Fundamentals of R -Programming Languages


To learn the concept of Naïve Bayes classification algorithm,Bayes
theorem.
I.Bayes Theorem:

Bayes’ Theorem is a way of finding a probability when we know certain


other probabilities.

The formula is:

P(A|B) = P(A) P(B|A)P(B)

P(A|B): how often A happens given that B happens, written P(A|B),

P(B|A): how often B happens given that A happens, written P(B|A)

P(A): and how likely A is on its own, written P(A)

P(B): and how likely B is on its own, written P(B)

Department of Computer
Engineering
Let us say P(Fire) means how often there is fire, and P(Smoke) means
how often we see smoke, then:

P(Fire|Smoke) means how often there is fire when we can see smoke
P(Smoke|Fire) means how often we can see smoke when there is fire

So the formula kind of tells us "forwards" P(Fire|Smoke) when we


know "backwards" P(Smoke|Fire)

Example: If dangerous fires are rare (1%) but smoke is fairly common
(10%) due to barbecues, and 90% of dangerous fires make smoke then:

P(Fire|Smoke) =P(Fire) P(Smoke|Fire)P(Smoke)


=1% x 90%10%
=9%

So the "Probability of dangerous Fire when there is Smoke" is 9%

II. Naive Bayes Classification

Naive Bayes is a simple, yet effective and commonly-used, machine


learningclassifier. It is a probabilistic classifier that makes classifications
using the Maximum A Posteriori decision rule in a Bayesian setting. It can
also be represented using a very simple Bayesian network. Naive Bayes
classifiers have been especially popular for text classification, and are a
traditional solution for problems such as spam detection. Windows/Linux
Operating Systems, RStudio, jdk.

Applications:
 Real time Prediction: Naive Bayes is an eager learning classifier and it is sure
fast.Thus, it could be used for making predictions in real time.
 Multi class Prediction: This algorithm is also well known for multi class
predictionfeature. Here we can predict the probability of multiple classes of target
variable.
 Text classification/ Spam Filtering/ Sentiment Analysis: Naive Bayes
classifiersmostly used in text classification (due to better result in multi class problems
and independence rule) have higher success rate as compared to other algorithms. As a
result, it is widely used in Spam filtering (identify spam e-mail) and Sentiment
Analysis (in social media analysis, to identify positive and negative customer
sentiments)
 Recommendation System: Naive Bayes Classifier and Collaborative
Department of Computer Engineering
Filteringtogether builds a Recommendation System that uses machine learning and
data mining techniques to filter unseen information and predict whether a user would
like a given resource or not

1.
Input:
Structured Dataset :Iris Dataset
File: iris.csv
Output:

1. Splitted dataset according to Split ratio.


2. Conditional probability of each feature.
3. visualization of the performance of an algorithm with confusion matrix

Conclusion: Hence, we have studied classification algorithm that is Naïve Bayes


classification.
Questions:
6. What is Bayes Theorem?
7. What is confusion matrix?
8. Which function is used to split the dataset in R?
9. What are steps of Naïve Bayes algorithm?
10. What is conditional probability?

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy