# bayes

## bayes公式

随机试验具有三个特征：

* 可以在相同的条件下重复进行
* 每次试验的结果不止一个，但预先知道试验的所有可能的结果
* 每次试验前不能确定那个结果会出现

**样本空间**：随机试验E的所有结果构成的集合称为E的样本空间，记为$$S={e}$$。\
S中的元素为基本事件或样本点。\
**随机事件**：一般称S的子集为随机事件。比如空集为不可能事件，全集为必然事件。\
**条件概率**：$$P(B|A) = \frac {P(AB)}{P(A)} \qquad P(A) \neq 0$$

![bayes](/files/-M7DeNqZ9zi4v_E62dZ8)

$$P(H|D) = \frac {P(H)P(D|H)}{P(D)}$$

$$P(H|D)$$ 后验概率

$$P(H)$$ 先验概率

$$P(D|H)$$ 似然概率

$$P(D)$$ 边缘概率

## 朴素bayes分类法

对给定的输入x，通过学习到的模型计算后验概率分布$$P(Y=c\_k | X=x)$$,将后验概率最大的类作为x的类输出。

### 新闻分类

$$P(y\_i|X) = \frac {P(X|y\_i)P(y\_i)}{P(X)} = \frac {P(y\_i) \prod\_j P(x\_j|y\_i)}{P(X)}$$

* $$P(y\_i)$$每个类别的先验概率，如P(军事)
* $$P(X|y\_i)$$每个类别产生该对象的概率
* $$P(x\_i|y\_i)$$每个类别产生该特征的概率，如P(苹果|科技)

### 参考佳文

[朴素贝叶斯理论推导与三种常见模型](http://blog.csdn.net/u012162613/article/details/48323777%29%20%20%0A\[贝叶斯学派与频率学派有何不同？]%28https://www.zhihu.com/question/20587681) 细读此文中的 @Xiangyu Wang 和 @秦松雄 回答

[如何通俗地解释贝叶斯线性回归的基本原理？](https://www.zhihu.com/question/22007264) 细读 @dawnmist 的回答

[清华大学计算机系朱军教授：机器学习里的贝叶斯基本理论、模型和算法](https://mp.weixin.qq.com/s?__biz=MzI5NTIxNTg0OA==\&mid=2247485462\&idx=2\&sn=9bc5865a87f8736179d5e0e138e90cdd)\
[基于 AC 自动机和贝叶斯方法的垃圾内容识别](https://zhuanlan.zhihu.com/p/25835417)

[从贝叶斯定理到概率分布：综述概率论基本定义](https://zhuanlan.zhihu.com/p/29503509)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://json007.gitbook.io/svm/bayes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
