朴素贝叶斯(Naïve Bayes)属于监督学习的生成模型,实现简单,没有迭代,学习效率高,在大样本量下会有较好的表现。但因为假设太强——假设特征条件独立,在输入向量的特征条件有关联的场景下并不适用。
1. 朴素贝叶斯算法
朴素贝叶斯分类器的主要思路:通过联合概率
![](https://i-blog.csdnimg.cn/blog_migrate/57fb68d31134593780e5c39ebeb66ec7.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6ed70225f2c1f1f23a2943d0af421ad2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/bbd8a060df0534aaa474a54c90dab235.png)
![](https://i-blog.csdnimg.cn/blog_migrate/3a13c9aa1df53226801f4440689d22b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
;将后验概率最大者对应的的类别作为预测类别。
分类方法
首先,我们定义训练集
![](https://i-blog.csdnimg.cn/blog_migrate/6ed70225f2c1f1f23a2943d0af421ad2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/5dd6ad9677a32c1c974a5401b7307d2e.png)
![](https://i-blog.csdnimg.cn/blog_migrate/c3838f8a515c30575ebccf6da0775b90.png)
![](https://i-blog.csdnimg.cn/blog_migrate/3c017187e73ba76794a360a8d0e7fdcf.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/5afff27d9a807ba051985c56928d4f50.png)
![](https://i-blog.csdnimg.cn/blog_migrate/4705aa4ed4b67dc207476fabd1c4cc78.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/83b735baca293efb604041e83fafa479.png)
![](https://i-blog.csdnimg.cn/blog_migrate/4705aa4ed4b67dc207476fabd1c4cc78.png)
![](https://i-blog.csdnimg.cn/blog_migrate/57df00824fa8929374afebd739d9e0fa.png)
![](https://i-blog.csdnimg.cn/blog_migrate/4705aa4ed4b67dc207476fabd1c4cc78.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/8967c79c6d6149b39a448d3dc528366a.png)
![](https://i-blog.csdnimg.cn/blog_migrate/5882afcf29685d3fb4cc03444b0fa261.png)
![](https://i-blog.csdnimg.cn/blog_migrate/40ffc1d08cd82199e06060768dfd9a03.png)
![](https://i-blog.csdnimg.cn/blog_migrate/742a3933753ca29822d81299f72cc844.png)
![](https://i-blog.csdnimg.cn/blog_migrate/3a13c9aa1df53226801f4440689d22b4.png)
,则预测类别
![](https://i-blog.csdnimg.cn/blog_migrate/bdb34b9f7e952c2ff426b8a865d932a2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/760c8c5d82982babbf450a8f943b127f.png)
![](https://i-blog.csdnimg.cn/blog_migrate/8e719c16b8806be7e85a74c87dfeac76.png)
![](https://i-blog.csdnimg.cn/blog_migrate/ca5819d9b75fb063080a55d62772bd52.png)
![](https://i-blog.csdnimg.cn/blog_migrate/bdb34b9f7e952c2ff426b8a865d932a2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6a5d7587c2bba2ff64838bfdf0b67e37.png)
![](https://i-blog.csdnimg.cn/blog_migrate/2f027a0ab6ea766f2788ab24b907838b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/51a0f5c0a193b72b72e17c00f510dc5d.png)
![](https://i-blog.csdnimg.cn/blog_migrate/32b872421c39024c9af6ba7daa73f28a.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6ed70225f2c1f1f23a2943d0af421ad2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/40827a6398fcec6b551562eca003ceb9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9f56581a9a5046f5b91412b0d2521481.png)
![](https://i-blog.csdnimg.cn/blog_migrate/bbd8a060df0534aaa474a54c90dab235.png)
![](https://i-blog.csdnimg.cn/blog_migrate/3a13c9aa1df53226801f4440689d22b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e2918013f651930d37d12461f46ef48e.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
由贝叶斯定理可知:
![](https://i-blog.csdnimg.cn/blog_migrate/32b872421c39024c9af6ba7daa73f28a.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6ed70225f2c1f1f23a2943d0af421ad2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/40827a6398fcec6b551562eca003ceb9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9f56581a9a5046f5b91412b0d2521481.png)
![](https://i-blog.csdnimg.cn/blog_migrate/bbd8a060df0534aaa474a54c90dab235.png)
![](https://i-blog.csdnimg.cn/blog_migrate/3a13c9aa1df53226801f4440689d22b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/40827a6398fcec6b551562eca003ceb9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/32b872421c39024c9af6ba7daa73f28a.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/3a13c9aa1df53226801f4440689d22b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/bbd8a060df0534aaa474a54c90dab235.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6ed70225f2c1f1f23a2943d0af421ad2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/40827a6398fcec6b551562eca003ceb9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9f56581a9a5046f5b91412b0d2521481.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/32b872421c39024c9af6ba7daa73f28a.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6ed70225f2c1f1f23a2943d0af421ad2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/40827a6398fcec6b551562eca003ceb9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9f56581a9a5046f5b91412b0d2521481.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/32b872421c39024c9af6ba7daa73f28a.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/3a13c9aa1df53226801f4440689d22b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
对于类别
![](https://i-blog.csdnimg.cn/blog_migrate/32b872421c39024c9af6ba7daa73f28a.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/3a13c9aa1df53226801f4440689d22b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e2918013f651930d37d12461f46ef48e.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/bdb34b9f7e952c2ff426b8a865d932a2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/760c8c5d82982babbf450a8f943b127f.png)
![](https://i-blog.csdnimg.cn/blog_migrate/8e719c16b8806be7e85a74c87dfeac76.png)
![](https://i-blog.csdnimg.cn/blog_migrate/ca5819d9b75fb063080a55d62772bd52.png)
![](https://i-blog.csdnimg.cn/blog_migrate/bdb34b9f7e952c2ff426b8a865d932a2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6a5d7587c2bba2ff64838bfdf0b67e37.png)
![](https://i-blog.csdnimg.cn/blog_migrate/2f027a0ab6ea766f2788ab24b907838b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/51a0f5c0a193b72b72e17c00f510dc5d.png)
![](https://i-blog.csdnimg.cn/blog_migrate/32b872421c39024c9af6ba7daa73f28a.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/3a13c9aa1df53226801f4440689d22b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/bbd8a060df0534aaa474a54c90dab235.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6ed70225f2c1f1f23a2943d0af421ad2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/40827a6398fcec6b551562eca003ceb9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9f56581a9a5046f5b91412b0d2521481.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/32b872421c39024c9af6ba7daa73f28a.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6ed70225f2c1f1f23a2943d0af421ad2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/40827a6398fcec6b551562eca003ceb9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9f56581a9a5046f5b91412b0d2521481.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/14dfee35b05e4e5a4f35539d54abc9a9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
从上面式子可以看出:朴素贝叶斯将分类问题转化成了求条件概率与先验概率的最大乘积问题。先验概率
![](https://i-blog.csdnimg.cn/blog_migrate/32b872421c39024c9af6ba7daa73f28a.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/3a13c9aa1df53226801f4440689d22b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/bbd8a060df0534aaa474a54c90dab235.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6ed70225f2c1f1f23a2943d0af421ad2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/40827a6398fcec6b551562eca003ceb9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9f56581a9a5046f5b91412b0d2521481.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
呢?
朴素贝叶斯对条件概率做了条件独立性的假设,即特征条件相互独立。设输入
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/3a13c9aa1df53226801f4440689d22b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/544508939ba782d1cc59ec2498bf3f15.png)
![](https://i-blog.csdnimg.cn/blog_migrate/5afff27d9a807ba051985c56928d4f50.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9b316b45faf090ca0a633dbc25daf9da.png)
![](https://i-blog.csdnimg.cn/blog_migrate/4705aa4ed4b67dc207476fabd1c4cc78.png)
![](https://i-blog.csdnimg.cn/blog_migrate/3a13c9aa1df53226801f4440689d22b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/544508939ba782d1cc59ec2498bf3f15.png)
![](https://i-blog.csdnimg.cn/blog_migrate/83b735baca293efb604041e83fafa479.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9b316b45faf090ca0a633dbc25daf9da.png)
![](https://i-blog.csdnimg.cn/blog_migrate/4705aa4ed4b67dc207476fabd1c4cc78.png)
![](https://i-blog.csdnimg.cn/blog_migrate/57df00824fa8929374afebd739d9e0fa.png)
![](https://i-blog.csdnimg.cn/blog_migrate/4705aa4ed4b67dc207476fabd1c4cc78.png)
![](https://i-blog.csdnimg.cn/blog_migrate/3a13c9aa1df53226801f4440689d22b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/544508939ba782d1cc59ec2498bf3f15.png)
![](https://i-blog.csdnimg.cn/blog_migrate/2b286d3a476809cb9642b1aecf297f14.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9b316b45faf090ca0a633dbc25daf9da.png)
![](https://i-blog.csdnimg.cn/blog_migrate/4705aa4ed4b67dc207476fabd1c4cc78.png)
![](https://i-blog.csdnimg.cn/blog_migrate/57df00824fa8929374afebd739d9e0fa.png)
![](https://i-blog.csdnimg.cn/blog_migrate/4705aa4ed4b67dc207476fabd1c4cc78.png)
![](https://i-blog.csdnimg.cn/blog_migrate/3a13c9aa1df53226801f4440689d22b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/544508939ba782d1cc59ec2498bf3f15.png)
![](https://i-blog.csdnimg.cn/blog_migrate/62edeb113aac23e86a5b0f4224420d35.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9b316b45faf090ca0a633dbc25daf9da.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/d5f60136f8f36763c470eb72b9af67fd.png)
![](https://i-blog.csdnimg.cn/blog_migrate/3a13c9aa1df53226801f4440689d22b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/544508939ba782d1cc59ec2498bf3f15.png)
![](https://i-blog.csdnimg.cn/blog_migrate/2b286d3a476809cb9642b1aecf297f14.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9b316b45faf090ca0a633dbc25daf9da.png)
![](https://i-blog.csdnimg.cn/blog_migrate/3e6bae7341bd271148e16f227f78a805.png)
![](https://i-blog.csdnimg.cn/blog_migrate/2b286d3a476809cb9642b1aecf297f14.png)
![](https://i-blog.csdnimg.cn/blog_migrate/32b872421c39024c9af6ba7daa73f28a.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/3a13c9aa1df53226801f4440689d22b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/bbd8a060df0534aaa474a54c90dab235.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6ed70225f2c1f1f23a2943d0af421ad2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/40827a6398fcec6b551562eca003ceb9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9f56581a9a5046f5b91412b0d2521481.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/40827a6398fcec6b551562eca003ceb9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/a59fa215aafd687ab6d6cd76526f694e.png)
![](https://i-blog.csdnimg.cn/blog_migrate/2b286d3a476809cb9642b1aecf297f14.png)
![](https://i-blog.csdnimg.cn/blog_migrate/32b872421c39024c9af6ba7daa73f28a.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/3a13c9aa1df53226801f4440689d22b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/544508939ba782d1cc59ec2498bf3f15.png)
![](https://i-blog.csdnimg.cn/blog_migrate/2b286d3a476809cb9642b1aecf297f14.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9b316b45faf090ca0a633dbc25daf9da.png)
![](https://i-blog.csdnimg.cn/blog_migrate/bbd8a060df0534aaa474a54c90dab235.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6ed70225f2c1f1f23a2943d0af421ad2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/40827a6398fcec6b551562eca003ceb9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9f56581a9a5046f5b91412b0d2521481.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
等价于
![](https://i-blog.csdnimg.cn/blog_migrate/bdb34b9f7e952c2ff426b8a865d932a2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/760c8c5d82982babbf450a8f943b127f.png)
![](https://i-blog.csdnimg.cn/blog_migrate/8e719c16b8806be7e85a74c87dfeac76.png)
![](https://i-blog.csdnimg.cn/blog_migrate/ca5819d9b75fb063080a55d62772bd52.png)
![](https://i-blog.csdnimg.cn/blog_migrate/bdb34b9f7e952c2ff426b8a865d932a2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6a5d7587c2bba2ff64838bfdf0b67e37.png)
![](https://i-blog.csdnimg.cn/blog_migrate/2f027a0ab6ea766f2788ab24b907838b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/51a0f5c0a193b72b72e17c00f510dc5d.png)
![](https://i-blog.csdnimg.cn/blog_migrate/32b872421c39024c9af6ba7daa73f28a.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6ed70225f2c1f1f23a2943d0af421ad2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/40827a6398fcec6b551562eca003ceb9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9f56581a9a5046f5b91412b0d2521481.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/a59fa215aafd687ab6d6cd76526f694e.png)
![](https://i-blog.csdnimg.cn/blog_migrate/2b286d3a476809cb9642b1aecf297f14.png)
![](https://i-blog.csdnimg.cn/blog_migrate/32b872421c39024c9af6ba7daa73f28a.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/3a13c9aa1df53226801f4440689d22b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/544508939ba782d1cc59ec2498bf3f15.png)
![](https://i-blog.csdnimg.cn/blog_migrate/2b286d3a476809cb9642b1aecf297f14.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9b316b45faf090ca0a633dbc25daf9da.png)
![](https://i-blog.csdnimg.cn/blog_migrate/bbd8a060df0534aaa474a54c90dab235.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6ed70225f2c1f1f23a2943d0af421ad2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/40827a6398fcec6b551562eca003ceb9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9f56581a9a5046f5b91412b0d2521481.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/8abf2272e4fb5fbcabd85544aab70113.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
为什么要选择后验概率最大的类别作为预测类别呢?因为后验概率最大化,可以使得期望风险最小化,具体证明参看[1]。
极大似然估计
在朴素贝叶斯学习中,需要估计先验概率与条件概率,一般时采用极大似然估计。先验概率的极大似然估计:
![](https://i-blog.csdnimg.cn/blog_migrate/32b872421c39024c9af6ba7daa73f28a.png)
![](https://i-blog.csdnimg.cn/blog_migrate/4e6d2aeb77159d500247e648c06450f5.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6ed70225f2c1f1f23a2943d0af421ad2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/40827a6398fcec6b551562eca003ceb9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9f56581a9a5046f5b91412b0d2521481.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/40827a6398fcec6b551562eca003ceb9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e4cd2565d50b380fe5c050d3f1714591.png)
![](https://i-blog.csdnimg.cn/blog_migrate/5dd6ad9677a32c1c974a5401b7307d2e.png)
![](https://i-blog.csdnimg.cn/blog_migrate/58cabd3af27c246c7347f831409fc052.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6ed70225f2c1f1f23a2943d0af421ad2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/5dd6ad9677a32c1c974a5401b7307d2e.png)
![](https://i-blog.csdnimg.cn/blog_migrate/40827a6398fcec6b551562eca003ceb9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9f56581a9a5046f5b91412b0d2521481.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/40ffc1d08cd82199e06060768dfd9a03.png)
其中,
是指示函数,满足括号内条件时为1否则为0;可以看作为计数。
设第
![](https://i-blog.csdnimg.cn/blog_migrate/3c017187e73ba76794a360a8d0e7fdcf.png)
![](https://i-blog.csdnimg.cn/blog_migrate/0a6f93171a2add28afda019bd506c0d8.png)
![](https://i-blog.csdnimg.cn/blog_migrate/2b286d3a476809cb9642b1aecf297f14.png)
![](https://i-blog.csdnimg.cn/blog_migrate/5afff27d9a807ba051985c56928d4f50.png)
![](https://i-blog.csdnimg.cn/blog_migrate/4705aa4ed4b67dc207476fabd1c4cc78.png)
![](https://i-blog.csdnimg.cn/blog_migrate/0a6f93171a2add28afda019bd506c0d8.png)
![](https://i-blog.csdnimg.cn/blog_migrate/2b286d3a476809cb9642b1aecf297f14.png)
![](https://i-blog.csdnimg.cn/blog_migrate/83b735baca293efb604041e83fafa479.png)
![](https://i-blog.csdnimg.cn/blog_migrate/4705aa4ed4b67dc207476fabd1c4cc78.png)
![](https://i-blog.csdnimg.cn/blog_migrate/57df00824fa8929374afebd739d9e0fa.png)
![](https://i-blog.csdnimg.cn/blog_migrate/4705aa4ed4b67dc207476fabd1c4cc78.png)
![](https://i-blog.csdnimg.cn/blog_migrate/0a6f93171a2add28afda019bd506c0d8.png)
![](https://i-blog.csdnimg.cn/blog_migrate/2b286d3a476809cb9642b1aecf297f14.png)
![](https://i-blog.csdnimg.cn/blog_migrate/516c2b6f3d59c18d9ddd1bdc947ee0f0.png)
![](https://i-blog.csdnimg.cn/blog_migrate/5e29d3b611453c7e0dcf304b734b7a0f.png)
![](https://i-blog.csdnimg.cn/blog_migrate/5882afcf29685d3fb4cc03444b0fa261.png)
![](https://i-blog.csdnimg.cn/blog_migrate/d5f60136f8f36763c470eb72b9af67fd.png)
![](https://i-blog.csdnimg.cn/blog_migrate/3a13c9aa1df53226801f4440689d22b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/544508939ba782d1cc59ec2498bf3f15.png)
![](https://i-blog.csdnimg.cn/blog_migrate/2b286d3a476809cb9642b1aecf297f14.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9b316b45faf090ca0a633dbc25daf9da.png)
![](https://i-blog.csdnimg.cn/blog_migrate/40827a6398fcec6b551562eca003ceb9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/0a6f93171a2add28afda019bd506c0d8.png)
![](https://i-blog.csdnimg.cn/blog_migrate/2b286d3a476809cb9642b1aecf297f14.png)
![](https://i-blog.csdnimg.cn/blog_migrate/3c0da26267b19db748fb2c435c960c37.png)
![](https://i-blog.csdnimg.cn/blog_migrate/32b872421c39024c9af6ba7daa73f28a.png)
![](https://i-blog.csdnimg.cn/blog_migrate/4e6d2aeb77159d500247e648c06450f5.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/3a13c9aa1df53226801f4440689d22b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/544508939ba782d1cc59ec2498bf3f15.png)
![](https://i-blog.csdnimg.cn/blog_migrate/2b286d3a476809cb9642b1aecf297f14.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9b316b45faf090ca0a633dbc25daf9da.png)
![](https://i-blog.csdnimg.cn/blog_migrate/40827a6398fcec6b551562eca003ceb9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/0a6f93171a2add28afda019bd506c0d8.png)
![](https://i-blog.csdnimg.cn/blog_migrate/2b286d3a476809cb9642b1aecf297f14.png)
![](https://i-blog.csdnimg.cn/blog_migrate/3c0da26267b19db748fb2c435c960c37.png)
![](https://i-blog.csdnimg.cn/blog_migrate/bbd8a060df0534aaa474a54c90dab235.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6ed70225f2c1f1f23a2943d0af421ad2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/40827a6398fcec6b551562eca003ceb9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9f56581a9a5046f5b91412b0d2521481.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/40827a6398fcec6b551562eca003ceb9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e4cd2565d50b380fe5c050d3f1714591.png)
![](https://i-blog.csdnimg.cn/blog_migrate/5dd6ad9677a32c1c974a5401b7307d2e.png)
![](https://i-blog.csdnimg.cn/blog_migrate/58cabd3af27c246c7347f831409fc052.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/3a13c9aa1df53226801f4440689d22b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/544508939ba782d1cc59ec2498bf3f15.png)
![](https://i-blog.csdnimg.cn/blog_migrate/2b286d3a476809cb9642b1aecf297f14.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9b316b45faf090ca0a633dbc25daf9da.png)
![](https://i-blog.csdnimg.cn/blog_migrate/5dd6ad9677a32c1c974a5401b7307d2e.png)
![](https://i-blog.csdnimg.cn/blog_migrate/40827a6398fcec6b551562eca003ceb9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/0a6f93171a2add28afda019bd506c0d8.png)
![](https://i-blog.csdnimg.cn/blog_migrate/2b286d3a476809cb9642b1aecf297f14.png)
![](https://i-blog.csdnimg.cn/blog_migrate/3c0da26267b19db748fb2c435c960c37.png)
![](https://i-blog.csdnimg.cn/blog_migrate/4705aa4ed4b67dc207476fabd1c4cc78.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6ed70225f2c1f1f23a2943d0af421ad2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/40827a6398fcec6b551562eca003ceb9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9f56581a9a5046f5b91412b0d2521481.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/58cabd3af27c246c7347f831409fc052.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6ed70225f2c1f1f23a2943d0af421ad2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/5dd6ad9677a32c1c974a5401b7307d2e.png)
![](https://i-blog.csdnimg.cn/blog_migrate/40827a6398fcec6b551562eca003ceb9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9f56581a9a5046f5b91412b0d2521481.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
贝叶斯估计
在估计先验概率与条件概率时,有可能出现为0的情况,则计算得到的后验概率亦为0,从而影响分类的效果。因此,需要在估计时做平滑,这种方法被称为贝叶斯估计(Bayesian estimation)。先验概率的贝叶斯估计:
![](https://i-blog.csdnimg.cn/blog_migrate/32b872421c39024c9af6ba7daa73f28a.png)
![](https://i-blog.csdnimg.cn/blog_migrate/4e6d2aeb77159d500247e648c06450f5.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6ed70225f2c1f1f23a2943d0af421ad2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/40827a6398fcec6b551562eca003ceb9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9f56581a9a5046f5b91412b0d2521481.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/40827a6398fcec6b551562eca003ceb9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e4cd2565d50b380fe5c050d3f1714591.png)
![](https://i-blog.csdnimg.cn/blog_migrate/5dd6ad9677a32c1c974a5401b7307d2e.png)
![](https://i-blog.csdnimg.cn/blog_migrate/58cabd3af27c246c7347f831409fc052.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6ed70225f2c1f1f23a2943d0af421ad2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/5dd6ad9677a32c1c974a5401b7307d2e.png)
![](https://i-blog.csdnimg.cn/blog_migrate/40827a6398fcec6b551562eca003ceb9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9f56581a9a5046f5b91412b0d2521481.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6f76ad74e4e3523c5effb945aaa077a6.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6561dda2f0dced00462a2eb0542de1a4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/40ffc1d08cd82199e06060768dfd9a03.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6f76ad74e4e3523c5effb945aaa077a6.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e80f7f32755e1b7cfcafd7aa01b0d934.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6561dda2f0dced00462a2eb0542de1a4.png)
后验概率的贝叶斯估计:
![](https://i-blog.csdnimg.cn/blog_migrate/32b872421c39024c9af6ba7daa73f28a.png)
![](https://i-blog.csdnimg.cn/blog_migrate/4e6d2aeb77159d500247e648c06450f5.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/3a13c9aa1df53226801f4440689d22b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/544508939ba782d1cc59ec2498bf3f15.png)
![](https://i-blog.csdnimg.cn/blog_migrate/2b286d3a476809cb9642b1aecf297f14.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9b316b45faf090ca0a633dbc25daf9da.png)
![](https://i-blog.csdnimg.cn/blog_migrate/40827a6398fcec6b551562eca003ceb9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/0a6f93171a2add28afda019bd506c0d8.png)
![](https://i-blog.csdnimg.cn/blog_migrate/2b286d3a476809cb9642b1aecf297f14.png)
![](https://i-blog.csdnimg.cn/blog_migrate/3c0da26267b19db748fb2c435c960c37.png)
![](https://i-blog.csdnimg.cn/blog_migrate/bbd8a060df0534aaa474a54c90dab235.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6ed70225f2c1f1f23a2943d0af421ad2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/40827a6398fcec6b551562eca003ceb9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9f56581a9a5046f5b91412b0d2521481.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/40827a6398fcec6b551562eca003ceb9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e4cd2565d50b380fe5c050d3f1714591.png)
![](https://i-blog.csdnimg.cn/blog_migrate/5dd6ad9677a32c1c974a5401b7307d2e.png)
![](https://i-blog.csdnimg.cn/blog_migrate/58cabd3af27c246c7347f831409fc052.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/3a13c9aa1df53226801f4440689d22b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/544508939ba782d1cc59ec2498bf3f15.png)
![](https://i-blog.csdnimg.cn/blog_migrate/2b286d3a476809cb9642b1aecf297f14.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9b316b45faf090ca0a633dbc25daf9da.png)
![](https://i-blog.csdnimg.cn/blog_migrate/5dd6ad9677a32c1c974a5401b7307d2e.png)
![](https://i-blog.csdnimg.cn/blog_migrate/40827a6398fcec6b551562eca003ceb9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/0a6f93171a2add28afda019bd506c0d8.png)
![](https://i-blog.csdnimg.cn/blog_migrate/2b286d3a476809cb9642b1aecf297f14.png)
![](https://i-blog.csdnimg.cn/blog_migrate/3c0da26267b19db748fb2c435c960c37.png)
![](https://i-blog.csdnimg.cn/blog_migrate/4705aa4ed4b67dc207476fabd1c4cc78.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6ed70225f2c1f1f23a2943d0af421ad2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/40827a6398fcec6b551562eca003ceb9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9f56581a9a5046f5b91412b0d2521481.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6f76ad74e4e3523c5effb945aaa077a6.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6561dda2f0dced00462a2eb0542de1a4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/58cabd3af27c246c7347f831409fc052.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6ed70225f2c1f1f23a2943d0af421ad2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/5dd6ad9677a32c1c974a5401b7307d2e.png)
![](https://i-blog.csdnimg.cn/blog_migrate/40827a6398fcec6b551562eca003ceb9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9f56581a9a5046f5b91412b0d2521481.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6f76ad74e4e3523c5effb945aaa077a6.png)
![](https://i-blog.csdnimg.cn/blog_migrate/3e6bae7341bd271148e16f227f78a805.png)
![](https://i-blog.csdnimg.cn/blog_migrate/2b286d3a476809cb9642b1aecf297f14.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6561dda2f0dced00462a2eb0542de1a4.png)
常取
,这时被称为Laplace平滑(Laplace smoothing)。下面提到的拼写检查则用到了Laplace平滑——初始时将所有单词的计数置为1。
2. 拼写检查
当用户在输入拼写错误单词时,如何返回他想输入的拼写正确单词。比如,用户输入单词thew
,用户有到底是想输入the
,还是想输入thaw
?这种拼写检查的问题等同于分类问题:在许多可能拼写正确单词中,到底哪一个时最有可能的呢?大神Peter Norvig [2]采用朴素贝叶斯解决这个拼写问题。
朴素贝叶斯分类
设用户输入的单词为
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/bdb34b9f7e952c2ff426b8a865d932a2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/760c8c5d82982babbf450a8f943b127f.png)
![](https://i-blog.csdnimg.cn/blog_migrate/8e719c16b8806be7e85a74c87dfeac76.png)
![](https://i-blog.csdnimg.cn/blog_migrate/ca5819d9b75fb063080a55d62772bd52.png)
![](https://i-blog.csdnimg.cn/blog_migrate/bdb34b9f7e952c2ff426b8a865d932a2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6a5d7587c2bba2ff64838bfdf0b67e37.png)
![](https://i-blog.csdnimg.cn/blog_migrate/2f027a0ab6ea766f2788ab24b907838b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/32b872421c39024c9af6ba7daa73f28a.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/bbd8a060df0534aaa474a54c90dab235.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1bf1b29f2cbe7158ef1bbfcdf0d6bb10.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1bf1b29f2cbe7158ef1bbfcdf0d6bb10.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/32b872421c39024c9af6ba7daa73f28a.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/bbd8a060df0534aaa474a54c90dab235.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1bf1b29f2cbe7158ef1bbfcdf0d6bb10.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/40827a6398fcec6b551562eca003ceb9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/32b872421c39024c9af6ba7daa73f28a.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1bf1b29f2cbe7158ef1bbfcdf0d6bb10.png)
![](https://i-blog.csdnimg.cn/blog_migrate/bbd8a060df0534aaa474a54c90dab235.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/32b872421c39024c9af6ba7daa73f28a.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/32b872421c39024c9af6ba7daa73f28a.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1bf1b29f2cbe7158ef1bbfcdf0d6bb10.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
贝叶斯分类器可表示为:
![](https://i-blog.csdnimg.cn/blog_migrate/bdb34b9f7e952c2ff426b8a865d932a2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/760c8c5d82982babbf450a8f943b127f.png)
![](https://i-blog.csdnimg.cn/blog_migrate/8e719c16b8806be7e85a74c87dfeac76.png)
![](https://i-blog.csdnimg.cn/blog_migrate/ca5819d9b75fb063080a55d62772bd52.png)
![](https://i-blog.csdnimg.cn/blog_migrate/bdb34b9f7e952c2ff426b8a865d932a2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6a5d7587c2bba2ff64838bfdf0b67e37.png)
![](https://i-blog.csdnimg.cn/blog_migrate/2f027a0ab6ea766f2788ab24b907838b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/32b872421c39024c9af6ba7daa73f28a.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1bf1b29f2cbe7158ef1bbfcdf0d6bb10.png)
![](https://i-blog.csdnimg.cn/blog_migrate/bbd8a060df0534aaa474a54c90dab235.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/32b872421c39024c9af6ba7daa73f28a.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
如何估计
![](https://i-blog.csdnimg.cn/blog_migrate/32b872421c39024c9af6ba7daa73f28a.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/32b872421c39024c9af6ba7daa73f28a.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/32b872421c39024c9af6ba7daa73f28a.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1bf1b29f2cbe7158ef1bbfcdf0d6bb10.png)
![](https://i-blog.csdnimg.cn/blog_migrate/bbd8a060df0534aaa474a54c90dab235.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1bf1b29f2cbe7158ef1bbfcdf0d6bb10.png)
![](https://i-blog.csdnimg.cn/blog_migrate/32b872421c39024c9af6ba7daa73f28a.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ea9a2d81b5b44bd195fe6c3dc5e24b4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1bf1b29f2cbe7158ef1bbfcdf0d6bb10.png)
![](https://i-blog.csdnimg.cn/blog_migrate/bbd8a060df0534aaa474a54c90dab235.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9a754f299fb97260010ce70a4f5f8c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9ed0afb572bef457b579d4cf61879e9b.png)
估计得较为准确。Norvig对此做了简易化的处理:
- 统计所有与
- 编辑距离为1的拼写正确单词,选出在文本库中频率最高者;
- 若未找到与
编辑距离为1的拼写正确单词,则统计所有与
- 编辑距离为2的拼写正确单词,选出在文本库中频率最高者
- 若与
编辑距离为2的拼写正确单词也未找到,则返回
- (即分类失败)。
所谓编辑距离为1,指单词可以通过增加、删除、修改(一个字母)或交换(相邻两个字母)变成另外的单词。上述处理办法默认了:编辑距离为1的拼写正确单词永远比编辑距离为2的更有可能。
存在问题
Norvig所介绍的拼写检查是非常简单的一种,他在博文[2]中指出不足。此外,还有一些需要优化的地方:
- 上下文关联,比如输入
thew
,在不同的上下文中可能返回的拼写正确单词不同; - 输入媒介,比如用户用键盘输入与用手机的九宫格输入,其拼写错误的方式时不一样的。
3. 参考资料
[1] 李航,《统计学习方法》.
[2] Peter Norvig, How to Write a Spelling Corrector.