Daniel S. T. Hughes > Algorithm-BaumWelch-v0.0.2 > Algorithm::BaumWelch

Download:
Algorithm-BaumWelch-v0.0.2.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: v0.0.2   Source  

NAME ^

Algorithm::BaumWelch - Baum-Welch Algorithm for Hidden Markov Chain parameter estimation.

VERSION ^

This document describes Algorithm::BaumWelch version 0.0.2

SYNOPSIS ^

    use Algorithm::BaumWelch;

    # The observation series see http://www.cs.jhu.edu/~jason/.
    my $obs_series = [qw/ obs2 obs3 obs3 obs2 obs3 obs2 obs3 obs2 obs2 
                          obs3 obs1 obs3 obs3 obs1 obs1 obs1 obs2 obs1 
                          obs1 obs1 obs3 obs1 obs2 obs1 obs1 obs1 obs2 
                          obs3 obs3 obs2 obs3 obs2 obs2
                     /];

    # The emission matrix - each nested array corresponds to the probabilities of a single observation type.
    my $emis = { 
        obs1 =>  [0.3, 0.3], 
        obs2 =>  [0.3, 0.4], 
        obs3 =>  [0.4, 0.3], 
               };

    # The transition matrixi - each row and column correspond to a particular state e.g. P(state1_x|state1_x-1) = 0.9...
    my $trans = [ 
                    [0.9, 0.1], 
                    [0.1, 0.9], 
                ];

    # The probabilities of each state at the start of the series.
    my $start = [0.5, 0.5];

    # Create an Algorithm::BaumWelch object.
    my $ba = Algorithm::BaumWelch->new;

    # Feed in the observation series.
    $ba->feed_obs($obs_series);

    # Feed in the transition and emission matrices and the starting probabilities.
    $ba->feed_values($trans, $emis, $start);

    # Alternatively you can randomly initialise the values - pass it the number of hidden states - 
    # i.e. to determine the parameters we need to make a first guess).
    # $ba->random_initialise(2);
     
    # Perform the algorithm.
    $ba->baum_welch;

    # Use results to pass data. 
    # In VOID-context prints formated results to STDOUT. 
    # In LIST-context returns references to the predicted transition & emission matrices and the starting parameters.
    $ba->results;

DESCRIPTION ^

The Baum-Welch algorithm is used to compute the parameters (transition and emission probabilities) of an Hidden Markov Model (HMM). The algorithm calculates the forward and backwards probabilities for each HMM state in a series and then re-estimates the parameters of the model.

SEE ALSO ^

Algorithm::Viterbi

DEPENDENCIES ^

'Carp' => '1.08', 'Math::Cephes' => '0.47', 'List::Util' => '1.19', 'Text::SimpleTable' => '2.0',

WARNING ^

This module Baum-Welch implementation has been tested fairly extensively with 2-hidden state cases but as yet has been subject to little (almost no) testing with >2 hidden states.

BUGS AND LIMITATIONS ^

Let me know.

AUTHOR ^

Daniel S. T. Hughes <dsth@cantab.net>

LICENCE AND COPYRIGHT ^

Copyright (c) 2010, Daniel S. T. Hughes <dsth@cantab.net>. All rights reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.

DISCLAIMER OF WARRANTY ^

Because this software is licensed free of charge, there is no warranty for the software, to the extent permitted by applicable law. Except when otherwise stated in writing the copyright holders and/or other parties provide the software "as is" without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. The entire risk as to the quality and performance of the software is with you. Should the software prove defective, you assume the cost of all necessary servicing, repair, or correction.

In no event unless required by applicable law or agreed to in writing will any copyright holder, or any other party who may modify and/or redistribute the software as permitted by the above licence, be liable to you for damages, including any general, special, incidental, or consequential damages arising out of the use or inability to use the software (including but not limited to loss of data or data being rendered inaccurate or losses sustained by you or third parties or a failure of the software to operate with any other software), even if such holder or other party has been advised of the possibility of such damages.

syntax highlighting: