"Markov" (機械学習メソッド)
- Classifyのためのメソッドである.
- 指定された文字列の n グラム頻度を使ってクラス確率をモデル化する.
詳細とサブオプション
- マルコフ(Markov)モデルでは,訓練時間に各クラスについての n グラム言語モデルが計算される.検定時間では,各クラスの確率がベイズ理論
に従って計算される.
は指定されたクラスの言語モデルによって与えられる.
はクラスの事前確率である. - 次は,使用可能なオプションである.
-
"AdditiveSmoothing" .1 使用する平滑化パラメータ "MinimumTokenCount" Automatic 考慮する n グラムの最小数 "Order" Automatic n グラムの長さ - "Order"n のとき,このメソッドは文字列を(n+1)グラムに分割する.
- "Order"0のとき,このメソッドはユニグラム(シングルトークン)を使う.モデルはユニグラムモデルまたはネイティブベイズモデルと呼ぶことができる.
- "AdditiveSmoothing"の値はすべての n グラム数に加えられる.これは,言語モデルの正規化に使われる.
例題
すべて開く すべて閉じる例 (1)
c = Classify[{{"flour", "butter"}, {"pasta", "tomato"}, {"apple", "ice cream"}, {"salt", "meat"}, {"honey", "sugar", "butter"}} -> {"dessert", "main course", "dessert", "main course", "dessert"}, Method -> "Markov"]Information[c]c[{"tomato", "meat", "salt"}]オプション (4)
"AdditiveSmoothing" (2)
"AdditiveSmoothing"サブオプションを使って分類器を訓練する:
Classify[{{[image], "this is dark red"} -> Red, {[image], "this is blue"} -> Blue, {[image], "this is dark blue"} -> Blue, {[image], "this red is almost orange"} -> Red}, Method -> {"Markov", "AdditiveSmoothing" -> 2}]"AdditiveSmoothing"の値を変え,不均衡なデータ集合で2つの分類器を訓練する:
data = {"aaabb" -> True, "cdfff" -> True, "cdffvvv" -> True, "aaa" -> True, "vvvtul" -> False, "dqedewf" -> True};c1 = Classify[data, Method -> {"Markov", "AdditiveSmoothing" -> .1}];
c2 = Classify[data, Method -> {"Markov", "AdditiveSmoothing" -> 7}];c1["vvvtul", "Probabilities"]c2["vvvtul", "Probabilities"]"Order" (2)
Classify[{{[image], "this is dark red"} -> Red, {[image], "this is blue"} -> Blue, {[image], "this is dark blue"} -> Blue, {[image], "this red is almost orange"} -> Red}, Method -> {"Markov", "Order" -> 2}]alphabet = Alphabet[];
randomstrings = RandomChoice[alphabet, RandomInteger[{2, 5}]];
realwords = DictionaryLookup["a" ~~ ___];
trainingset = <|"RealWord" -> RandomSample[realwords, 200],
"RandomString" -> Table[StringJoin@@randomstrings, 200]|>;c0 = Classify[trainingset, Method -> {"Markov" , "Order" -> 0}]c2 = Classify[trainingset, Method -> {"Markov", "Order" -> 2}]SeedRandom[4]
notRandom = RandomSample[DictionaryLookup["a" ~~ ___], 1];
Dataset@<|"Classifier1" -> c0[notRandom, "Probabilities"], "Classifier2" -> c2[notRandom, "Probabilities"]|>