- 浏览: 140121 次
文章分类
最新评论
数据挖掘 贝叶斯算法
贝叶斯算法
朴素贝叶斯分类是一种十分简单的分类算法,叫它朴素贝叶斯分类是因为这种方法的思想真的很朴素,朴素贝叶斯的思想基础是这样的:对于给出的待分类项,求解在此项出现的条件下各个类别出现的概率,哪个最大,就认为此待分类项属于哪个类别。
贝叶斯的公式很简单,其实就是<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
那么我们首先算出所有
然后就是每个列属性
Outlook
Outlook==Sunny 有5个,其中
然后Outlook==Overcast 有4,其中yes=4,no=0
yes | 2 | 4 | 3 |
no | 3 | 0 | 2 |
总 | 5 | 4 | 5 |
那么就可以得到
接着对全部的计算
我们类别yes,no可以
因为<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>
参考:
- 数学之美番外篇:平凡而又神奇的贝叶斯方法
相关推荐
用贝叶斯算法解决数据挖掘中分类的问题,通过训练集先训练出分类规则后,再输入测试集进行测试
数据挖掘贝叶斯算法Java实现 数据挖掘贝叶斯是一种实现贝叶斯数据分类的算法,该算法使用Java语言实现,主要用于小规模数据集的实验和测试,不适合用于工程应用。该算法假定训练数据各属性列的值均是离散类型的,...
数据挖掘是一种从大量数据中发现有价值信息和知识的过程,而贝叶斯算法是其中一种常用的方法。本资源提供了一个基于Java实现的贝叶斯算法,它包含可调试运行的源代码,这对于学习和理解贝叶斯算法的工作原理非常有...
数据挖掘 贝叶斯算法 C++ 贝叶斯算法一般都用MATLAB实现,好不容易找到个C++的,可以用到工程中去
数据挖掘是一种从大量...总的来说,朴素贝叶斯算法是数据挖掘中一个基础且实用的工具,尤其适用于大规模数据集和实时预测。通过理解和应用这种算法,可以为商业决策提供有力的支持,帮助预测用户行为并优化营销策略。
通过构建基于朴素贝叶斯算法的社交网络数据挖掘平台,如PcIE—FN平台,可以更深入地挖掘数据,提高分类准确度,并且能够对社交网络数据进行有效利用。 朴素贝叶斯算法之所以适合社交网络数据挖掘,是因为其具有以下...
本实验报告主要涉及了数据挖掘过程中的五个关键环节,分别是数据预处理、数据立方体与联机分析处理、Apriori算法挖掘频繁项集、贝叶斯决策分类算法以及k-均值聚类算法。 一、数据预处理 数据预处理是数据挖掘的第...
在数据挖掘领域,贝叶斯算法是一种广泛应用的统计学方法,尤其在分类问题中表现出色。贝叶斯定理基于概率论,通过先验概率和似然概率来更新我们对事件发生的后验概率,这种理论为理解和预测复杂数据提供了强大工具。...
在数据挖掘中,贝叶斯算法常用于分类任务,如垃圾邮件过滤、文本分类和医学诊断等。它的优势在于可以处理高维数据,并且在处理稀疏数据时表现良好。 首先,我们要理解贝叶斯分类器的基本工作原理。在训练阶段,我们...
数据挖掘,决策树分类,关联规则挖掘,预测,聚类分析。
《树型朴素贝叶斯算法在Java中的实现与数据挖掘》 朴素贝叶斯算法,作为统计学和机器学习领域中的一种基础分类方法,因其简单高效而被广泛应用。树型朴素贝叶斯算法是朴素贝叶斯算法的一种变体,它以决策树的形式...
该实验的的数据源是Wine recognition data,这是对在意大利同一地区生产的三种不同品种的酒,做大量分析所得出的数据。这些数据包括了三种酒中13种不同成分的数量。13种成分分别为:Alcohol,Malic acid,Ash,...
贝叶斯网络算法java数据挖掘算法源码 数据挖掘算法是根据数据创建数据挖掘模型的一组试探法和计算。 为了创建模型,算法将首先分析您提供的数据,并查找特定类型的模式和趋势。概念描述算法使用此分析的结果来定义...
数据挖掘是一种从海量数据中提取有价值信息的过程,而贝叶斯算法是数据挖掘中的一个重要工具,尤其在分类问题上表现出色。贝叶斯算法基于概率论中的贝叶斯定理,能够通过已有的先验知识对未知事件进行预测。在这个...
### 数据挖掘与数据分析应用案例:基于Python的朴素贝叶斯算法的应用 #### 一、数据挖掘的历史及其发展 数据挖掘(Data Mining)源自于人工智能(Artificial Intelligence, AI)领域,随着计算机技术的发展,人工智能...
这个数据集是数据挖掘和机器学习领域常用的基准数据集。 首先,我们需要导入必要的Python库,如pandas用于数据处理,numpy用于数值计算,matplotlib用于数据可视化,以及sklearn库中的load_iris函数获取Iris数据集...
朴素贝叶斯算法java数据挖掘算法源码 数据挖掘算法是根据数据创建数据挖掘模型的一组试探法和计算。 为了创建模型,算法将首先分析您提供的数据,并查找特定类型的模式和趋势。概念描述算法使用此分析的结果来定义...
数据挖掘是一种从海量数据中提取有价值知识的过程,它利用各种算法来发现隐藏在数据中的模式、规律和关联。本知识包全面涵盖了数据挖掘的核心概念、常用算法及其应用场景。以下是关于数据挖掘算法的详细阐述: 一、...
数据挖掘是一种从大量数据中提取有用信息的过程,而贝叶斯算法和KNN算法是两种常用的数据挖掘技术,尤其在文本分类领域。这两种算法在处理非结构化数据,如文档分类时,有着显著的效果。 贝叶斯算法是基于概率论的...