LTI-Lib latest version v1.9 - last update 24 Nov 2005
Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

lti::hmmClassifier Class Reference

This class defines training and classification methods for Hidden Markov Models (HMM) using observation sequences. More...

#include <ltiHmmClassifier.h>

Inheritance diagram for lti::hmmClassifier:

Inheritance graph
[legend]
Collaboration diagram for lti::hmmClassifier:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 hmmClassifier ()
 hmmClassifier (const hmmClassifier &other)
virtual ~hmmClassifier ()
virtual const char * getTypeName () const
hmmClassifiercopy (const hmmClassifier &other)
hmmClassifieroperator= (const hmmClassifier &other)
virtual classifierclone () const
const parametersgetParameters () const
virtual bool write (ioHandler &handler, const bool complete=true) const
virtual bool read (ioHandler &handler, const bool complete=true)
Training routines
These methods are needed to train Hidden Markov models.

virtual bool train (const std::vector< sequence< dvector > > &input, const ivector &ids)
bool train (std::vector< sequence< dvector > > &input, int id)
void reset ()
Classification routines.
These methods are used for classification.

virtual bool classify (const sequence< dvector > &observations, outputVector &result)
bool reducedClassify (const sequence< dvector > &observations, outputVector &result, std::map< int, std::string > usedModelsIDNameMap)
Direct access routines
These methods are used to directly access/change the Hidden Markov models used internally. Note that changing single models may lead to incorrect output templates!

ivector getIDs ()
hiddenMarkovModel getHMM (int id) const
bool setHMM (hiddenMarkovModel &model, int id)
bool deleteHMM (int id)
void setName (int id, const std::string &theName)
void generateIndexNameMap (std::map< int, std::string > &theMap) const
int getShortestModelLength () const

Protected Attributes

std::map< int, hiddenMarkovModeltheModels
int featureDimension

Classes

class  parameters
 the parameters for the class hmmClassifier More...

Detailed Description

This class defines training and classification methods for Hidden Markov Models (HMM) using observation sequences.

The algorithms are taken from "Fundamentals of speech recognition" (L. Rabiner and B.-H. Juang, Prentice Hall, 1993) and can also be found in "Erkennung kontinuierlicher Gebärdensprache mit Ganzwortmodellen" (H. C. Hienz, PhD thesis, Chair of Technical Computer Science, 2000). The notation in this documentation is taken from the latter literature.

In case of classification, the probability $P(\mathbf{O}|\lambda)$ of the observation sequence $\mathbf{O}$ is approximated by the observation probability $P^*(\mathbf{O}|\lambda)$ of the best path $\mathbf{q^*}$ . The best path is found with the Viterbi algorithm. Increased computational efficiency and precision are achieved by using scores with $Score(\mathbf{X}|\lambda):=-\ln P^*(\mathbf{X}|\lambda)$ instead of probabilities. Note that the lowest score corresponds to the highest probability and thus represents the best recognition result.

Note: The values in the outputVector are not probabilities! To match the value criteria (higher values represent better recognition results, positive values only), scores are mapped to values between 0.0 and 1.0. Currently exponential, linear, and none are available.

exponential (default)
$\left[ \frac{1.0}{score-lowestScore + 1.0} - \frac{1.0}{(highestScore-lowestScore)+1.0}\right] \cdot \frac{(highestScore-lowestScore)+1.0}{highestScore-lowestScore}$
linear
$value = \frac{highestScore-score}{highestScore-lowestScore}$
none
$value = score$


Constructor & Destructor Documentation

lti::hmmClassifier::hmmClassifier  ) 
 

default constructor

lti::hmmClassifier::hmmClassifier const hmmClassifier other  ) 
 

copy constructor

Parameters:
other the object to be copied

virtual lti::hmmClassifier::~hmmClassifier  )  [virtual]
 

destructor


Member Function Documentation

virtual bool lti::hmmClassifier::classify const sequence< dvector > &  observations,
outputVector &  result
[virtual]
 

Classification.

Classifies the sequence of features and returns the outputVector with the classification result.

Parameters:
observations the sequence to be classified
result the result of the classification
Returns:
false if an error occurred during classification else true

Implements lti::supervisedSequenceClassifier.

virtual classifier* lti::hmmClassifier::clone  )  const [virtual]
 

returns a pointer to a clone of this functor.

Implements lti::classifier.

Reimplemented in lti::hmmOnlineClassifier.

