朴素贝叶斯
来源:互联网 发布:linux 输出重定向 2 1 编辑:程序博客网 时间:2024/05/18 02:59
朴素贝叶斯
- 朴素贝叶斯
- 贝叶斯定理
- 基本方法
- 拉普拉斯平滑 Laplace
- 模型
- 高斯朴素贝叶斯 Gaussian naive Bayes
- 多项模型 MultinomialNB
- 相关资料
贝叶斯定理
贝叶斯定理是关于随机事件A和B的条件概率的一则定理。
在贝叶斯定理中,每个名词都有约定俗成的名称:P(A|B)是已知B发生后A的条件概率,也由于得自B的取值而被称作A的后验概率。P(A)是A的先验概率(或边缘概率)。P(B)是B的先验概率或边缘概率
先验概率是指根据以往经验和分析得到的概率,没有考虑其他证据。后验概率是考虑其他证据后得到的条件概率
Wiki:In Bayesian statistical, a prior probability distribution, often simply called the prior, of an uncertain quantity is the probability distribution that would express one’s beliefs about this quantity before some evidence is taken into account. The posterior probability of a random event or an uncertain proposition is the conditional probability that is assigned after the relevant evidence or background is taken into account.
基本方法
输入空间
朴素贝叶斯学习先验概率分布
及条件概率分布
假设
朴素贝叶斯算法对条件概率分布作出了独立性的假设, 假设各维度特征独立
此假设使朴素贝叶斯变简单,但牺牲一定准确率。
所以后验概率等于
这是朴素贝叶斯的基本公式。于是,朴素贝叶斯分类器表示为
对与不同
拉普拉斯平滑 Laplace
可能会出现所要估计的概率值
对
模型
高斯朴素贝叶斯 (Gaussian naive Bayes)
When dealing with continuous data, a typical assumption is that the continuous values associated with each class are distributed according to a Gaussian distribution. For example, suppose the training data contains a continuous attribute,
多项模型 (MultinomialNB)
假设一个邮件的概率服从多项分布,和里面每个单词出现的频率有关
With a multinomial event model, samples (feature vectors) represent the frequencies with which certain events have been generated by a multinomial
The multinomial naive Bayes classifier becomes a linear classifier when expressed in log-space:[2]
where
If a given class and feature value never occur together in the training data, then the frequency-based probability estimate will be zero. This is problematic because it will wipe out all information in the other probabilities when they are multiplied. Therefore, it is often desirable to incorporate a small-sample correction, called pseudocount, in all probability estimates such that no probability is ever set to be exactly zero. This way of regularizing naive Bayes is called Laplace smoothing when the pseudocount is one, and Lidstone smoothing in the general case.
class sklearn.naive_bayes.MultinomialNB(alpha=1.0, fit_prior=True, class_prior=None)
参数:
alpha : float, optional (default=1.0)
fit_prior : boolean, optional (default=True). Whether to learn class prior probabilities or not. If false, a uniform prior will be used. 默认True, 如果false各先验概率相等。
class_prior : array-like, size (n_classes,), optional (default=None). Prior probabilities of the classes. If specified the priors are not adjusted according to the data. 默认None,可用来指定先验概率。
>>> import numpy as np>>> X = np.random.randint(5, size=(6, 100)) # X.shape = [n_samples, n_features]>>> y = np.array([1, 2, 3, 4, 5, 6]) # y.shape = [n_samples]>>> from sklearn.naive_bayes import MultinomialNB>>> clf = MultinomialNB()>>> clf.fit(X, y)MultinomialNB(alpha=1.0, class_prior=None, fit_prior=True)>>> print(clf.predict(X[2:3]))[3]
相关资料
[1]: 李航 统计学习方法
[2]: https://en.wikipedia.org/wiki/Prior_probability Prior probability
[3]: http://www.letiantian.me/2014-10-12-three-models-of-naive-nayes/ 朴素贝叶斯的三个常用模型:高斯、多项式、伯努利
[4]: http://blog.csdn.net/u012162613/article/details/48323777 朴素贝叶斯理论推导与三种常见模型
[5]: https://en.wikipedia.org/wiki/Naive_Bayes_classifier#Multinomial_naive_Bayes Multinomial naive Bayes
[6]: http://www.cs.cmu.edu/~knigam/papers/multinomial-aaaiws98.pdf A Comparison of Event Models for Naive Bayes Text Classification
[7]: http://cs229.stanford.edu/materials.html MIT 229 lecture 2
- 朴素贝叶斯
- 朴素贝叶斯
- 朴素贝叶斯
- 朴素贝叶斯
- 朴素贝叶斯
- 朴素贝叶斯
- 朴素贝叶斯
- 朴素贝叶斯
- 朴素贝叶斯
- 朴素贝叶斯
- 朴素贝叶斯
- 朴素贝叶斯
- 朴素贝叶斯
- 朴素贝叶斯
- 朴素贝叶斯
- 朴素贝叶斯
- 朴素贝叶斯
- 朴素贝叶斯
- poj1004
- 【Java】简单递归
- java在数字前面自动补零的方法
- JDBC和结果集的操作
- javaee导测(ssh框架)分页 mysql数据库(带条件查询)
- 朴素贝叶斯
- 《Python爬虫学习系列教程》学习笔记
- Ubuntu 启动进入命令行模式
- tensorflow学习笔记(一)
- GeoJson的生成与解析
- atom编辑器快捷键
- js交互
- 产业互联网——大数据的行业应用
- hibernate 更新对象updateobject