MaximumLikelihoodLearning Class |
Namespace: Accord.Statistics.Models.Markov.Learning
public class MaximumLikelihoodLearning : BaseMaximumLikelihoodLearning<HiddenMarkovModel, GeneralDiscreteDistribution, int, GeneralDiscreteOptions>, ISupervisedLearning, ISupervisedLearning<HiddenMarkovModel, int[], int[]>
The MaximumLikelihoodLearning type exposes the following members.
Name | Description | |
---|---|---|
MaximumLikelihoodLearning |
Creates a new instance of the Maximum Likelihood learning algorithm.
| |
MaximumLikelihoodLearning(HiddenMarkovModel) |
Creates a new instance of the Maximum Likelihood learning algorithm.
|
Name | Description | |
---|---|---|
Emissions |
Gets or sets the function that initializes the emission
distributions in the hidden Markov Models.
(Inherited from BaseMaximumLikelihoodLearningTModel, TDistribution, TObservation, TOptions.) | |
FittingOptions |
Gets or sets the distribution fitting options
to use when estimating distribution densities
during learning.
(Inherited from BaseMaximumLikelihoodLearningTModel, TDistribution, TObservation, TOptions.) | |
Model |
Gets the model being trained.
(Inherited from BaseMaximumLikelihoodLearningTModel, TDistribution, TObservation, TOptions.) | |
Token |
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.) | |
UseLaplaceRule |
Gets or sets whether to use Laplace's rule
of succession to avoid zero probabilities.
(Inherited from BaseMaximumLikelihoodLearningTModel, TDistribution, TObservation, TOptions.) | |
UseWeights |
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.) |
Name | Description | |
---|---|---|
Create |
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).) | |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
Learn |
Learns a model that can map the given inputs to the given outputs.
(Inherited from BaseMaximumLikelihoodLearningTModel, TDistribution, TObservation, TOptions.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
Run | Obsolete.
Runs the Maximum Likelihood learning algorithm for hidden Markov models.
| |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Name | Description | |
---|---|---|
HasMethod |
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.) | |
IsEqual |
Compares two objects for equality, performing an elementwise
comparison if the elements are vectors or matrices.
(Defined by Matrix.) | |
To(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.) | |
ToT | 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.) |
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.
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();