Loading…
Glossary term
A simple probabilistic classifier that assumes input features are independent.
Naive Bayes uses Bayes' theorem to compute the probability of each class given the features, and 'naively' assumes the features are independent of each other. That assumption is rarely true, yet the method often works well. It is fast and needs little data.
Naive Bayes for text
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.naive_bayes import MultinomialNB
from sklearn.pipeline import make_pipeline
nb = make_pipeline(CountVectorizer(), MultinomialNB())
nb.fit(["free prize", "meeting notes"], ["spam", "ham"])It was the engine of early spam filters and remains a handy quick baseline for text.