Update Naive_Bayes_Classifiers.md

pull/1210/head
Divyanshi 2024-06-19 15:28:34 +05:30 zatwierdzone przez GitHub
rodzic 02e4d34b44
commit cb44aba5d2
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
1 zmienionych plików z 6 dodań i 6 usunięć

Wyświetl plik

@ -3,7 +3,7 @@
A Naive Bayes classifier is a probabilistic machine learning model used for classification tasks. It is based on Bayes' Theorem and assumes that the features (or predictors) are independent of each other given the class. This assumption of independence is called the "naive" assumption, which rarely holds true in real-world data but simplifies the computations involved and often works well in practice.
It is not a single algorithm but a family of algorithms where all of them share a common principle, i.e. every pair of features being classified is independent of each other.
## Bayes Theorem:
## Bayes Theorem
Bayes Theorem finds the probability of an event occurring given the probability of another event that has already occurred. Bayes theorem is stated mathematically as the following equation:
$$ P(C|X) = \frac{P(X|C) \cdot P(C)}{P(X)} $$
@ -30,7 +30,7 @@ In the context of a Naive Bayes classifier, we are interested in finding the mos
Consider a simple example where we want to classify emails as "spam" or "not spam" based on features like the presence of certain keywords.
#### Training Data
#### Training Data:
| Email | Keyword1 | Keyword2 | Spam |
|--------|-------------|-------------|---------|
@ -70,9 +70,9 @@ For a new email with Keyword1 = Yes and Keyword2 = Yes:
P(Spam|Keywords) > P(Not Spam|Keywords), we classify the new email as "Spam".
## Types of Naive Bayes Classifiers:
## Types of Naive Bayes Classifiers
#### 1. Gaussian Naive Bayes:
#### 1. Gaussian Naive Bayes
In Gaussian Naive Bayes, continuous values associated with each feature are assumed to be distributed according to a Gaussian distribution. A Gaussian distribution is also called Normal distribution When plotted, it gives a bell shaped curve which is symmetric about the mean of the feature values as shown below:
![img_2.png](img_2.png)
@ -111,7 +111,7 @@ y_pred = gnb.predict(X_test)
from sklearn import metrics
print("Gaussian Naive Bayes model accuracy(in %):", metrics.accuracy_score(y_test, y_pred)*100)
```
#### 2. Multinomial Naive Bayes:
#### 2. Multinomial Naive Bayes
Feature vectors represent the frequencies with which certain events have been generated by a multinomial distribution.
Typically used for discrete features, especially for text (or document) classification problems like spam detection, where features represent word counts.
* Assumption: Features represent the number of times events (e.g., words) occur.
@ -124,7 +124,7 @@ $$
where n(c,xi) is the count of feature 𝑥𝑖 in class 𝐶, N(C) is the total count of all features in class C, n is the number of features, and 𝛼 is a smoothing parameter.
#### 3. Bernoulli Naive Bayes:
#### 3. 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 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).
Used for binary/boolean features, where features represent binary occurrences (e.g., word presence/absence in text).
* Assumption: Features are binary (e.g., word presence/absence).