Now let's do one more example of a probabilistic problem--this time, spelling correction.
That is, given a word that is possibly misspelled,
how do we come up with the best correction for that word?
We're going to do the same type of analysis.
We're saying we're looking for the best possible correction, C*,
and that's going to be the argmax over all possible corrections c to maximize
the probability of that correction given the word.
So that's the definition of what it means to have the best correction.
Then we can start the analysis, and we can apply Bayes rule to say
that's going to be equal to the probability of the word given the correction
times the probability of the correction.
Of course, in Bayes rule there's a factor on the bottom, but that cancels out,
because it's equal for all possible corrections.
So to choose the maximum, we just have to deal with these two probabilities.
Now, it may seem like we made a backwards step.
Here we had one probability to estimate.
Now we've applied Bayes rule and now we have two probabilities we have to estimate,
but the hope is that we can come up with data that can help us with this.
And certainly, these unigram statistics--what's the probability of a correction?--
those we can get from our document counts, so we look at our corpus.
The probability of a correct word is from the data.
We just look at those counts and apply whatever smoothing we decided is best.
Now, the other part--what's the probability that somebody typed the word w
when they meant to type to the word c--that's harder.
We can't observe that directly by just looking at documents that are typed,
because there we only have the words where we are.
We don't have the intent and the word,
but maybe we can look at lists of spelling corrections.
So this is from spelling correction data.
Now that kind of data is much harder to come by.
It's easy to go out and collect billions of words of regular text and do those counts,
but to find spelling correction data--that's harder to do
unless you're, say, already running a spelling correction service.
If you're a big company that happens to run that, then it's easy to collect the data.
But bootstrapping it is hard.
There are, however, some sites that will give you on the order of thousands
or tens of thousands of examples of misspellings, not billions or trillions.
もう1つ確率的な問題の例を挙げましょう
スペル修正です
スペルに誤りがある単語に対し
どのように最適な修正語を導くとかいう問題です
これまでと同じ分析をしてみます
最適だと思われる修正語をC*として
数式を立てます
C*はすべての修正語の候補cのargmaxに等しく
ある単語が与えられた時の
可能な修正の確率P(c|w)を最大化します
これが最適な修正語を得る定義を表す式です
ここから分析してベイズの定理を適用すると
これが修正されるべき元の単語の確率P(w|c)と
修正語cの確率の積に等しいことが分かります
ベイズの定理では分母の要素が必要ですが
どの修正cとも同じなので
ここでは省略します
従って最大値を取るために必要なのは
この2つの確率だけです
ここでは逆向きのステップを取るようです
こちらでは推定する確率は1つでしたが
ベイズの定理を適用し推定する確率は
2つになりました
しかしデータが得られれば
この推定に役立てることができます
P(c)が表すユニグラムの統計
つまり修正語の確率は
集めた文書から得ることができるので
コーパスを見ていきます
修正語の確率P(c)は
データから得られます
文書データの数に合わせて
最適なスムージングを選び適用します
もう1つここで求める確率は
cと入力すべき単語が
wで入力されてしまった場合の確率で
こちらはより複雑です
入力された文書を見るだけでは
こうした単語一覧を探し出すことはできません
与えられた単語には限りがあり
意味も種類も分かりません
しかしスペル修正のリストなら
見られるかもしれません
従ってこれはスペル修正のデータから得られます
こうしたデータを得るのはとても困難です
文章を構成する数十億もの単語を
集めて数えるのはまだできますが
スペル修正のデータを見つけるのは
修正機能を使っていない限り
容易ではありません
スペル修正機能からのデータ収集なら簡単です
ブートストラッピングは難しいでしょう
しかし数十億や数兆まではいきませんが
数千数万ものスペルミスの例を
提供するサイトもいくつかあります