×

# Naive Bayes Algorithm Example in Machine Learning

Example of Naive Bayes Algorithm: In this tutorial, we will learn about the naive bayes algorithm with the help of an example. By Anamika Gupta Last updated : April 16, 2023

## Why Naive Bayes Algorithm Is Used?

Naive Bayes is basically used for text learning. Using this algorithm we trained machine from text.

## Naive Bayes Algorithm Example

### Question

There are two writers SARA and CHRIS .The probability of writing the word "LOVE" ,"DEAL" and "LIFE" is 0.1,0.8 and 0.1 respectively by CHRIS and 0.5,0.2 and 0.3 by SARA. The probability of sending mail by CHRIS and SARA is 0.5, and then answer this question:

1. Who will more likely send the mail "LOVE LIFE"?
2. What is the probability that "LOVE LIFE" is send by CHRIS?

### Solution

#### Answer 1

```P(CHRIS,"LOVE LIFE")=P(CHRIS) *P("LOVE LIFE"|CHRIS)
= 0.5 * (0.1 *0.1) =0.005
P(SARA,"LOVE LIFE")=P(SARA) * P("LOVE LIFE"|SARA)
= 0.5 * (0.5 * 0.3)
= 0.075

Hence, SARA is more likely to send mail "LOVE LIFE".
```

#### Answer 2

```Normalize:
P("LOVE LIFE")=P(CHRIS,"LOVE LIFE")+P(SARA,"LOVE LIFE")
= 0.005+0.075
= 0.08
Probability of sending mail "LOVE LIFE" by CHRIS (P(CHRIS|"LOVE LIFE"))
= P(CHRIS,"LOVE LIFE")/P("LOVE LIFE")
= 0.005/0.08
= 0.0625
```

Similarly for probability of sending mail by SARA we can divide 0.075 by the total of two i.e. 0.08. Hence this process is the algorithm for bayes rule.

Comments and Discussions!

Student's Section
Subscribe

Copyright © 2024 www.includehelp.com. All rights reserved.