プリンキピア

第22章付録:深層学習のための数学

22.9.3. The Naive Bayes Classifier22.9.3 ナイーブベイズ分類器

Fortunately, by making some assumptions about conditional independence, we can introduce some inductive bias and build a model capable of generalizing from a comparatively modest selection of training examples. To begin, let’s use Bayes theorem, to express the classifier as
英語のヒント
幸い、条件付き独立について何らかの仮定を置くことで、帰納バイアスを導入し、比較的控えめな量の訓練例から汎化できるモデルを作れる。まず、ベイズの定理を使って、分類器を次のように表そう。
yˆ=argmaxyp(y∣𝐱)=argmaxyp(𝐱∣y)p(y)p(𝐱).(22.9.2)
Note that the denominator is the normalizing term p(𝐱) which does not depend on the value of the label y. As a result, we only need to worry about comparing the numerator across different values of y. Even if calculating the denominator turned out to be intractable, we could get away with ignoring it, so long as we could evaluate the numerator. Fortunately, even if we wanted to recover the normalizing constant, we could. We can always recover the normalization term since ∑yp(y∣𝐱)=1.
英語のヒント
分母は正規化項p(𝐱)であり、ラベルyの値に依存しないことに注意しよう。その結果、yの異なる値の間で分子を比べることだけを気にすればよい。分母の計算が手に負えないとわかったとしても、分子を評価できるかぎり、分母を無視して済ませられる。幸い、正規化定数を取り戻したいとしても、それはできる。∑yp(y∣𝐱)=1なので、正規化項はいつでも取り戻せる。
Now, let’s focus on p(𝐱∣y). Using the chain rule of probability, we can express the term p(𝐱∣y) as
英語のヒント
では、p(𝐱∣y)に焦点を当てよう。確率の連鎖律を使うと、項p(𝐱∣y)は次のように表せる。
p(x1∣y)⋅p(x2∣x1,y)⋅...⋅p(xd∣x1,...,xd−1,y).(22.9.3)
By itself, this expression does not get us any further. We still must estimate roughly 2d parameters. However, if we assume that the features are conditionally independent of each other, given the label, then suddenly we are in much better shape, as this term simplifies to ∏ip(xi∣y), giving us the predictor
英語のヒント
それだけでは、この式はこれ以上先に進ませてくれない。依然としておよそ2d個のパラメータを推定しなければならない。しかし、ラベルが与えられたもとで特徴が互いに条件付き独立だと仮定すると、この項は∏ip(xi∣y)に単純化されるので、急にずっとよい状態になり、次の予測器が得られる。
yˆ=argmaxy∏i=1dp(xi∣y)p(y).(22.9.4)
If we can estimate p(xi=1∣y) for every i and y, and save its value in Pxy[i,y], here Pxy is a d×n matrix with n being the number of classes and y∈{1,…,n}, then we can also use this to estimate p(xi=0∣y), i.e.,
英語のヒント
すべてのiとyについてp(xi=1∣y)を推定し、その値をPxy[i,y]に保存できれば(ここでPxyはd×n行列で、nはクラスの数、y∈{1,…,n}である)、これを使ってp(xi=0∣y)も推定できる。つまり、
p(xi=ti∣y)={Pxy[i,y]for ti=1;1−Pxy[i,y]for ti=0.(22.9.5)
In addition, we estimate p(y) for every y and save it in Py[y], with Py a n-length vector. Then, for any new example 𝐭=(t1,t2,…,td), we could compute
英語のヒント
さらに、すべてのyについてp(y)を推定し、それをPy[y]に保存する。ここでPyは長さnのベクトルである。すると、任意の新しい例𝐭=(t1,t2,…,td)について、次を計算できる。
yˆ=argmaxy p(y)∏i=1dp(xt=ti∣y)=argmaxy Py[y]∏i=1d Pxy[i,y]ti(1−Pxy[i,y])1−ti(22.9.6)
for any y. So our assumption of conditional independence has taken the complexity of our model from an exponential dependence on the number of features 𝒪(2dn) to a linear dependence, which is 𝒪(dn).
英語のヒント
これは任意のyについてである。したがって、条件付き独立の仮定によって、モデルの計算量は、特徴の数への指数的な依存𝒪(2dn)から、線形の依存𝒪(dn)になった。