Click or drag to resize
Accord.NET (logo)

MaximumLikelihoodLearning Class

Maximum Likelihood learning algorithm for discrete-density Hidden Markov Models.
Inheritance Hierarchy
SystemObject
  Accord.Statistics.Models.Markov.LearningBaseMaximumLikelihoodLearningHiddenMarkovModel, GeneralDiscreteDistribution, Int32, GeneralDiscreteOptions
    Accord.Statistics.Models.Markov.LearningMaximumLikelihoodLearning

Namespace:  Accord.Statistics.Models.Markov.Learning
Assembly:  Accord.Statistics (in Accord.Statistics.dll) Version: 3.8.0
Syntax
public class MaximumLikelihoodLearning : BaseMaximumLikelihoodLearning<HiddenMarkovModel, GeneralDiscreteDistribution, int, GeneralDiscreteOptions>, 
	ISupervisedLearning, ISupervisedLearning<HiddenMarkovModel, int[], int[]>
Request Example View Source

The MaximumLikelihoodLearning type exposes the following members.

Constructors
  NameDescription
Public methodMaximumLikelihoodLearning
Creates a new instance of the Maximum Likelihood learning algorithm.
Public methodMaximumLikelihoodLearning(HiddenMarkovModel)
Creates a new instance of the Maximum Likelihood learning algorithm.
Top
Properties
  NameDescription
Public propertyEmissions
Gets or sets the function that initializes the emission distributions in the hidden Markov Models.
(Inherited from BaseMaximumLikelihoodLearningTModel, TDistribution, TObservation, TOptions.)
Public propertyFittingOptions
Gets or sets the distribution fitting options to use when estimating distribution densities during learning.
(Inherited from BaseMaximumLikelihoodLearningTModel, TDistribution, TObservation, TOptions.)
Public propertyModel
Gets the model being trained.
(Inherited from BaseMaximumLikelihoodLearningTModel, TDistribution, TObservation, TOptions.)
Public propertyToken
Gets or sets a cancellation token that can be used to stop the learning algorithm while it is running.
(Inherited from BaseMaximumLikelihoodLearningTModel, TDistribution, TObservation, TOptions.)
Public propertyUseLaplaceRule
Gets or sets whether to use Laplace's rule of succession to avoid zero probabilities.
(Inherited from BaseMaximumLikelihoodLearningTModel, TDistribution, TObservation, TOptions.)
Public propertyUseWeights
Gets or sets whether the emission fitting algorithm should present weighted samples or simply the clustered samples to the density estimation methods.
(Inherited from BaseMaximumLikelihoodLearningTModel, TDistribution, TObservation, TOptions.)
Top
Methods
  NameDescription
Protected methodCreate
Creates an instance of the model to be learned. Inheritors of this abstract class must define this method so new models can be created from the training data.
(Overrides BaseMaximumLikelihoodLearningTModel, TDistribution, TObservation, TOptionsCreate(TObservation, Int32).)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodLearn
Learns a model that can map the given inputs to the given outputs.
(Inherited from BaseMaximumLikelihoodLearningTModel, TDistribution, TObservation, TOptions.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodRun Obsolete.
Runs the Maximum Likelihood learning algorithm for hidden Markov models.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodTo(Type)Overloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Public Extension MethodToTOverloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Top
Remarks

The maximum likelihood estimate is a supervised learning algorithm. It considers both the sequence of observations as well as the sequence of states in the Markov model are visible and thus during training.

Often, the Maximum Likelihood Estimate can be used to give a starting point to a unsupervised algorithm, making possible to use semi-supervised techniques with HMMs. It is possible, for example, to use MLE to guess initial values for an HMM given a small set of manually labeled labels, and then further estimate this model using the Viterbi learning algorithm.

Examples

The following example comes from Prof. Yechiam Yemini slides on Hidden Markov Models, available at http://www.cs.columbia.edu/4761/notes07/chapter4.3-HMM.pdf. In this example, we will be specifying both the sequence of observations and the sequence of states assigned to each observation in each sequence to learn our Markov model.

// Example from
// http://www.cs.columbia.edu/4761/notes07/chapter4.3-HMM.pdf

// Inputs
int[][] observations = 
{
    new int[] { 0,0,0,1,0,0 }, 
    new int[] { 1,0,0,1,0,0 },
    new int[] { 0,0,1,0,0,0 },
    new int[] { 0,0,0,0,1,0 },
    new int[] { 1,0,0,0,1,0 },
    new int[] { 0,0,0,1,1,0 },
    new int[] { 1,0,0,0,0,0 },
    new int[] { 1,0,1,0,0,0 },
};

// Outputs
int[][] paths =
{
    new int[] { 0,0,1,0,1,0 },
    new int[] { 1,0,1,0,1,0 },
    new int[] { 1,0,0,1,1,0 },
    new int[] { 1,0,1,1,1,0 },
    new int[] { 1,0,0,1,0,1 },
    new int[] { 0,0,1,0,0,1 },
    new int[] { 0,0,1,1,0,1 },
    new int[] { 0,1,1,1,0,0 },
};

// Create a hidden Markov model with 2 states for 2 symbols
var model = new HiddenMarkovModel(states: 2, symbols: 2);

// Create a Maximum Likelihood learning algorithm
var target = new MaximumLikelihoodLearning(model)
{
    UseLaplaceRule = false // don't use Laplace smoothing (to reproduce the example)
};

// Learn the Markov model
target.Learn(observations, paths);

// Recover the learned parameters
var pi = model.LogInitial.Exp();
var A = model.LogTransitions.Exp();
var B = model.LogEmissions.Exp();
See Also