hmmClassifier& lti::hmmClassifier::copy const hmmClassifier other  ) 
 

copy data of "other" functor.

Parameters:
other the functor to be copied
Returns:
a reference to this functor object

bool lti::hmmClassifier::deleteHMM int  id  ) 
 

Delete the model with the given id.

Note: the output template may contain incorrect values after this!

Returns:
true, if successful, false otherwise.

void lti::hmmClassifier::generateIndexNameMap std::map< int, std::string > &  theMap  )  const
 

Generate a map ID -> name for all loaded models.

hiddenMarkovModel lti::hmmClassifier::getHMM int  id  )  const
 

Returns a copy of the model with the given id.

If no such model exists, the empty default model given in parameters is returned.

ivector lti::hmmClassifier::getIDs  ) 
 

Query id's of trained models.

Returns:
vector containing the ids of all models of this classifier.

const parameters& lti::hmmClassifier::getParameters  )  const
 

returns used parameters

Reimplemented from lti::supervisedSequenceClassifier.

Reimplemented in lti::hmmOnlineClassifier.

int lti::hmmClassifier::getShortestModelLength  )  const
 

Returns the length of the shortest model.

This allows to tell if an observation of a certain length can be classified by this classifier. If no models are available, -1 will be returned.

virtual const char* lti::hmmClassifier::getTypeName  )  const [virtual]
 

returns the name of this type ("hmmClassifier")

Reimplemented from lti::supervisedSequenceClassifier.

Reimplemented in lti::hmmOnlineClassifier.

hmmClassifier& lti::hmmClassifier::operator= const hmmClassifier other  ) 
 

alias for copy member

Parameters:
other the classifier to be copied
Returns:
a reference to this classifier object

virtual bool lti::hmmClassifier::read ioHandler handler,
const bool  complete = true
[virtual]
 

read method

Reimplemented from lti::classifier.

Reimplemented in lti::hmmOnlineClassifier.

bool lti::hmmClassifier::reducedClassify const sequence< dvector > &  observations,
outputVector &  result,
std::map< int, std::string >  usedModelsIDNameMap
 

Reduced Classification.

Classifies the sequence of features only with a reduced number of models given in usedModelsIDNameMap. Returns the outputVector with the classification result.

Parameters:
observations the sequence to be classified
result the result of the classification
usedModelsIDNameMap map of hmm models given by id and name
Returns:
false if an error occurred during classification else true

void lti::hmmClassifier::reset  ) 
 

Deletes all models saved internally.

Reimplemented in lti::hmmOnlineClassifier.

bool lti::hmmClassifier::setHMM hiddenMarkovModel model,
int  id
 

Set the model to be used for the given id.

Note: the output template may contain incorrect values hereafter!

Returns:
true, if successful, false otherwise

void lti::hmmClassifier::setName int  id,
const std::string &  theName
 

Set the name of a specific model (if a model with the given ID exists).

bool lti::hmmClassifier::train std::vector< sequence< dvector > > &  input,
int  id
 

Training of a single model.

The given sequences are used to train the model of the given id. If such a model already exists internally, it will be overwritten. Training is performed with the training parameters given in the parameters class.

Note: if you train a single model this way, the output template may contain incorrect values!

virtual bool lti::hmmClassifier::train const std::vector< sequence< dvector > > &  input,
const ivector ids
[virtual]
 

Supervised sequence training.

The sequences in the input vector are used for training the sequence classifier. Each sequence is associated with an id given in the vector ids. Hidden Markov models are created for all given ids, existing models being deleted first. After the training process, the outputTemplate is generated on the training set.

Parameters:
input vector of training sequences
ids the classes of the training sequences
Returns:
true if successful, false otherwise. (if false you can check the error message with getStatusString())

Implements lti::supervisedSequenceClassifier.

virtual bool lti::hmmClassifier::write ioHandler handler,
const bool  complete = true
const [virtual]
 

write method

Reimplemented from lti::classifier.

Reimplemented in lti::hmmOnlineClassifier.


Member Data Documentation

int lti::hmmClassifier::featureDimension [protected]
 

feature dimension (saved here for faster access)

std::map<int, hiddenMarkovModel> lti::hmmClassifier::theModels [protected]
 

the models with the given ids.


The documentation for this class was generated from the following file:
Generated on Thu Nov 24 16:32:06 2005 for LTI-Lib by Doxygen 1.4.4