1.朴素贝叶斯案例
1.1防止求出的概率为0,进行拉普拉斯平滑
1.2sklearn朴素贝叶斯实现API
sklearn.naive_bayes.MultinomialNB
sklearn.naive_bayes.MultinomialNB(alpha = 1.0)
alpha:拉普拉斯平滑系数
1.3案例分析 20类新闻分类
from sklearn.model_selection import train_test_split
from sklearn.naive_bayes import MultinomialNB
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.datasets import fetch_20newsgroups
from sklearn.metrics import c