## org.apache.mahout.classifier.sequencelearning.hmm
Class HmmModel

    java.lang.Object
      org.apache.mahout.classifier.sequencelearning.hmm.HmmModel

All Implemented Interfaces:
  Cloneable

    public class HmmModel

extends Object
implements Cloneable

Main class defining a Hidden Markov Model

Constructor Summary
`HmmModel(int nrOfHiddenStates, int nrOfOutputStates)` Construct a valid random Hidden-Markov parameter set with the given number of hidden and output states.
`HmmModel(int nrOfHiddenStates, int nrOfOutputStates, long seed)` Construct a valid random Hidden-Markov parameter set with the given number of hidden and output states using a given seed.
`HmmModel(Matrix transitionMatrix, Matrix emissionMatrix, Vector initialProbabilities)` Generates a Hidden Markov model using the specified parameters

Method Summary
`void` `assign(HmmModel model)` Assign the content of another HMM model to this one
`HmmModel` `clone()` Get a copy of this model
`Matrix` `getEmissionMatrix()` Getter function to get the output state probability matrix
`int` `getHiddenStateID(String name)` Lookup the ID for the given hidden state name
`String` `getHiddenStateName(int id)` Lookup the name for the given hidden state ID
`Map<String,Integer>` `getHiddenStateNames()` Getter method for the hidden state Names map
`Vector` `getInitialProbabilities()` Getter function to return the vector of initial hidden state probabilities
`int` `getNrOfHiddenStates()` Getter Method for the number of hidden states
`int` `getNrOfOutputStates()` Getter Method for the number of output states
`int` `getOutputStateID(String name)` Lookup the ID for the given output state name
`String` `getOutputStateName(int id)` Lookup the name for the given output state id
`Map<String,Integer>` `getOutputStateNames()` Getter method for the output state Names map
`Matrix` `getTransitionMatrix()` Getter function to get the hidden state transition matrix
`void` `registerHiddenStateNames(Map<String,Integer> stateNames)` Register a map of hidden state Names/state IDs
`void` `registerHiddenStateNames(String[] stateNames)` Register an array of hidden state Names.
`void` `registerOutputStateNames(Map<String,Integer> stateNames)` Register a map of hidden state Names/state IDs
`void` `registerOutputStateNames(String[] stateNames)` Register an array of hidden state Names.

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### HmmModel

    public HmmModel(int nrOfHiddenStates,
                    int nrOfOutputStates,
                    long seed)

  Construct a valid random Hidden-Markov parameter set with the given number of hidden and output states using a given seed.

  Parameters:
    `nrOfHiddenStates` - Number of hidden states
    `nrOfOutputStates` - Number of output states
    `seed` - Seed for the random initialization, if set to 0 the current time is used

### HmmModel

    public HmmModel(int nrOfHiddenStates,
                    int nrOfOutputStates)

  Construct a valid random Hidden-Markov parameter set with the given number of hidden and output states.

  Parameters:
    `nrOfHiddenStates` - Number of hidden states
    `nrOfOutputStates` - Number of output states

### HmmModel

    public HmmModel(Matrix transitionMatrix,
                    Matrix emissionMatrix,
                    Vector initialProbabilities)

  Generates a Hidden Markov model using the specified parameters

  Parameters:
    `transitionMatrix` - transition probabilities.
    `emissionMatrix` - emission probabilities.
    `initialProbabilities` - initial start probabilities.
  Throws:
    `IllegalArgumentException` - If the given parameter set is invalid

Method Detail

### clone

    public HmmModel clone()

  Get a copy of this model

  Overrides:
    `clone` in class `Object`

### assign

    public void assign(HmmModel model)

  Assign the content of another HMM model to this one

  Parameters:
    `model` - The HmmModel that will be assigned to this one

### getNrOfHiddenStates

    public int getNrOfHiddenStates()

  Getter Method for the number of hidden states

  Returns:
    Number of hidden states

### getNrOfOutputStates

    public int getNrOfOutputStates()

  Getter Method for the number of output states

  Returns:
    Number of output states

### getTransitionMatrix

    public Matrix getTransitionMatrix()

  Getter function to get the hidden state transition matrix

  Returns:
    returns the model's transition matrix.

### getEmissionMatrix

    public Matrix getEmissionMatrix()

  Getter function to get the output state probability matrix

  Returns:
    returns the models emission matrix.

### getInitialProbabilities

    public Vector getInitialProbabilities()

  Getter function to return the vector of initial hidden state probabilities

  Returns:
    returns the model's init probabilities.

### getHiddenStateNames

    public Map<String,Integer> getHiddenStateNames()

  Getter method for the hidden state Names map

  Returns:
    hidden state names.

### registerHiddenStateNames

    public void registerHiddenStateNames(String[] stateNames)

  Register an array of hidden state Names. We assume that the state name at position i has the ID i

  Parameters:
    `stateNames` - names of hidden states.

### registerHiddenStateNames

    public void registerHiddenStateNames(Map<String,Integer> stateNames)

  Register a map of hidden state Names/state IDs

  Parameters:
    `stateNames` - <String,Integer> Map that assigns each state name an integer ID

### getHiddenStateName

    public String getHiddenStateName(int id)

  Lookup the name for the given hidden state ID

  Parameters:
    `id` - Integer id of the hidden state
  Returns:
    String containing the name for the given ID, null if this ID is not known or no hidden state names were specified

### getHiddenStateID

    public int getHiddenStateID(String name)

  Lookup the ID for the given hidden state name

  Parameters:
    `name` - Name of the hidden state
  Returns:
    int containing the ID for the given name, -1 if this name is not known or no hidden state names were specified

### getOutputStateNames

    public Map<String,Integer> getOutputStateNames()

  Getter method for the output state Names map

  Returns:
    names of output states.

### registerOutputStateNames

    public void registerOutputStateNames(String[] stateNames)

  Register an array of hidden state Names. We assume that the state name at position i has the ID i

  Parameters:
    `stateNames` - state names to register.

### registerOutputStateNames

    public void registerOutputStateNames(Map<String,Integer> stateNames)

  Register a map of hidden state Names/state IDs

  Parameters:
    `stateNames` - <String,Integer> Map that assigns each state name an integer ID

### getOutputStateName

    public String getOutputStateName(int id)

  Lookup the name for the given output state id

  Parameters:
    `id` - Integer id of the output state
  Returns:
    String containing the name for the given id, null if this id is not known or no output state names were specified

### getOutputStateID

    public int getOutputStateID(String name)

  Lookup the ID for the given output state name

  Parameters:
    `name` - Name of the output state
  Returns:
    int containing the ID for the given name, -1 if this name is not known or no output state names were specified

Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.