mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r902892 - in /websites/staging/mahout/trunk/content: ./ users/stuff/hidden-markov-models.html
Date Sat, 22 Mar 2014 17:08:08 GMT
Author: buildbot
Date: Sat Mar 22 17:08:08 2014
New Revision: 902892

Log:
Staging update by buildbot for mahout

Modified:
    websites/staging/mahout/trunk/content/   (props changed)
    websites/staging/mahout/trunk/content/users/stuff/hidden-markov-models.html

Propchange: websites/staging/mahout/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Sat Mar 22 17:08:08 2014
@@ -1 +1 @@
-1579870
+1580262

Modified: websites/staging/mahout/trunk/content/users/stuff/hidden-markov-models.html
==============================================================================
--- websites/staging/mahout/trunk/content/users/stuff/hidden-markov-models.html (original)
+++ websites/staging/mahout/trunk/content/users/stuff/hidden-markov-models.html Sat Mar 22
17:08:08 2014
@@ -245,6 +245,48 @@ using the Viterbi algorithm.</li>
 model M*=argmax(M)P(O|M) to generate this sequence. The Learning problem
 can be efficiently solved using the Baum-Welch algorithm.</li>
 </ol>
+<p><a name="HiddenMarkovModels-Example"></a></p>
+<h2 id="example">Example</h2>
+<p>To build a Hidden Markov Model and use it to build some predictions, try a simple
example like this:</p>
+<p>Create an input file to train the model.  Here we have a sequence drawn from the
set of states 0, 1, 2, and 3, separated by space characters.</p>
+<div class="codehilite"><pre>$ <span class="n">echo</span> &quot;0
1 2 2 2 1 1 0 0 3 3 3 2 1 2 1 1 1 1 2 2 2 0 0 0 0 0 0 2 2 2 0 0 0 0 0 0 2 2 2 3 3 3 3 3 3
2 3 2 3 2 3 2 1 3 0 0 0 1 0 1 0 2 1 2 1 2 1 2 3 3 3 3 2 2 3 2 1 1 0&quot; <span class="o">&gt;</span>
<span class="n">hmm</span><span class="o">-</span><span class="n">input</span>
+</pre></div>
+
+
+<p>Now run the baumwelch job to train your model.</p>
+<div class="codehilite"><pre>$ $<span class="n">MAHOUT_HOME</span><span
class="o">/</span><span class="n">bin</span><span class="o">/</span><span
class="n">mahout</span> <span class="n">baumwelch</span> <span class="o">-</span><span
class="nb">i</span> <span class="n">hmm</span><span class="o">-</span><span
class="n">input</span> <span class="o">-</span><span class="n">o</span>
<span class="n">hmm</span><span class="o">-</span><span class="n">model</span>
<span class="o">-</span><span class="n">nh</span> 3 <span class="o">-</span><span
class="n">no</span> 4 <span class="o">-</span><span class="n">e</span>
<span class="p">.</span>0001 <span class="o">-</span><span class="n">m</span>
1000
+</pre></div>
+
+
+<p>The following output should appear in the console.</p>
+<div class="codehilite"><pre><span class="n">Initial</span> <span
class="n">probabilities</span><span class="p">:</span> 
+0 1 2 
+1<span class="p">.</span>0 0<span class="p">.</span>0 3<span class="p">.</span>5659361683006626<span
class="n">E</span><span class="o">-</span>251 
+<span class="n">Transition</span> <span class="n">matrix</span><span
class="p">:</span>
+  0 1 2 
+0 6<span class="p">.</span>098919959130616<span class="n">E</span><span
class="o">-</span>5 0<span class="p">.</span>9997275322964165 2<span
class="p">.</span>1147850399214744<span class="n">E</span><span class="o">-</span>4

+1 7<span class="p">.</span>404648706054873<span class="n">E</span><span
class="o">-</span>37 0<span class="p">.</span>9086408633885092 0<span
class="p">.</span>09135913661149081 
+2 0<span class="p">.</span>2284374545687356 7<span class="p">.</span>01786289571088<span
class="n">E</span><span class="o">-</span>11 0<span class="p">.</span>7715625453610858

+<span class="n">Emission</span> <span class="n">matrix</span><span
class="p">:</span> 
+  0 1 2 3 
+0 0<span class="p">.</span>9999997858591223 2<span class="p">.</span>0536163836449762<span
class="n">E</span><span class="o">-</span>39 2<span class="p">.</span>1414087769942127<span
class="n">E</span><span class="o">-</span>7 1<span class="p">.</span>052441093535389<span
class="n">E</span><span class="o">-</span>27 
+1 7<span class="p">.</span>495656581383351<span class="n">E</span><span
class="o">-</span>34 0<span class="p">.</span>2241269055449904 0<span
class="p">.</span>4510889999455847 0<span class="p">.</span>32478409450942497

+2 0<span class="p">.</span>815051477991782 0<span class="p">.</span>18494852200821799
8<span class="p">.</span>465660634827592<span class="n">E</span><span
class="o">-</span>33 2<span class="p">.</span>8603899591778015<span
class="n">E</span><span class="o">-</span>36 
+14<span class="o">/</span>03<span class="o">/</span>22 09<span
class="p">:</span>52<span class="p">:</span>21 <span class="n">INFO</span>
<span class="n">driver</span><span class="p">.</span><span class="n">MahoutDriver</span><span
class="p">:</span> <span class="n">Program</span> <span class="n">took</span>
180 <span class="n">ms</span> <span class="p">(</span><span class="n">Minutes</span><span
class="p">:</span> 0<span class="p">.</span>003<span class="p">)</span>
+</pre></div>
+
+
+<p>The model trained with the input set now is in the file 'hmm-model', which we can
use to build a predicted sequence.</p>
+<div class="codehilite"><pre>$ $<span class="n">MAHOUT_HOME</span><span
class="o">/</span><span class="n">bin</span><span class="o">/</span><span
class="n">mahout</span> <span class="n">hmmpredict</span> <span class="o">-</span><span
class="n">m</span> <span class="n">hmm</span><span class="o">-</span><span
class="n">model</span> <span class="o">-</span><span class="n">o</span>
<span class="n">hmm</span><span class="o">-</span><span class="n">predictions</span>
<span class="o">-</span><span class="n">l</span> 10
+</pre></div>
+
+
+<p>To see the predictions:</p>
+<div class="codehilite"><pre>$ <span class="nb">cat</span> <span
class="n">hmm</span><span class="o">-</span><span class="n">predictions</span>

+0 1 3 3 2 2 2 2 1 2
+</pre></div>
+
+
 <p><a name="HiddenMarkovModels-Resources"></a></p>
 <h2 id="resources">Resources</h2>
 <p>[1]



Mime
View raw message