<p>为什么使用alpha?</p>
<p>用于对NB p(Y=1 | W)或p(Y=0 | W)中的查询点进行分类(考虑二进制分类)
这里W是单词的向量W=[w1,w2,w3。。。。wd[文字]
d=特征数量</p>
<p>所以,在训练时找出所有这些的概率<br/>
P(w1 | Y=1)*P(w2 | Y=1)*…..P(wd | Y=1))*P(Y=1)</p>
<p>对于Y=0,应执行上述操作。</p>
<p>对于Naive Bayes公式,请参阅(<a href="https://en.wikipedia.org/wiki/Naive_Bayes_classifier" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/Naive_Bayes_classifier</a>)</p>
<p>现在在测试的时候,假设你遇到了一个不在火车上的单词,那么它在一个类中存在的概率为零,这会使整个概率为0,这是不好的。</p>
<p>考虑W*单词不在训练集中</p>
<p>p(W*| Y=1)=p(W*,Y=1)/p(Y=1)</p>
<pre><code> = Number of training points such that w* word present and Y=1 / Number of training point where Y=1
= 0/Number of training point where Y=1
</code></pre>
<p>为了解决这个问题,我们做拉普拉斯平滑。
我们把α加到分子和分母域。</p>
<pre><code> = 0 + alpha / Number of training point where Y=1 + (Number of class labels in classifier * alpha)
</code></pre>
<ol start=“2”>
<li>它发生在现实世界中,在上述公式中(P(W<code>|Y=1) = P(W</code>,Y=1)/P(Y=1)),如果分子和分母字段很小,则很容易受到异常值或噪声的影响。这里alpha也有帮助,因为随着alpha的增加,我的可能性分布趋于均匀。</li>
</ol>
<p>所以alpha是超参数的,你必须使用网格搜索(如jakevdp所述)或随机搜索等技术来调整它。(<a href="https://towardsdatascience.com/hyperparameter-tuning-c5619e7e6624" rel="nofollow noreferrer">https://towardsdatascience.com/hyperparameter-tuning-c5619e7e6624</a>)</p>