`
lindexi-gd
  • 浏览: 140102 次
社区版块
存档分类
最新评论

数据挖掘 贝叶斯算法

 
阅读更多

贝叶斯算法

朴素贝叶斯分类是一种十分简单的分类算法,叫它朴素贝叶斯分类是因为这种方法的思想真的很朴素,朴素贝叶斯的思想基础是这样的:对于给出的待分类项,求解在此项出现的条件下各个类别出现的概率,哪个最大,就认为此待分类项属于哪个类别。

贝叶斯的公式很简单,其实就是<nobr><span class="math" id="MathJax-Span-35558" style="width: 4.163em; display: inline-block;"><span style="display: inline-block; position: relative; width: 3.309em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.869em 1000em 3.203em -0.424em); top: -2.771em; left: 0.003em;"><span class="mrow" id="MathJax-Span-35559"><span class="mi" id="MathJax-Span-35560" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-35561" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-35562" style="font-family: MathJax_Math-italic;">A</span><span class="texatom" id="MathJax-Span-35563"><span class="mrow" id="MathJax-Span-35564"><span class="mo" id="MathJax-Span-35565" style="font-family: MathJax_Main;">|</span></span></span><span class="mi" id="MathJax-Span-35566" style="font-family: MathJax_Math-italic;">B</span><span class="mo" id="MathJax-Span-35567" style="font-family: MathJax_Main;">)</span></span><span style="display: inline-block; width: 0px; height: 2.776em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.403em; vertical-align: -0.397em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-1956">P(A|B)</script>就是在B已经发生的情况,A发生的概率,这个概率<nobr><span class="math" id="MathJax-Span-35568" style="width: 13.016em; display: inline-block;"><span style="display: inline-block; position: relative; width: 10.403em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.869em 1000em 3.203em -0.424em); top: -2.771em; left: 0.003em;"><span class="mrow" id="MathJax-Span-35569"><span class="mi" id="MathJax-Span-35570" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-35571" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-35572" style="font-family: MathJax_Math-italic;">A</span><span class="texatom" id="MathJax-Span-35573"><span class="mrow" id="MathJax-Span-35574"><span class="mo" id="MathJax-Span-35575" style="font-family: MathJax_Main;">|</span></span></span><span class="mi" id="MathJax-Span-35576" style="font-family: MathJax_Math-italic;">B</span><span class="mo" id="MathJax-Span-35577" style="font-family: MathJax_Main;">)</span><span class="mo" id="MathJax-Span-35578" style="font-family: MathJax_Main; padding-left: 0.269em;">=</span><span class="mi" id="MathJax-Span-35579" style="font-family: MathJax_Math-italic; padding-left: 0.269em;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-35580" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-35581" style="font-family: MathJax_Math-italic;">A</span><span class="mi" id="MathJax-Span-35582" style="font-family: MathJax_Math-italic;">B</span><span class="mo" id="MathJax-Span-35583" style="font-family: MathJax_Main;">)</span><span class="texatom" id="MathJax-Span-35584"><span class="mrow" id="MathJax-Span-35585"><span class="mo" id="MathJax-Span-35586" style="font-family: MathJax_Main;">/</span></span></span><span class="mi" id="MathJax-Span-35587" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-35588" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-35589" style="font-family: MathJax_Math-italic;">B</span><span class="mo" id="MathJax-Span-35590" style="font-family: MathJax_Main;">)</span></span><span style="display: inline-block; width: 0px; height: 2.776em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.403em; vertical-align: -0.397em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-1957">P(A|B)=P(AB)/P(B)</script>在发生B的概率中,AB一起发生的概率就是<nobr><span class="math" id="MathJax-Span-35591" style="width: 4.163em; display: inline-block;"><span style="display: inline-block; position: relative; width: 3.309em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.869em 1000em 3.203em -0.424em); top: -2.771em; left: 0.003em;"><span class="mrow" id="MathJax-Span-35592"><span class="mi" id="MathJax-Span-35593" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-35594" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-35595" style="font-family: MathJax_Math-italic;">A</span><span class="texatom" id="MathJax-Span-35596"><span class="mrow" id="MathJax-Span-35597"><span class="mo" id="MathJax-Span-35598" style="font-family: MathJax_Main;">|</span></span></span><span class="mi" id="MathJax-Span-35599" style="font-family: MathJax_Math-italic;">B</span><span class="mo" id="MathJax-Span-35600" style="font-family: MathJax_Main;">)</span></span><span style="display: inline-block; width: 0px; height: 2.776em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.403em; vertical-align: -0.397em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-1958">P(A|B)</script>。

那么贝叶斯公式<nobr><span class="math" id="MathJax-Span-35601" style="width: 16.216em; display: inline-block;"><span style="display: inline-block; position: relative; width: 12.963em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.869em 1000em 3.203em -0.424em); top: -2.771em; left: 0.003em;"><span class="mrow" id="MathJax-Span-35602"><span class="mi" id="MathJax-Span-35603" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-35604" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-35605" style="font-family: MathJax_Math-italic;">B</span><span class="texatom" id="MathJax-Span-35606"><span class="mrow" id="MathJax-Span-35607"><span class="mo" id="MathJax-Span-35608" style="font-family: MathJax_Main;">|</span></span></span><span class="mi" id="MathJax-Span-35609" style="font-family: MathJax_Math-italic;">A</span><span class="mo" id="MathJax-Span-35610" style="font-family: MathJax_Main;">)</span><span class="mo" id="MathJax-Span-35611" style="font-family: MathJax_Main; padding-left: 0.269em;">=</span><span class="mi" id="MathJax-Span-35612" style="font-family: MathJax_Math-italic; padding-left: 0.269em;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-35613" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-35614" style="font-family: MathJax_Math-italic;">A</span><span class="texatom" id="MathJax-Span-35615"><span class="mrow" id="MathJax-Span-35616"><span class="mo" id="MathJax-Span-35617" style="font-family: MathJax_Main;">|</span></span></span><span class="mi" id="MathJax-Span-35618" style="font-family: MathJax_Math-italic;">B</span><span class="mo" id="MathJax-Span-35619" style="font-family: MathJax_Main;">)</span><span class="mi" id="MathJax-Span-35620" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-35621" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-35622" style="font-family: MathJax_Math-italic;">B</span><span class="mo" id="MathJax-Span-35623" style="font-family: MathJax_Main;">)</span><span class="texatom" id="MathJax-Span-35624"><span class="mrow" id="MathJax-Span-35625"><span class="mo" id="MathJax-Span-35626" style="font-family: MathJax_Main;">/</span></span></span><span class="mi" id="MathJax-Span-35627" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-35628" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-35629" style="font-family: MathJax_Math-italic;">A</span><span class="mo" id="MathJax-Span-35630" style="font-family: MathJax_Main;">)</span></span><span style="display: inline-block; width: 0px; height: 2.776em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.403em; vertical-align: -0.397em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-1959">P(B|A)=P(A|B)P(B)/P(A)</script>,朴素贝叶斯公式,依靠之前存在的事件,推测出当前在A发生下B发生的概率,因为从<nobr><span class="math" id="MathJax-Span-35631" style="width: 4.163em; display: inline-block;"><span style="display: inline-block; position: relative; width: 3.309em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.869em 1000em 3.203em -0.424em); top: -2.771em; left: 0.003em;"><span class="mrow" id="MathJax-Span-35632"><span class="mi" id="MathJax-Span-35633" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-35634" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-35635" style="font-family: MathJax_Math-italic;">A</span><span class="texatom" id="MathJax-Span-35636"><span class="mrow" id="MathJax-Span-35637"><span class="mo" id="MathJax-Span-35638" style="font-family: MathJax_Main;">|</span></span></span><span class="mi" id="MathJax-Span-35639" style="font-family: MathJax_Math-italic;">B</span><span class="mo" id="MathJax-Span-35640" style="font-family: MathJax_Main;">)</span></span><span style="display: inline-block; width: 0px; height: 2.776em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.403em; vertical-align: -0.397em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-1960">P(A|B)</script>是简单的。

那么看我说的有些主观,让我们看例子

一所学校里面有 60% 的男生,40% 的女生。男生总是穿长裤,女生则一半穿长裤一半穿裙子。有了这些信息之后我们可以容易地计算“随机选取一个学生,他(她)穿长裤的概率和穿裙子的概率是多大”,这个就是前面说的“正向概率”的计算。然而,假设你走在校园中,迎面走来一个穿长裤的学生(很不幸的是你高度近似,你只看得见他(她)穿的是否长裤,而无法确定他(她)的性别),你能够推断出他(她)是男生的概率是多大吗?

那么数据挖掘,我们有一个要我们分类的x,他有属性a1、a2

<nobr><span class="math" id="MathJax-Span-35641" style="width: 10.829em; display: inline-block;"><span style="display: inline-block; position: relative; width: 8.643em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.869em 1000em 3.203em -0.424em); top: -2.771em; left: 0.003em;"><span class="mrow" id="MathJax-Span-35642"><span class="mi" id="MathJax-Span-35643" style="font-family: MathJax_Math-italic;">x</span><span class="mo" id="MathJax-Span-35644" style="font-family: MathJax_Main; padding-left: 0.269em;">=</span><span class="mo" id="MathJax-Span-35645" style="font-family: MathJax_Main; padding-left: 0.269em;">{</span><span class="msubsup" id="MathJax-Span-35646"><span style="display: inline-block; position: relative; width: 0.963em; height: 0px;"><span style="position: absolute; clip: rect(1.976em 1000em 2.723em -0.424em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-35647" style="font-family: MathJax_Math-italic;">a</span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.291em; left: 0.536em;"><span class="mn" id="MathJax-Span-35648" style="font-size: 70.7%; font-family: MathJax_Main;">1</span><span style="display: inline-block; width: 0px; height: 2.456em;"></span></span></span></span><span class="mo" id="MathJax-Span-35649" style="font-family: MathJax_Main;">,</span><span class="msubsup" id="MathJax-Span-35650" style="padding-left: 0.163em;"><span style="display: inline-block; position: relative; width: 0.963em; height: 0px;"><span style="position: absolute; clip: rect(1.976em 1000em 2.723em -0.424em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-35651" style="font-family: MathJax_Math-italic;">a</span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.291em; left: 0.536em;"><span class="mn" id="MathJax-Span-35652" style="font-size: 70.7%; font-family: MathJax_Main;">2</span><span style="display: inline-block; width: 0px; height: 2.456em;"></span></span></span></span><span class="mo" id="MathJax-Span-35653" style="font-family: MathJax_Main;">,</span><span class="mo" id="MathJax-Span-35654" style="font-family: MathJax_Main; padding-left: 0.163em;">…</span><span class="mo" id="MathJax-Span-35655" style="font-family: MathJax_Main; padding-left: 0.163em;">,</span><span class="msubsup" id="MathJax-Span-35656" style="padding-left: 0.163em;"><span style="display: inline-block; position: relative; width: 1.229em; height: 0px;"><span style="position: absolute; clip: rect(1.976em 1000em 2.723em -0.424em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-35657" style="font-family: MathJax_Math-italic;">a</span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.291em; left: 0.536em;"><span class="mi" id="MathJax-Span-35658" style="font-size: 70.7%; font-family: MathJax_Math-italic;">m</span><span style="display: inline-block; width: 0px; height: 2.456em;"></span></span></span></span><span class="mo" id="MathJax-Span-35659" style="font-family: MathJax_Main;">}</span></span><span style="display: inline-block; width: 0px; height: 2.776em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.403em; vertical-align: -0.397em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-1961"> x=\{a_1 , a_2,…,a_m\} </script>

我们还有各种类<nobr><span class="math" id="MathJax-Span-35660" style="width: 10.776em; display: inline-block;"><span style="display: inline-block; position: relative; width: 8.589em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.869em 1000em 3.203em -0.424em); top: -2.771em; left: 0.003em;"><span class="mrow" id="MathJax-Span-35661"><span class="mi" id="MathJax-Span-35662" style="font-family: MathJax_Math-italic;">C<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mo" id="MathJax-Span-35663" style="font-family: MathJax_Main; padding-left: 0.269em;">=</span><span class="mo" id="MathJax-Span-35664" style="font-family: MathJax_Main; padding-left: 0.269em;">{</span><span class="msubsup" id="MathJax-Span-35665"><span style="display: inline-block; position: relative; width: 0.963em; height: 0px;"><span style="position: absolute; clip: rect(1.976em 1000em 2.936em -0.477em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-35666" style="font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.184em; left: 0.536em;"><span class="mn" id="MathJax-Span-35667" style="font-size: 70.7%; font-family: MathJax_Main;">1</span><span style="display: inline-block; width: 0px; height: 2.456em;"></span></span></span></span><span class="mo" id="MathJax-Span-35668" style="font-family: MathJax_Main;">,</span><span class="msubsup" id="MathJax-Span-35669" style="padding-left: 0.163em;"><span style="display: inline-block; position: relative; width: 0.963em; height: 0px;"><span style="position: absolute; clip: rect(1.976em 1000em 2.936em -0.477em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-35670" style="font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.184em; left: 0.536em;"><span class="mn" id="MathJax-Span-35671" style="font-size: 70.7%; font-family: MathJax_Main;">2</span><span style="display: inline-block; width: 0px; height: 2.456em;"></span></span></span></span><span class="mo" id="MathJax-Span-35672" style="font-family: MathJax_Main;">,</span><span class="mo" id="MathJax-Span-35673" style="font-family: MathJax_Main; padding-left: 0.163em;">…</span><span class="mo" id="MathJax-Span-35674" style="font-family: MathJax_Main; padding-left: 0.163em;">,</span><span class="msubsup" id="MathJax-Span-35675" style="padding-left: 0.163em;"><span style="display: inline-block; position: relative; width: 1.016em; height: 0px;"><span style="position: absolute; clip: rect(1.976em 1000em 2.936em -0.477em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-35676" style="font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.184em; left: 0.536em;"><span class="mi" id="MathJax-Span-35677" style="font-size: 70.7%; font-family: MathJax_Math-italic;">n</span><span style="display: inline-block; width: 0px; height: 2.456em;"></span></span></span></span><span class="mo" id="MathJax-Span-35678" style="font-family: MathJax_Main;">}</span></span><span style="display: inline-block; width: 0px; height: 2.776em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.403em; vertical-align: -0.397em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-1962">C=\{y_1,y_2,…,y_n\}</script>

我们计算出<nobr><span class="math" id="MathJax-Span-35679" style="width: 14.616em; display: inline-block;"><span style="display: inline-block; position: relative; width: 11.683em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.869em 1000em 3.203em -0.424em); top: -2.771em; left: 0.003em;"><span class="mrow" id="MathJax-Span-35680"><span class="mi" id="MathJax-Span-35681" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-35682" style="font-family: MathJax_Main;">(</span><span class="msubsup" id="MathJax-Span-35683"><span style="display: inline-block; position: relative; width: 0.963em; height: 0px;"><span style="position: absolute; clip: rect(1.976em 1000em 2.936em -0.477em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-35684" style="font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.184em; left: 0.536em;"><span class="mn" id="MathJax-Span-35685" style="font-size: 70.7%; font-family: MathJax_Main;">1</span><span style="display: inline-block; width: 0px; height: 2.456em;"></span></span></span></span><span class="texatom" id="MathJax-Span-35686"><span class="mrow" id="MathJax-Span-35687"><span class="mo" id="MathJax-Span-35688" style="font-family: MathJax_Main;">|</span></span></span><span class="mi" id="MathJax-Span-35689" style="font-family: MathJax_Math-italic;">x</span><span class="mo" id="MathJax-Span-35690" style="font-family: MathJax_Main;">)</span><span class="mo" id="MathJax-Span-35691" style="font-family: MathJax_Main;">,</span><span class="mi" id="MathJax-Span-35692" style="font-family: MathJax_Math-italic; padding-left: 0.163em;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-35693" style="font-family: MathJax_Main;">(</span><span class="msubsup" id="MathJax-Span-35694"><span style="display: inline-block; position: relative; width: 0.963em; height: 0px;"><span style="position: absolute; clip: rect(1.976em 1000em 2.936em -0.477em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-35695" style="font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.184em; left: 0.536em;"><span class="mn" id="MathJax-Span-35696" style="font-size: 70.7%; font-family: MathJax_Main;">2</span><span style="display: inline-block; width: 0px; height: 2.456em;"></span></span></span></span><span class="texatom" id="MathJax-Span-35697"><span class="mrow" id="MathJax-Span-35698"><span class="mo" id="MathJax-Span-35699" style="font-family: MathJax_Main;">|</span></span></span><span class="mi" id="MathJax-Span-35700" style="font-family: MathJax_Math-italic;">x</span><span class="mo" id="MathJax-Span-35701" style="font-family: MathJax_Main;">)</span><span class="mo" id="MathJax-Span-35702" style="font-family: MathJax_Main;">,</span><span class="mtext" id="MathJax-Span-35703" style="font-family: MathJax_Main; padding-left: 0.163em;"></span><span class="mtext" id="MathJax-Span-35704" style="font-family: MathJax_Main;"></span><span class="mtext" id="MathJax-Span-35705" style="font-family: MathJax_Main;"></span><span class="mi" id="MathJax-Span-35706" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-35707" style="font-family: MathJax_Main;">(</span><span class="msubsup" id="MathJax-Span-35708"><span style="display: inline-block; position: relative; width: 1.016em; height: 0px;"><span style="position: absolute; clip: rect(1.976em 1000em 2.936em -0.477em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-35709" style="font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.184em; left: 0.536em;"><span class="mi" id="MathJax-Span-35710" style="font-size: 70.7%; font-family: MathJax_Math-italic;">n</span><span style="display: inline-block; width: 0px; height: 2.456em;"></span></span></span></span><span class="texatom" id="MathJax-Span-35711"><span class="mrow" id="MathJax-Span-35712"><span class="mo" id="MathJax-Span-35713" style="font-family: MathJax_Main;">|</span></span></span><span class="mi" id="MathJax-Span-35714" style="font-family: MathJax_Math-italic;">x</span><span class="mo" id="MathJax-Span-35715" style="font-family: MathJax_Main;">)</span></span><span style="display: inline-block; width: 0px; height: 2.776em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.403em; vertical-align: -0.397em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-1963">P(y_1|x),P(y_2|x),\ \ \ P(y_n|x)</script>

那么得到最大的一个<nobr><span class="math" id="MathJax-Span-35716" style="width: 4.216em; display: inline-block;"><span style="display: inline-block; position: relative; width: 3.363em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.869em 1000em 3.203em -0.424em); top: -2.771em; left: 0.003em;"><span class="mrow" id="MathJax-Span-35717"><span class="mi" id="MathJax-Span-35718" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-35719" style="font-family: MathJax_Main;">(</span><span class="msubsup" id="MathJax-Span-35720"><span style="display: inline-block; position: relative; width: 0.963em; height: 0px;"><span style="position: absolute; clip: rect(1.976em 1000em 2.936em -0.477em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-35721" style="font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.184em; left: 0.536em;"><span class="mi" id="MathJax-Span-35722" style="font-size: 70.7%; font-family: MathJax_Math-italic;">k</span><span style="display: inline-block; width: 0px; height: 2.456em;"></span></span></span></span><span class="texatom" id="MathJax-Span-35723"><span class="mrow" id="MathJax-Span-35724"><span class="mo" id="MathJax-Span-35725" style="font-family: MathJax_Main;">|</span></span></span><span class="mi" id="MathJax-Span-35726" style="font-family: MathJax_Math-italic;">x</span><span class="mo" id="MathJax-Span-35727" style="font-family: MathJax_Main;">)</span></span><span style="display: inline-block; width: 0px; height: 2.776em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.403em; vertical-align: -0.397em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-1964">P(y_k|x)</script>就是我们x的类别。

简单的,假如我们按照某人是否打球来划分天气。

这个例子数据挖掘

Day

Outlook

Temperature

Humidity

Wind

PlayTennis

D1

Sunny

Hot

High

Weak

No

D2

Sunny

Hot

High

Strong

No

D3

Overcast

Hot

High

Weak

Yes

D4

Rain

Mild

High

Weak

Yes

D5

Rain

Cool

Normal

Weak

Yes

D6

Rain

Cool

Normal

Strong

No

D7

Overcast

Cool

Normal

Strong

Yes

D8

Sunny

Mild

High

Weak

No

D9

Sunny

Cool

Normal

Weak

Yes

D10

Rain

Mild

Normal

Weak

Yes

D11

Sunny

Mild

Normal

Strong

Yes

D12

Overcast

Mild

High

Strong

Yes

D13

Overcast

Hot

Normal

Weak

Yes

D14

Rain

Mild

High

Strong

No

我们要分类Outlook=sunny, Temperature=cool,Humidity=high,Wind=strong

那么我们首先算出所有

<nobr><span class="math" id="MathJax-Span-35728" style="width: 100%; display: inline-block; min-width: 7.896em;"><span style="display: inline-block; position: relative; width: 100%; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(3.096em 1000em 5.869em -0.477em); top: -3.997em; left: 0.003em; width: 100%;"><span class="mrow" id="MathJax-Span-35729"><span style="display: inline-block; position: relative; width: 100%; height: 0px;"><span style="position: absolute; clip: rect(3.096em 1000em 4.429em -0.424em); top: -3.997em; left: 50%; margin-left: -3.144em;"><span class="mi" id="MathJax-Span-35730" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-35731" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-35732" style="font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-35733" style="font-family: MathJax_Math-italic;">e</span><span class="mi" id="MathJax-Span-35734" style="font-family: MathJax_Math-italic;">s</span><span class="mo" id="MathJax-Span-35735" style="font-family: MathJax_Main;">)</span><span class="mo" id="MathJax-Span-35736" style="font-family: MathJax_Main; padding-left: 0.269em;">=</span><span class="mn" id="MathJax-Span-35737" style="font-family: MathJax_Main; padding-left: 0.269em;">9</span><span class="texatom" id="MathJax-Span-35738"><span class="mrow" id="MathJax-Span-35739"><span class="mo" id="MathJax-Span-35740" style="font-family: MathJax_Main;">/</span></span></span><span class="mn" id="MathJax-Span-35741" style="font-family: MathJax_Main;">14</span><span style="display: inline-block; width: 0px; height: 4.003em;"></span></span><span style="position: absolute; clip: rect(3.096em 1000em 4.429em -0.477em); top: -2.557em; left: 50%; margin-left: -2.984em;"><span class="mspace" id="MathJax-Span-35742" style="height: 0.003em; vertical-align: 0.003em; width: 0.003em; display: inline-block; overflow: hidden;"></span><span class="mi" id="MathJax-Span-35743" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-35744" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-35745" style="font-family: MathJax_Math-italic;">n</span><span class="mi" id="MathJax-Span-35746" style="font-family: MathJax_Math-italic;">o</span><span class="mo" id="MathJax-Span-35747" style="font-family: MathJax_Main;">)</span><span class="mo" id="MathJax-Span-35748" style="font-family: MathJax_Main; padding-left: 0.269em;">=</span><span class="mn" id="MathJax-Span-35749" style="font-family: MathJax_Main; padding-left: 0.269em;">5</span><span class="texatom" id="MathJax-Span-35750"><span class="mrow" id="MathJax-Span-35751"><span class="mo" id="MathJax-Span-35752" style="font-family: MathJax_Main;">/</span></span></span><span class="mn" id="MathJax-Span-35753" style="font-family: MathJax_Main;">14</span><span style="display: inline-block; width: 0px; height: 4.003em;"></span></span></span></span><span style="display: inline-block; width: 0px; height: 4.003em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 3.203em; vertical-align: -2.197em;"></span></span></nobr>
<script type="math/tex; mode=display" id="MathJax-Element-1965"> P(yes)=9/14 \\ P(no)=5/14 </script>

然后就是每个列属性
Outlook

Outlook==Sunny 有5个,其中

<nobr><span class="math" id="MathJax-Span-60571" style="width: 100%; display: inline-block; min-width: 25.069em;"><span style="display: inline-block; position: relative; width: 100%; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(4.696em 1000em 10.349em -0.477em); top: -6.344em; left: 0.003em; width: 100%;"><span class="mrow" id="MathJax-Span-60572"><span style="display: inline-block; position: relative; width: 100%; height: 0px;"><span style="position: absolute; clip: rect(2.349em 1000em 5.123em -0.424em); top: -3.997em; left: 50%; margin-left: -10.024em;"><span class="mi" id="MathJax-Span-60573" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-60574" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-60575" style="font-family: MathJax_Math-italic;">S<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mi" id="MathJax-Span-60576" style="font-family: MathJax_Math-italic;">u</span><span class="mi" id="MathJax-Span-60577" style="font-family: MathJax_Math-italic;">n</span><span class="mi" id="MathJax-Span-60578" style="font-family: MathJax_Math-italic;">n</span><span class="mi" id="MathJax-Span-60579" style="font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="texatom" id="MathJax-Span-60580"><span class="mrow" id="MathJax-Span-60581"><span class="mo" id="MathJax-Span-60582" style="font-family: MathJax_Main;">|</span></span></span><span class="mi" id="MathJax-Span-60583" style="font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-60584" style="font-family: MathJax_Math-italic;">e</span><span class="mi" id="MathJax-Span-60585" style="font-family: MathJax_Math-italic;">s</span><span class="mo" id="MathJax-Span-60586" style="font-family: MathJax_Main;">)</span><span class="mo" id="MathJax-Span-60587" style="font-family: MathJax_Main; padding-left: 0.269em;">=</span><span class="mfrac" id="MathJax-Span-60588" style="padding-left: 0.269em;"><span style="display: inline-block; position: relative; width: 5.816em; height: 0px; margin-right: 0.109em; margin-left: 0.109em;"><span style="position: absolute; clip: rect(1.869em 1000em 3.203em -0.424em); top: -3.517em; left: 50%; margin-left: -2.824em;"><span class="mrow" id="MathJax-Span-60589"><span class="mi" id="MathJax-Span-60590" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-60591" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-60592" style="font-family: MathJax_Math-italic;">s</span><span class="mi" id="MathJax-Span-60593" style="font-family: MathJax_Math-italic;">u</span><span class="mi" id="MathJax-Span-60594" style="font-family: MathJax_Math-italic;">n</span><span class="mi" id="MathJax-Span-60595" style="font-family: MathJax_Math-italic;">n</span><span class="mi" id="MathJax-Span-60596" style="font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-60597" style="font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-60598" style="font-family: MathJax_Math-italic;">e</span><span class="mi" id="MathJax-Span-60599" style="font-family: MathJax_Math-italic;">s</span><span class="mo" id="MathJax-Span-60600" style="font-family: MathJax_Main;">)</span></span><span style="display: inline-block; width: 0px; height: 2.776em;"></span></span><span style="position: absolute; clip: rect(1.869em 1000em 3.203em -0.424em); top: -2.024em; left: 50%; margin-left: -1.437em;"><span class="mrow" id="MathJax-Span-60601"><span class="mi" id="MathJax-Span-60602" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-60603" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-60604" style="font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-60605" style="font-family: MathJax_Math-italic;">e</span><span class="mi" id="MathJax-Span-60606" style="font-family: MathJax_Math-italic;">s</span><span class="mo" id="MathJax-Span-60607" style="font-family: MathJax_Main;">)</span></span><span style="display: inline-block; width: 0px; height: 2.776em;"></span></span><span style="position: absolute; clip: rect(0.856em 1000em 1.229em -0.477em); top: -1.277em; left: 0.003em;"><span style="border-left-width: 5.816em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.25px; vertical-align: 0.003em;"></span><span style="display: inline-block; width: 0px; height: 1.069em;"></span></span></span></span><span class="mo" id="MathJax-Span-60608" style="font-family: MathJax_Main; padding-left: 0.269em;">=</span><span class="mfrac" id="MathJax-Span-60609" style="padding-left: 0.269em;"><span style="display: inline-block; position: relative; width: 2.136em; height: 0px; margin-right: 0.109em; margin-left: 0.109em;"><span style="position: absolute; clip: rect(1.869em 1000em 3.203em -0.424em); top: -3.517em; left: 50%; margin-left: -1.011em;"><span class="mrow" id="MathJax-Span-60610"><span class="mn" id="MathJax-Span-60611" style="font-family: MathJax_Main;">2</span><span class="texatom" id="MathJax-Span-60612"><span class="mrow" id="MathJax-Span-60613"><span class="mo" id="MathJax-Span-60614" style="font-family: MathJax_Main;">/</span></span></span><span class="mn" id="MathJax-Span-60615" style="font-family: MathJax_Main;">14</span></span><span style="display: inline-block; width: 0px; height: 2.776em;"></span></span><span style="position: absolute; clip: rect(1.869em 1000em 3.203em -0.424em); top: -2.024em; left: 50%; margin-left: -1.011em;"><span class="mrow" id="MathJax-Span-60616"><span class="mn" id="MathJax-Span-60617" style="font-family: MathJax_Main;">9</span><span class="texatom" id="MathJax-Span-60618"><span class="mrow" id="MathJax-Span-60619"><span class="mo" id="MathJax-Span-60620" style="font-family: MathJax_Main;">/</span></span></span><span class="mn" id="MathJax-Span-60621" style="font-family: MathJax_Main;">14</span></span><span style="display: inline-block; width: 0px; height: 2.776em;"></span></span><span style="position: absolute; clip: rect(0.856em 1000em 1.229em -0.477em); top: -1.277em; left: 0.003em;"><span style="border-left-width: 2.136em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.25px; vertical-align: 0.003em;"></span><span style="display: inline-block; width: 0px; height: 1.069em;"></span></span></span></span><span class="mo" id="MathJax-Span-60622" style="font-family: MathJax_Main; padding-left: 0.269em;">=</span><span class="mn" id="MathJax-Span-60623" style="font-family: MathJax_Main; padding-left: 0.269em;">2</span><span class="texatom" id="MathJax-Span-60624"><span class="mrow" id="MathJax-Span-60625"><span class="mo" id="MathJax-Span-60626" style="font-family: MathJax_Main;">/</span></span></span><span class="mn" id="MathJax-Span-60627" style="font-family: MathJax_Main;">9</span><span style="display: inline-block; width: 0px; height: 4.003em;"></span></span><span style="position: absolute; clip: rect(2.349em 1000em 5.123em -0.477em); top: -1.117em; left: 50%; margin-left: -7.464em;"><span class="mspace" id="MathJax-Span-60628" style="height: 0.003em; vertical-align: 0.003em; width: 0.003em; display: inline-block; overflow: hidden;"></span><span class="mi" id="MathJax-Span-60629" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-60630" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-60631" style="font-family: MathJax_Math-italic;">s</span><span class="mi" id="MathJax-Span-60632" style="font-family: MathJax_Math-italic;">u</span><span class="mi" id="MathJax-Span-60633" style="font-family: MathJax_Math-italic;">n</span><span class="mi" id="MathJax-Span-60634" style="font-family: MathJax_Math-italic;">n</span><span class="mi" id="MathJax-Span-60635" style="font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="texatom" id="MathJax-Span-60636"><span class="mrow" id="MathJax-Span-60637"><span class="mo" id="MathJax-Span-60638" style="font-family: MathJax_Main;">|</span></span></span><span class="mi" id="MathJax-Span-60639" style="font-family: MathJax_Math-italic;">n</span><span class="mi" id="MathJax-Span-60640" style="font-family: MathJax_Math-italic;">o</span><span class="mo" id="MathJax-Span-60641" style="font-family: MathJax_Main;">)</span><span class="mo" id="MathJax-Span-60642" style="font-family: MathJax_Main; padding-left: 0.269em;">=</span><span class="mfrac" id="MathJax-Span-60643" style="padding-left: 0.269em;"><span style="display: inline-block; position: relative; width: 5.496em; height: 0px; margin-right: 0.109em; margin-left: 0.109em;"><span style="position: absolute; clip: rect(1.869em 1000em 3.203em -0.424em); top: -3.517em; left: 50%; margin-left: -2.664em;"><span class="mrow" id="MathJax-Span-60644"><span class="mi" id="MathJax-Span-60645" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-60646" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-60647" style="font-family: MathJax_Math-italic;">s</span><span class="mi" id="MathJax-Span-60648" style="font-family: MathJax_Math-italic;">u</span><span class="mi" id="MathJax-Span-60649" style="font-family: MathJax_Math-italic;">n</span><span class="mi" id="MathJax-Span-60650" style="font-family: MathJax_Math-italic;">n</span><span class="mi" id="MathJax-Span-60651" style="font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-60652" style="font-family: MathJax_Math-italic;">n</span><span class="mi" id="MathJax-Span-60653" style="font-family: MathJax_Math-italic;">o</span><span class="mo" id="MathJax-Span-60654" style="font-family: MathJax_Main;">)</span></span><span style="display: inline-block; width: 0px; height: 2.776em;"></span></span><span style="position: absolute; clip: rect(1.869em 1000em 3.203em -0.424em); top: -2.024em; left: 50%; margin-left: -1.277em;"><span class="mrow" id="MathJax-Span-60655"><span class="mi" id="MathJax-Span-60656" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-60657" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-60658" style="font-family: MathJax_Math-italic;">n</span><span class="mi" id="MathJax-Span-60659" style="font-family: MathJax_Math-italic;">o</span><span class="mo" id="MathJax-Span-60660" style="font-family: MathJax_Main;">)</span></span><span style="display: inline-block; width: 0px; height: 2.776em;"></span></span><span style="position: absolute; clip: rect(0.856em 1000em 1.229em -0.477em); top: -1.277em; left: 0.003em;"><span style="border-left-width: 5.496em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.25px; vertical-align: 0.003em;"></span><span style="display: inline-block; width: 0px; height: 1.069em;"></span></span></span></span><span class="mo" id="MathJax-Span-60661" style="font-family: MathJax_Main; padding-left: 0.269em;">=</span><span class="mfrac" id="MathJax-Span-60662" style="padding-left: 0.269em;"><span style="display: inline-block; position: relative; width: 0.643em; height: 0px; margin-right: 0.109em; margin-left: 0.109em;"><span style="position: absolute; clip: rect(1.976em 1000em 2.936em -0.424em); top: -3.464em; left: 50%; margin-left: -0.264em;"><span class="mn" id="MathJax-Span-60663" style="font-family: MathJax_Main;">3</span><span style="display: inline-block; width: 0px; height: 2.776em;"></span></span><span style="position: absolute; clip: rect(1.976em 1000em 2.936em -0.424em); top: -2.077em; left: 50%; margin-left: -0.264em;"><span class="mn" id="MathJax-Span-60664" style="font-family: MathJax_Main;">5</span><span style="display: inline-block; width: 0px; height: 2.776em;"></span></span><span style="position: absolute; clip: rect(0.856em 1000em 1.229em -0.477em); top: -1.277em; left: 0.003em;"><span style="border-left-width: 0.643em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.25px; vertical-align: 0.003em;"></span><span style="display: inline-block; width: 0px; height: 1.069em;"></span></span></span></span><span style="display: inline-block; width: 0px; height: 4.003em;"></span></span></span></span><span style="display: inline-block; width: 0px; height: 6.349em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 6.803em; vertical-align: -4.863em;"></span></span></nobr>
<script type="math/tex; mode=display" id="MathJax-Element-2328"> P(Sunny|yes)=\frac{P(sunny yes)}{P(yes)}=\frac{2/14}{9/14} =2/9 \\ P(sunny|no)=\frac{P(sunny no)}{P(no)}=\frac3 5 </script>

然后Outlook==Overcast 有4,其中yes=4,no=0

outlook Sunny Overcast Rain
yes 2 4 3
no 3 0 2
5 4 5

那么就可以得到

<nobr><span class="math" id="MathJax-Span-60665" style="width: 100%; display: inline-block; min-width: 10.349em;"><span style="display: inline-block; position: relative; width: 100%; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(3.096em 1000em 5.869em -0.477em); top: -3.997em; left: 0.003em; width: 100%;"><span class="mrow" id="MathJax-Span-60666"><span style="display: inline-block; position: relative; width: 100%; height: 0px;"><span style="position: absolute; clip: rect(3.096em 1000em 4.429em -0.424em); top: -3.997em; left: 50%; margin-left: -4.157em;"><span class="mi" id="MathJax-Span-60667" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-60668" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-60669" style="font-family: MathJax_Math-italic;">R</span><span class="mi" id="MathJax-Span-60670" style="font-family: MathJax_Math-italic;">a</span><span class="mi" id="MathJax-Span-60671" style="font-family: MathJax_Math-italic;">i</span><span class="mi" id="MathJax-Span-60672" style="font-family: MathJax_Math-italic;">n</span><span class="texatom" id="MathJax-Span-60673"><span class="mrow" id="MathJax-Span-60674"><span class="mo" id="MathJax-Span-60675" style="font-family: MathJax_Main;">|</span></span></span><span class="mi" id="MathJax-Span-60676" style="font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-60677" style="font-family: MathJax_Math-italic;">e</span><span class="mi" id="MathJax-Span-60678" style="font-family: MathJax_Math-italic;">s</span><span class="mo" id="MathJax-Span-60679" style="font-family: MathJax_Main;">)</span><span class="mo" id="MathJax-Span-60680" style="font-family: MathJax_Main; padding-left: 0.269em;">=</span><span class="mn" id="MathJax-Span-60681" style="font-family: MathJax_Main; padding-left: 0.269em;">3</span><span class="texatom" id="MathJax-Span-60682"><span class="mrow" id="MathJax-Span-60683"><span class="mo" id="MathJax-Span-60684" style="font-family: MathJax_Main;">/</span></span></span><span class="mn" id="MathJax-Span-60685" style="font-family: MathJax_Main;">9</span><span style="display: inline-block; width: 0px; height: 4.003em;"></span></span><span style="position: absolute; clip: rect(3.096em 1000em 4.429em -0.477em); top: -2.557em; left: 50%; margin-left: -3.944em;"><span class="mspace" id="MathJax-Span-60686" style="height: 0.003em; vertical-align: 0.003em; width: 0.003em; display: inline-block; overflow: hidden;"></span><span class="mi" id="MathJax-Span-60687" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-60688" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-60689" style="font-family: MathJax_Math-italic;">R</span><span class="mi" id="MathJax-Span-60690" style="font-family: MathJax_Math-italic;">a</span><span class="mi" id="MathJax-Span-60691" style="font-family: MathJax_Math-italic;">i</span><span class="mi" id="MathJax-Span-60692" style="font-family: MathJax_Math-italic;">n</span><span class="texatom" id="MathJax-Span-60693"><span class="mrow" id="MathJax-Span-60694"><span class="mo" id="MathJax-Span-60695" style="font-family: MathJax_Main;">|</span></span></span><span class="mi" id="MathJax-Span-60696" style="font-family: MathJax_Math-italic;">n</span><span class="mi" id="MathJax-Span-60697" style="font-family: MathJax_Math-italic;">o</span><span class="mo" id="MathJax-Span-60698" style="font-family: MathJax_Main;">)</span><span class="mo" id="MathJax-Span-60699" style="font-family: MathJax_Main; padding-left: 0.269em;">=</span><span class="mn" id="MathJax-Span-60700" style="font-family: MathJax_Main; padding-left: 0.269em;">2</span><span class="texatom" id="MathJax-Span-60701"><span class="mrow" id="MathJax-Span-60702"><span class="mo" id="MathJax-Span-60703" style="font-family: MathJax_Main;">/</span></span></span><span class="mn" id="MathJax-Span-60704" style="font-family: MathJax_Main;">5</span><span style="display: inline-block; width: 0px; height: 4.003em;"></span></span></span></span><span style="display: inline-block; width: 0px; height: 4.003em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 3.203em; vertical-align: -2.197em;"></span></span></nobr>
<script type="math/tex; mode=display" id="MathJax-Element-2329"> P(Rain|yes)=3/9 \\ P(Rain|no)=2/5 </script>
接着对全部的计算

我们类别yes,no可以

<nobr><span class="math" id="MathJax-Span-60705" style="width: 100%; display: inline-block; min-width: 29.336em;"><span style="display: inline-block; position: relative; width: 100%; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(3.949em 1000em 8.109em -0.477em); top: -4.851em; left: 0.003em; width: 100%;"><span class="mrow" id="MathJax-Span-60706"><span style="display: inline-block; position: relative; width: 100%; height: 0px;"><span style="position: absolute; clip: rect(3.096em 1000em 4.429em -0.424em); top: -3.997em; left: 50%; margin-left: -11.517em;"><span class="mi" id="MathJax-Span-60707" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-60708" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-60709" style="font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-60710" style="font-family: MathJax_Math-italic;">e</span><span class="mi" id="MathJax-Span-60711" style="font-family: MathJax_Math-italic;">s</span><span class="mo" id="MathJax-Span-60712" style="font-family: MathJax_Main;">)</span><span class="mi" id="MathJax-Span-60713" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-60714" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-60715" style="font-family: MathJax_Math-italic;">s</span><span class="mi" id="MathJax-Span-60716" style="font-family: MathJax_Math-italic;">u</span><span class="mi" id="MathJax-Span-60717" style="font-family: MathJax_Math-italic;">n</span><span class="mi" id="MathJax-Span-60718" style="font-family: MathJax_Math-italic;">n</span><span class="mi" id="MathJax-Span-60719" style="font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="texatom" id="MathJax-Span-60720"><span class="mrow" id="MathJax-Span-60721"><span class="mo" id="MathJax-Span-60722" style="font-family: MathJax_Main;">|</span></span></span><span class="mi" id="MathJax-Span-60723" style="font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-60724" style="font-family: MathJax_Math-italic;">e</span><span class="mi" id="MathJax-Span-60725" style="font-family: MathJax_Math-italic;">s</span><span class="mo" id="MathJax-Span-60726" style="font-family: MathJax_Main;">)</span><span class="mi" id="MathJax-Span-60727" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-60728" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-60729" style="font-family: MathJax_Math-italic;">c</span><span class="mi" id="MathJax-Span-60730" style="font-family: MathJax_Math-italic;">o</span><span class="mi" id="MathJax-Span-60731" style="font-family: MathJax_Math-italic;">o</span><span class="mi" id="MathJax-Span-60732" style="font-family: MathJax_Math-italic;">l</span><span class="texatom" id="MathJax-Span-60733"><span class="mrow" id="MathJax-Span-60734"><span class="mo" id="MathJax-Span-60735" style="font-family: MathJax_Main;">|</span></span></span><span class="mi" id="MathJax-Span-60736" style="font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-60737" style="font-family: MathJax_Math-italic;">e</span><span class="mi" id="MathJax-Span-60738" style="font-family: MathJax_Math-italic;">s</span><span class="mo" id="MathJax-Span-60739" style="font-family: MathJax_Main;">)</span><span class="mi" id="MathJax-Span-60740" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-60741" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-60742" style="font-family: MathJax_Math-italic;">h</span><span class="mi" id="MathJax-Span-60743" style="font-family: MathJax_Math-italic;">i</span><span class="mi" id="MathJax-Span-60744" style="font-family: MathJax_Math-italic;">g<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-60745" style="font-family: MathJax_Math-italic;">h</span><span class="texatom" id="MathJax-Span-60746"><span class="mrow" id="MathJax-Span-60747"><span class="mo" id="MathJax-Span-60748" style="font-family: MathJax_Main;">|</span></span></span><span class="mi" id="MathJax-Span-60749" style="font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-60750" style="font-family: MathJax_Math-italic;">e</span><span class="mi" id="MathJax-Span-60751" style="font-family: MathJax_Math-italic;">s</span><span class="mo" id="MathJax-Span-60752" style="font-family: MathJax_Main;">)</span><span class="mi" id="MathJax-Span-60753" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-60754" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-60755" style="font-family: MathJax_Math-italic;">s</span><span class="mi" id="MathJax-Span-60756" style="font-family: MathJax_Math-italic;">t</span><span class="mi" id="MathJax-Span-60757" style="font-family: MathJax_Math-italic;">r</span><span class="mi" id="MathJax-Span-60758" style="font-family: MathJax_Math-italic;">o</span><span class="mi" id="MathJax-Span-60759" style="font-family: MathJax_Math-italic;">n</span><span class="mi" id="MathJax-Span-60760" style="font-family: MathJax_Math-italic;">g<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span style="display: inline-block; width: 0px; height: 4.003em;"></span></span><span style="position: absolute; clip: rect(3.096em 1000em 4.429em -0.371em); top: -2.557em; left: 50%; margin-left: -1.064em;"><span class="texatom" id="MathJax-Span-60761"><span class="mrow" id="MathJax-Span-60762"><span class="mo" id="MathJax-Span-60763" style="font-family: MathJax_Main;">|</span></span></span><span class="mi" id="MathJax-Span-60764" style="font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-60765" style="font-family: MathJax_Math-italic;">e</span><span class="mi" id="MathJax-Span-60766" style="font-family: MathJax_Math-italic;">s</span><span class="mo" id="MathJax-Span-60767" style="font-family: MathJax_Main;">)</span><span style="display: inline-block; width: 0px; height: 4.003em;"></span></span><span style="position: absolute; clip: rect(3.096em 1000em 4.429em -0.477em); top: -1.117em; left: 50%; margin-left: -11.731em;"><span class="mspace" id="MathJax-Span-60768" style="height: 0.003em; vertical-align: 0.003em; width: 0.003em; display: inline-block; overflow: hidden;"></span><span class="mi" id="MathJax-Span-60769" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-60770" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-60771" style="font-family: MathJax_Math-italic;">n</span><span class="mi" id="MathJax-Span-60772" style="font-family: MathJax_Math-italic;">o</span><span class="mo" id="MathJax-Span-60773" style="font-family: MathJax_Main;">)</span><span class="mi" id="MathJax-Span-60774" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-60775" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-60776" style="font-family: MathJax_Math-italic;">s</span><span class="mi" id="MathJax-Span-60777" style="font-family: MathJax_Math-italic;">u</span><span class="mi" id="MathJax-Span-60778" style="font-family: MathJax_Math-italic;">n</span><span class="mi" id="MathJax-Span-60779" style="font-family: MathJax_Math-italic;">n</span><span class="mi" id="MathJax-Span-60780" style="font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="texatom" id="MathJax-Span-60781"><span class="mrow" id="MathJax-Span-60782"><span class="mo" id="MathJax-Span-60783" style="font-family: MathJax_Main;">|</span></span></span><span class="mi" id="MathJax-Span-60784" style="font-family: MathJax_Math-italic;">n</span><span class="mi" id="MathJax-Span-60785" style="font-family: MathJax_Math-italic;">o</span><span class="mo" id="MathJax-Span-60786" style="font-family: MathJax_Main;">)</span><span class="mi" id="MathJax-Span-60787" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-60788" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-60789" style="font-family: MathJax_Math-italic;">c</span><span class="mi" id="MathJax-Span-60790" style="font-family: MathJax_Math-italic;">o</span><span class="mi" id="MathJax-Span-60791" style="font-family: MathJax_Math-italic;">o</span><span class="mi" id="MathJax-Span-60792" style="font-family: MathJax_Math-italic;">l</span><span class="texatom" id="MathJax-Span-60793"><span class="mrow" id="MathJax-Span-60794"><span class="mo" id="MathJax-Span-60795" style="font-family: MathJax_Main;">|</span></span></span><span class="mi" id="MathJax-Span-60796" style="font-family: MathJax_Math-italic;">n</span><span class="mi" id="MathJax-Span-60797" style="font-family: MathJax_Math-italic;">o</span><span class="mo" id="MathJax-Span-60798" style="font-family: MathJax_Main;">)</span><span class="mi" id="MathJax-Span-60799" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-60800" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-60801" style="font-family: MathJax_Math-italic;">h</span><span class="mi" id="MathJax-Span-60802" style="font-family: MathJax_Math-italic;">i</span><span class="mi" id="MathJax-Span-60803" style="font-family: MathJax_Math-italic;">g<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-60804" style="font-family: MathJax_Math-italic;">h</span><span class="texatom" id="MathJax-Span-60805"><span class="mrow" id="MathJax-Span-60806"><span class="mo" id="MathJax-Span-60807" style="font-family: MathJax_Main;">|</span></span></span><span class="mi" id="MathJax-Span-60808" style="font-family: MathJax_Math-italic;">n</span><span class="mi" id="MathJax-Span-60809" style="font-family: MathJax_Math-italic;">o</span><span class="mo" id="MathJax-Span-60810" style="font-family: MathJax_Main;">)</span><span class="mi" id="MathJax-Span-60811" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-60812" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-60813" style="font-family: MathJax_Math-italic;">s</span><span class="mi" id="MathJax-Span-60814" style="font-family: MathJax_Math-italic;">t</span><span class="mi" id="MathJax-Span-60815" style="font-family: MathJax_Math-italic;">r</span><span class="mi" id="MathJax-Span-60816" style="font-family: MathJax_Math-italic;">o</span><span class="mi" id="MathJax-Span-60817" style="font-family: MathJax_Math-italic;">n</span><span class="mi" id="MathJax-Span-60818" style="font-family: MathJax_Math-italic;">g<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="texatom" id="MathJax-Span-60819"><span class="mrow" id="MathJax-Span-60820"><span class="mo" id="MathJax-Span-60821" style="font-family: MathJax_Main;">|</span></span></span><span class="mi" id="MathJax-Span-60822" style="font-family: MathJax_Math-italic;">n</span><span class="mi" id="MathJax-Span-60823" style="font-family: MathJax_Math-italic;">o</span><span class="mo" id="MathJax-Span-60824" style="font-family: MathJax_Main;">)</span><span style="display: inline-block; width: 0px; height: 4.003em;"></span></span></span></span><span style="display: inline-block; width: 0px; height: 4.856em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 4.937em; vertical-align: -3.93em;"></span></span></nobr>
<script type="math/tex; mode=display" id="MathJax-Element-2330"> P(yes)P(sunny|yes)P(cool|yes)P(high|yes)P(strong|yes)\\ P(no)P(sunny|no)P(cool|no)P(high|no)P(strong|no) </script>

因为<nobr><span class="math" id="MathJax-Span-60825" style="width: 14.616em; display: inline-block;"><span style="display: inline-block; position: relative; width: 11.683em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.869em 1000em 3.203em -0.424em); top: -2.771em; left: 0.003em;"><span class="mrow" id="MathJax-Span-60826"><span class="mi" id="MathJax-Span-60827" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-60828" style="font-family: MathJax_Main;">(</span><span class="msubsup" id="MathJax-Span-60829"><span style="display: inline-block; position: relative; width: 0.963em; height: 0px;"><span style="position: absolute; clip: rect(1.976em 1000em 2.936em -0.477em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-60830" style="font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.184em; left: 0.536em;"><span class="mn" id="MathJax-Span-60831" style="font-size: 70.7%; font-family: MathJax_Main;">1</span><span style="display: inline-block; width: 0px; height: 2.456em;"></span></span></span></span><span class="texatom" id="MathJax-Span-60832"><span class="mrow" id="MathJax-Span-60833"><span class="mo" id="MathJax-Span-60834" style="font-family: MathJax_Main;">|</span></span></span><span class="mi" id="MathJax-Span-60835" style="font-family: MathJax_Math-italic;">x</span><span class="mo" id="MathJax-Span-60836" style="font-family: MathJax_Main;">)</span><span class="mo" id="MathJax-Span-60837" style="font-family: MathJax_Main;">,</span><span class="mi" id="MathJax-Span-60838" style="font-family: MathJax_Math-italic; padding-left: 0.163em;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-60839" style="font-family: MathJax_Main;">(</span><span class="msubsup" id="MathJax-Span-60840"><span style="display: inline-block; position: relative; width: 0.963em; height: 0px;"><span style="position: absolute; clip: rect(1.976em 1000em 2.936em -0.477em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-60841" style="font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.184em; left: 0.536em;"><span class="mn" id="MathJax-Span-60842" style="font-size: 70.7%; font-family: MathJax_Main;">2</span><span style="display: inline-block; width: 0px; height: 2.456em;"></span></span></span></span><span class="texatom" id="MathJax-Span-60843"><span class="mrow" id="MathJax-Span-60844"><span class="mo" id="MathJax-Span-60845" style="font-family: MathJax_Main;">|</span></span></span><span class="mi" id="MathJax-Span-60846" style="font-family: MathJax_Math-italic;">x</span><span class="mo" id="MathJax-Span-60847" style="font-family: MathJax_Main;">)</span><span class="mo" id="MathJax-Span-60848" style="font-family: MathJax_Main;">,</span><span class="mtext" id="MathJax-Span-60849" style="font-family: MathJax_Main; padding-left: 0.163em;"></span><span class="mtext" id="MathJax-Span-60850" style="font-family: MathJax_Main;"></span><span class="mtext" id="MathJax-Span-60851" style="font-family: MathJax_Main;"></span><span class="mi" id="MathJax-Span-60852" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-60853" style="font-family: MathJax_Main;">(</span><span class="msubsup" id="MathJax-Span-60854"><span style="display: inline-block; position: relative; width: 1.016em; height: 0px;"><span style="position: absolute; clip: rect(1.976em 1000em 2.936em -0.477em); top: -2.557em; left: 0.003em;"><span class="mi" id="MathJax-Span-60855" style="font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span style="display: inline-block; width: 0px; height: 2.563em;"></span></span><span style="position: absolute; top: -2.184em; left: 0.536em;"><span class="mi" id="MathJax-Span-60856" style="font-size: 70.7%; font-family: MathJax_Math-italic;">n</span><span style="display: inline-block; width: 0px; height: 2.456em;"></span></span></span></span><span class="texatom" id="MathJax-Span-60857"><span class="mrow" id="MathJax-Span-60858"><span class="mo" id="MathJax-Span-60859" style="font-family: MathJax_Main;">|</span></span></span><span class="mi" id="MathJax-Span-60860" style="font-family: MathJax_Math-italic;">x</span><span class="mo" id="MathJax-Span-60861" style="font-family: MathJax_Main;">)</span></span><span style="display: inline-block; width: 0px; height: 2.776em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.403em; vertical-align: -0.397em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-2331">P(y_1|x),P(y_2|x),\ \ \ P(y_n|x)</script>比较最大一个,<nobr><span class="math" id="MathJax-Span-60862" style="width: 11.309em; display: inline-block;"><span style="display: inline-block; position: relative; width: 9.016em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.496em 1000em 3.576em -0.424em); top: -2.771em; left: 0.003em;"><span class="mrow" id="MathJax-Span-60863"><span class="mi" id="MathJax-Span-60864" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-60865" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-60866" style="font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-60867" style="font-family: MathJax_Math-italic;">i</span><span class="texatom" id="MathJax-Span-60868"><span class="mrow" id="MathJax-Span-60869"><span class="mo" id="MathJax-Span-60870" style="font-family: MathJax_Main;">|</span></span></span><span class="mi" id="MathJax-Span-60871" style="font-family: MathJax_Math-italic;">x</span><span class="mo" id="MathJax-Span-60872" style="font-family: MathJax_Main;">)</span><span class="mo" id="MathJax-Span-60873" style="font-family: MathJax_Main; padding-left: 0.269em;">=</span><span class="mfrac" id="MathJax-Span-60874" style="padding-left: 0.269em;"><span style="display: inline-block; position: relative; width: 4.323em; height: 0px; margin-right: 0.109em; margin-left: 0.109em;"><span style="position: absolute; clip: rect(1.763em 1000em 2.776em -0.477em); top: -3.037em; left: 50%; margin-left: -2.077em;"><span class="mrow" id="MathJax-Span-60875"><span class="mi" id="MathJax-Span-60876" style="font-size: 70.7%; font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mo" id="MathJax-Span-60877" style="font-size: 70.7%; font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-60878" style="font-size: 70.7%; font-family: MathJax_Math-italic;">x</span><span class="texatom" id="MathJax-Span-60879"><span class="mrow" id="MathJax-Span-60880"><span class="mo" id="MathJax-Span-60881" style="font-size: 70.7%; font-family: MathJax_Main;">|</span></span></span><span class="mi" id="MathJax-Span-60882" style="font-size: 70.7%; font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-60883" style="font-size: 70.7%; font-family: MathJax_Math-italic;">i</span><span class="mo" id="MathJax-Span-60884" style="font-size: 70.7%; font-family: MathJax_Main;">)</span><span class="mo" id="MathJax-Span-60885" style="font-size: 70.7%; font-family: MathJax_Main;">∗</span><span class="mi" id="MathJax-Span-60886" style="font-size: 70.7%; font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mo" id="MathJax-Span-60887" style="font-size: 70.7%; font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-60888" style="font-size: 70.7%; font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-60889" style="font-size: 70.7%; font-family: MathJax_Math-italic;">i</span><span class="mo" id="MathJax-Span-60890" style="font-size: 70.7%; font-family: MathJax_Main;">)</span></span><span style="display: inline-block; width: 0px; height: 2.456em;"></span></span><span style="position: absolute; clip: rect(1.763em 1000em 2.776em -0.477em); top: -2.024em; left: 50%; margin-left: -0.691em;"><span class="mrow" id="MathJax-Span-60891"><span class="mi" id="MathJax-Span-60892" style="font-size: 70.7%; font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.056em;"></span></span><span class="mo" id="MathJax-Span-60893" style="font-size: 70.7%; font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-60894" style="font-size: 70.7%; font-family: MathJax_Math-italic;">x</span><span class="mo" id="MathJax-Span-60895" style="font-size: 70.7%; font-family: MathJax_Main;">)</span></span><span style="display: inline-block; width: 0px; height: 2.456em;"></span></span><span style="position: absolute; clip: rect(0.856em 1000em 1.229em -0.477em); top: -1.277em; left: 0.003em;"><span style="border-left-width: 4.323em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.25px; vertical-align: 0.003em;"></span><span style="display: inline-block; width: 0px; height: 1.069em;"></span></span></span></span></span><span style="display: inline-block; width: 0px; height: 2.776em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 2.337em; vertical-align: -0.863em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-2332">P(yi|x)=\frac{P(x|yi)*P(yi)}{P(x)}</script>,因为<nobr><span class="math" id="MathJax-Span-60896" style="width: 2.616em; display: inline-block;"><span style="display: inline-block; position: relative; width: 2.083em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.869em 1000em 3.203em -0.424em); top: -2.771em; left: 0.003em;"><span class="mrow" id="MathJax-Span-60897"><span class="mi" id="MathJax-Span-60898" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-60899" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-60900" style="font-family: MathJax_Math-italic;">x</span><span class="mo" id="MathJax-Span-60901" style="font-family: MathJax_Main;">)</span></span><span style="display: inline-block; width: 0px; height: 2.776em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.403em; vertical-align: -0.397em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-2333">P(x)</script>相同,我们比较<nobr><span class="math" id="MathJax-Span-60902" style="width: 13.763em; display: inline-block;"><span style="display: inline-block; position: relative; width: 10.989em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.869em 1000em 3.203em -0.424em); top: -2.771em; left: 0.003em;"><span class="mrow" id="MathJax-Span-60903"><span class="mi" id="MathJax-Span-60904" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-60905" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-60906" style="font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-60907" style="font-family: MathJax_Math-italic;">i</span><span class="texatom" id="MathJax-Span-60908"><span class="mrow" id="MathJax-Span-60909"><span class="mo" id="MathJax-Span-60910" style="font-family: MathJax_Main;">|</span></span></span><span class="mi" id="MathJax-Span-60911" style="font-family: MathJax_Math-italic;">x</span><span class="mo" id="MathJax-Span-60912" style="font-family: MathJax_Main;">)</span><span class="mo" id="MathJax-Span-60913" style="font-family: MathJax_Main; padding-left: 0.269em;">=</span><span class="mi" id="MathJax-Span-60914" style="font-family: MathJax_Math-italic; padding-left: 0.269em;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-60915" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-60916" style="font-family: MathJax_Math-italic;">x</span><span class="texatom" id="MathJax-Span-60917"><span class="mrow" id="MathJax-Span-60918"><span class="mo" id="MathJax-Span-60919" style="font-family: MathJax_Main;">|</span></span></span><span class="mi" id="MathJax-Span-60920" style="font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-60921" style="font-family: MathJax_Math-italic;">i</span><span class="mo" id="MathJax-Span-60922" style="font-family: MathJax_Main;">)</span><span class="mo" id="MathJax-Span-60923" style="font-family: MathJax_Main; padding-left: 0.216em;">∗</span><span class="mi" id="MathJax-Span-60924" style="font-family: MathJax_Math-italic; padding-left: 0.216em;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-60925" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-60926" style="font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-60927" style="font-family: MathJax_Math-italic;">i</span><span class="mo" id="MathJax-Span-60928" style="font-family: MathJax_Main;">)</span></span><span style="display: inline-block; width: 0px; height: 2.776em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.403em; vertical-align: -0.397em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-2334">P(yi|x)=P(x|yi)*P(yi)</script>,<nobr><span class="math" id="MathJax-Span-60929" style="width: 21.869em; display: inline-block;"><span style="display: inline-block; position: relative; width: 17.496em; height: 0px; font-size: 125%;"><span style="position: absolute; clip: rect(1.869em 1000em 3.203em -0.424em); top: -2.771em; left: 0.003em;"><span class="mrow" id="MathJax-Span-60930"><span class="mi" id="MathJax-Span-60931" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-60932" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-60933" style="font-family: MathJax_Math-italic;">x</span><span class="texatom" id="MathJax-Span-60934"><span class="mrow" id="MathJax-Span-60935"><span class="mo" id="MathJax-Span-60936" style="font-family: MathJax_Main;">|</span></span></span><span class="mi" id="MathJax-Span-60937" style="font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-60938" style="font-family: MathJax_Math-italic;">i</span><span class="mo" id="MathJax-Span-60939" style="font-family: MathJax_Main;">)</span><span class="mo" id="MathJax-Span-60940" style="font-family: MathJax_Main; padding-left: 0.216em;">∗</span><span class="mi" id="MathJax-Span-60941" style="font-family: MathJax_Math-italic; padding-left: 0.216em;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-60942" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-60943" style="font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-60944" style="font-family: MathJax_Math-italic;">i</span><span class="mo" id="MathJax-Span-60945" style="font-family: MathJax_Main;">)</span><span class="mo" id="MathJax-Span-60946" style="font-family: MathJax_Main; padding-left: 0.269em;">=</span><span class="mi" id="MathJax-Span-60947" style="font-family: MathJax_Math-italic; padding-left: 0.269em;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-60948" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-60949" style="font-family: MathJax_Math-italic;">a</span><span class="mn" id="MathJax-Span-60950" style="font-family: MathJax_Main;">1</span><span class="texatom" id="MathJax-Span-60951"><span class="mrow" id="MathJax-Span-60952"><span class="mo" id="MathJax-Span-60953" style="font-family: MathJax_Main;">|</span></span></span><span class="mi" id="MathJax-Span-60954" style="font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-60955" style="font-family: MathJax_Math-italic;">i</span><span class="mo" id="MathJax-Span-60956" style="font-family: MathJax_Main;">)</span><span class="mi" id="MathJax-Span-60957" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-60958" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-60959" style="font-family: MathJax_Math-italic;">a</span><span class="mn" id="MathJax-Span-60960" style="font-family: MathJax_Main;">2</span><span class="texatom" id="MathJax-Span-60961"><span class="mrow" id="MathJax-Span-60962"><span class="mo" id="MathJax-Span-60963" style="font-family: MathJax_Main;">|</span></span></span><span class="mi" id="MathJax-Span-60964" style="font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-60965" style="font-family: MathJax_Math-italic;">i</span><span class="mo" id="MathJax-Span-60966" style="font-family: MathJax_Main;">)</span><span class="mi" id="MathJax-Span-60967" style="font-family: MathJax_Math-italic;">P<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.109em;"></span></span><span class="mo" id="MathJax-Span-60968" style="font-family: MathJax_Main;">(</span><span class="mi" id="MathJax-Span-60969" style="font-family: MathJax_Math-italic;">y<span style="display: inline-block; overflow: hidden; height: 1px; width: 0.003em;"></span></span><span class="mi" id="MathJax-Span-60970" style="font-family: MathJax_Math-italic;">i</span><span class="mo" id="MathJax-Span-60971" style="font-family: MathJax_Main;">)</span></span><span style="display: inline-block; width: 0px; height: 2.776em;"></span></span></span><span style="border-left-width: 0.003em; border-left-style: solid; display: inline-block; overflow: hidden; width: 0px; height: 1.403em; vertical-align: -0.397em;"></span></span></nobr><script type="math/tex" id="MathJax-Element-2335">P(x|yi)*P(yi)=P(a1|yi)P(a2|yi)P(yi)</script>

参考:
- 数学之美番外篇:平凡而又神奇的贝叶斯方法

<script type="text/javascript"> $(function () { $('pre.prettyprint code').each(function () { var lines = $(this).text().split('\n').length; var $numbering = $('<ul/>').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i <= lines; i++) { $numbering.append($('<li/>').text(i)); }; $numbering.fadeIn(1700); }); }); </script>
分享到:
评论

相关推荐

    数据挖掘贝叶斯算法C++实现

    用贝叶斯算法解决数据挖掘中分类的问题,通过训练集先训练出分类规则后,再输入测试集进行测试

    数据挖掘贝叶斯——一种实现

    数据挖掘贝叶斯算法Java实现 数据挖掘贝叶斯是一种实现贝叶斯数据分类的算法,该算法使用Java语言实现,主要用于小规模数据集的实验和测试,不适合用于工程应用。该算法假定训练数据各属性列的值均是离散类型的,...

    数据挖掘贝叶斯算法java源代码(内含数据集)

    数据挖掘是一种从大量数据中发现有价值信息和知识的过程,而贝叶斯算法是其中一种常用的方法。本资源提供了一个基于Java实现的贝叶斯算法,它包含可调试运行的源代码,这对于学习和理解贝叶斯算法的工作原理非常有...

    数据挖掘 贝叶斯分类算法 C++

    数据挖掘 贝叶斯算法 C++ 贝叶斯算法一般都用MATLAB实现,好不容易找到个C++的,可以用到工程中去

    数据挖掘--朴素贝叶斯算法(决策用户是否购买商品)

    数据挖掘是一种从大量...总的来说,朴素贝叶斯算法是数据挖掘中一个基础且实用的工具,尤其适用于大规模数据集和实时预测。通过理解和应用这种算法,可以为商业决策提供有力的支持,帮助预测用户行为并优化营销策略。

    基于朴素贝叶斯算法的社交网络数据挖掘技术研究.pdf

    通过构建基于朴素贝叶斯算法的社交网络数据挖掘平台,如PcIE—FN平台,可以更深入地挖掘数据,提高分类准确度,并且能够对社交网络数据进行有效利用。 朴素贝叶斯算法之所以适合社交网络数据挖掘,是因为其具有以下...

    数据挖掘实验报告+代码+截图

    本实验报告主要涉及了数据挖掘过程中的五个关键环节,分别是数据预处理、数据立方体与联机分析处理、Apriori算法挖掘频繁项集、贝叶斯决策分类算法以及k-均值聚类算法。 一、数据预处理 数据预处理是数据挖掘的第...

    数据挖掘 贝叶斯算法 C++

    在数据挖掘领域,贝叶斯算法是一种广泛应用的统计学方法,尤其在分类问题中表现出色。贝叶斯定理基于概率论,通过先验概率和似然概率来更新我们对事件发生的后验概率,这种理论为理解和预测复杂数据提供了强大工具。...

    数据挖掘实验-C++实现贝叶斯Bayesian

    在数据挖掘中,贝叶斯算法常用于分类任务,如垃圾邮件过滤、文本分类和医学诊断等。它的优势在于可以处理高维数据,并且在处理稀疏数据时表现良好。 首先,我们要理解贝叶斯分类器的基本工作原理。在训练阶段,我们...

    常用的数据挖掘算法课件

    数据挖掘,决策树分类,关联规则挖掘,预测,聚类分析。

    树型朴素贝叶斯算法java数据挖掘算法源码

    《树型朴素贝叶斯算法在Java中的实现与数据挖掘》 朴素贝叶斯算法,作为统计学和机器学习领域中的一种基础分类方法,因其简单高效而被广泛应用。树型朴素贝叶斯算法是朴素贝叶斯算法的一种变体,它以决策树的形式...

    数据挖掘贝叶斯分类bayes算法

    该实验的的数据源是Wine recognition data,这是对在意大利同一地区生产的三种不同品种的酒,做大量分析所得出的数据。这些数据包括了三种酒中13种不同成分的数量。13种成分分别为:Alcohol,Malic acid,Ash,...

    贝叶斯网络算法java数据挖掘算法源码

    贝叶斯网络算法java数据挖掘算法源码 数据挖掘算法是根据数据创建数据挖掘模型的一组试探法和计算。 为了创建模型,算法将首先分析您提供的数据,并查找特定类型的模式和趋势。概念描述算法使用此分析的结果来定义...

    数据挖掘之贝叶斯算法(C++实现)

    数据挖掘是一种从海量数据中提取有价值信息的过程,而贝叶斯算法是数据挖掘中的一个重要工具,尤其在分类问题上表现出色。贝叶斯算法基于概率论中的贝叶斯定理,能够通过已有的先验知识对未知事件进行预测。在这个...

    数据挖掘与数据分析应用案例 数据挖掘算法实践 基于Python的朴素贝叶斯算法的应用.doc

    ### 数据挖掘与数据分析应用案例:基于Python的朴素贝叶斯算法的应用 #### 一、数据挖掘的历史及其发展 数据挖掘(Data Mining)源自于人工智能(Artificial Intelligence, AI)领域,随着计算机技术的发展,人工智能...

    朴素贝叶斯算法python实现

    这个数据集是数据挖掘和机器学习领域常用的基准数据集。 首先,我们需要导入必要的Python库,如pandas用于数据处理,numpy用于数值计算,matplotlib用于数据可视化,以及sklearn库中的load_iris函数获取Iris数据集...

    朴素贝叶斯算法java数据挖掘算法源码.rar

    朴素贝叶斯算法java数据挖掘算法源码 数据挖掘算法是根据数据创建数据挖掘模型的一组试探法和计算。 为了创建模型,算法将首先分析您提供的数据,并查找特定类型的模式和趋势。概念描述算法使用此分析的结果来定义...

    数据挖掘算法

    数据挖掘是一种从海量数据中提取有价值知识的过程,它利用各种算法来发现隐藏在数据中的模式、规律和关联。本知识包全面涵盖了数据挖掘的核心概念、常用算法及其应用场景。以下是关于数据挖掘算法的详细阐述: 一、...

    数据挖掘-基于贝叶斯算法及KNN算法.docx

    数据挖掘是一种从大量数据中提取有用信息的过程,而贝叶斯算法和KNN算法是两种常用的数据挖掘技术,尤其在文本分类领域。这两种算法在处理非结构化数据,如文档分类时,有着显著的效果。 贝叶斯算法是基于概率论的...

Global site tag (gtag.js) - Google Analytics