Questions tagged [naive-bayes-classifier]

Naive Bayes classifiers makes the naive assumption that the features are independent. They make use of Bayes theorem.

Naive Bayes classifiers make use of Bayes theorem:

$$\overbrace{P(c | X)}^{\text{A posteriori}} = \frac{\overbrace{P(X | c)}^{\text{Likelihood}} \cdot \overbrace{P(c)}^{\text{A priori} } }{\underbrace{P(X)}_{\text{evidence}}}$$

See also

203 questions
17
votes
1 answer

How to handle a zero factor in Naive Bayes Classifier calculation?

If I have a training data set and I train a Naive Bayes Classifier on it and I have an attribute value which has probability zero. How do I handle this if I later want to predict the classification on new data? The problem is, if there is a zero in…
fragant
  • 323
  • 1
  • 2
  • 6
14
votes
1 answer

How does the naive Bayes classifier handle missing data in training?

Naive Bayes apparently handles missing data differently, depending on whether they exist in training or testing/classification instances. When classifying instances, the attribute with the missing value is simply not included in the probability…
11
votes
2 answers

Implementing Complementary Naive Bayes in python?

Problem I have tried using Naive bayes on a labeled data set of crime data but got really poor results (7% accuracy). Naive Bayes runs much faster than other alogorithms I've been using so I wanted to try finding out why the score was so…
11
votes
1 answer

How does Naive Bayes classifier work for continuous variables?

I know that for categorical features we just calculate the prior and likelihood probability assuming conditional independence between the features. How does it work for continuous variables? How can we calculate likelihood probability for continuous…
Jeeth
  • 911
  • 2
  • 10
  • 18
10
votes
1 answer

Difference between Bernoulli and Multinomial Naive Bayes

Here is my understanding of the difference between a Bernoulli and a Multinomial Naive Bayes: Bernoulli explicitly models the presence/absence of a feature, whereas Multinomial doesn't. Is there something that I am missing? Can someone explain why…
Valentin Calomme
  • 5,396
  • 3
  • 20
  • 49
10
votes
1 answer

How to use TFIDF vectors with multinomial naive bayes?

Say we have used the TFIDF transform to encode documents into continuous-valued features. How would we now use this as input to a Naive Bayes classifier? Bernoulli naive-bayes is out, because our features aren't binary anymore. Seems like we can't…
dhrumeel
  • 201
  • 2
  • 4
10
votes
1 answer

Naive Bayes Should generate prediction given missing features (scikit learn)

Seeing that Naive Bayes uses probability to make a prediction, and treats features as being conditionally independent of each other, then it makes sense that the model can still make a prediction given that there are some features missing in the…
gbhrea
  • 307
  • 4
  • 10
8
votes
1 answer

Naive Bayes for Multi label text classification

How to use Naive Bayes for multi-label text classification in R. I tried using naiveBayes() from e1071 library but it seems that while training, it doesn't accept multi-label class variable. I created TermDocumentMatrix using the text document…
8
votes
3 answers

Overfitting Naive Bayes

My question is what are potential reasons for Naive Bayes to perform well on a train set but poorly on a test set? I am working with a variation of the 20news dataset. The dataset has documents, which are represented as "bag of words" with no…
7
votes
1 answer

SPARK, ML: Naive Bayes classifier often assigns 1 as probability prediction

Hi I am using Spark ML to optimise a Naive Bayes multi-class classifier. I have about 300 categories and I am classifying text documents. The training set is balanced enough and there is about 300 training examples for each category. All looks good…
7
votes
1 answer

Understanding of naive bayes: computing the conditional probabilities

For a task on sentiment analysis, suppose we have some classes represented by $c$ and features $i$. We can represent the conditional probability of each class as: $$P(c | w_i) = \frac{P(w_i|c) \cdot P(c)}{P(w_i)}$$ where $w_i$ represents each…
6
votes
2 answers

How to deal with missing data for Bernoulli Naive Bayes?

I am dealing with a dataset of categorical data that looks like this: content_1 content_2 content_4 content_5 content_6 0 NaN 0.0 0.0 0.0 NaN 1 NaN 0.0 0.0 0.0 …
6
votes
3 answers

Why does the naive bayes algorithm make the naive assumption that features are independent to each other?

Naive Bayes is called naive because it makes the naive assumption that features have zero correlation with each other. They are independent of each other. Why does naive Bayes want to make such an assumption?
user781486
  • 1,305
  • 2
  • 16
  • 18
6
votes
4 answers

Naive Bayes Multinomial, independence assumption misunderstood

This is embarrassing but I think I miss understand something. In multinomial distribution, "while the trials are independent, their outcomes X are dependent because they must be summed to n." wiki Naive Bayes assumption is that the features are…
6
votes
2 answers

Naive Bayes: Divide by Zero error

OK this is my first time in ML and for starter I am implementing Naive Bayes. I have Cricket(sports) data in which I have to check whether the team will win or lost based on Toss Won|Lost and Bat First|Second. Below is my code: from…
Volatil3
  • 341
  • 3
  • 10
1
2 3
13 14