Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes

HiddenMarkovModel Class Reference

Hidden Markov Model implementation of PILIS. More...

#include <OpenMS/ANALYSIS/ID/HiddenMarkovModel.h>

List of all members.

Public Member Functions

HiddenMarkovModeloperator= (const HiddenMarkovModel &)
 assignment operator
Constructors and destructors

 HiddenMarkovModel ()
 default constructor
 HiddenMarkovModel (const HiddenMarkovModel &hmm_new)
 copy constructor
virtual ~HiddenMarkovModel ()
 destructor

void writeGraphMLFile (const String &filename)
 writes the HMM into a file in GraphML format
void write (std::ostream &out) const
 writes the HMM into an outstream
DoubleReal getTransitionProbability (const String &s1, const String &s2) const
 returns the transition probability of the given state names
void setTransitionProbability (const String &s1, const String &s2, DoubleReal prob)
 sets the transition probability of the given state names to prob
Size getNumberOfStates () const
 return the number of states
void addNewState (HMMState *state)
 registers a new state to the HMM
void addNewState (const String &name)
 registers a new state to the HMM
void addSynonymTransition (const String &name1, const String &name2, const String &synonym1, const String &synonym2)
 add a new synonym transition to the given state names
void evaluate ()
 evaluate the HMM, estimates the transition probabilities from the training
void train ()
 trains the HMM; initial probabilities and emission probabilities of the emitting states should be set
void setInitialTransitionProbability (const String &state, DoubleReal prob)
 sets the initial transition probability of the given state to prob
void clearInitialTransitionProbabilities ()
 clears the initial probabilities
void setTrainingEmissionProbability (const String &state, DoubleReal prob)
 sets the emission probability of the given state to prob
void clearTrainingEmissionProbabilities ()
 clear the emission probabilities
void enableTransition (const String &s1, const String &s2)
 enables a transition; adds s1 to the predecessor list of s2 and s2 to the successor list of s1
void disableTransition (const String &s1, const String &s2)
 disables the transition; deletes the nodes from the predeccessor/successor list repsectively
void disableTransitions ()
 disables all transitions
void calculateEmissionProbabilities (Map< HMMState *, DoubleReal > &emission_probs)
 calculates the emission probabilities of the HMM (of course only of the non-hidden states)
void dump ()
 writes some stats to cerr
void forwardDump ()
 writes some info of the forward "matrix" to cerr
void estimateUntrainedTransitions ()
 builds a synonyms structure, needed when synonyms are used
HMMStategetState (const String &name)
 returns the state with the given name
const HMMStategetState (const String &name) const
 returns the state with the given name
void clear ()
 clears all data
void setPseudoCounts (DoubleReal pseudo_counts)
 sets the pseudo count that are added instead of zero
DoubleReal getPseudoCounts () const
 returns the pseudo counts
void setVariableModifications (const StringList &modifications)

Protected Member Functions

void disableTransition_ (HMMState *s1, HMMState *s2)
 disables the transition; deletes the nodes from the predeccessor/successor list repsectively
void enableTransition_ (HMMState *s1, HMMState *s2)
 enables a transition; adds s1 to the predecessor list of s2 and s2 to the successor list of s1
void setTrainingEmissionProbability_ (HMMState *state, DoubleReal prob)
 sets the emission probability of the given state to prob
void setTransitionProbability_ (HMMState *s1, HMMState *s2, DoubleReal prob)
 sets the transition probability of the given states to prob
DoubleReal getTransitionProbability_ (HMMState *s1, HMMState *s2) const
 returns the transition probability of the given states
void calculateForwardPart_ ()
 performs the forward algorithm
void calculateBackwardPart_ ()
 performs the backward algorithm
DoubleReal getForwardVariable_ (HMMState *)
 returns the forward variable
DoubleReal getBackwardVariable_ (HMMState *)
 returns the backward variable

Private Member Functions

void copy_ (const HiddenMarkovModel &source)

Private Attributes

Map< HMMState *, Map< HMMState
*, DoubleReal > > 
trans_
Map< HMMState *, Map< HMMState
*, DoubleReal > > 
count_trans_
Map< HMMState *, Map< HMMState
*, std::vector< DoubleReal > > > 
count_trans_all_
Map< HMMState *, Map< HMMState
*, std::vector< DoubleReal > > > 
train_count_trans_all_
Map< HMMState *, Map< HMMState
*, Size > > 
training_steps_count_
Map< HMMState *, DoubleRealforward_
Map< HMMState *, DoubleRealbackward_
Map< String, HMMState * > name_to_state_
Map< HMMState *, DoubleRealtrain_emission_prob_
Map< HMMState *, DoubleRealinit_prob_
std::set< HMMState * > states_
std::set< std::pair< HMMState
*, HMMState * > > 
trained_trans_
Map< String, Map< String,
std::pair< String, String > > > 
synonym_trans_names_
Map< HMMState *, Map< HMMState
*, std::pair< HMMState
*, HMMState * > > > 
synonym_trans_
Map< HMMState *, std::set
< HMMState * > > 
enabled_trans_
DoubleReal pseudo_counts_
StringList var_modifications_

Detailed Description

Hidden Markov Model implementation of PILIS.

Hidden Markov Model implementation suitable for forward conncected HMMs. The HMM is mostly used within PILIS. For further details have a look at the docs of PILIS.


Constructor & Destructor Documentation

default constructor

HiddenMarkovModel ( const HiddenMarkovModel hmm_new  ) 

copy constructor

virtual ~HiddenMarkovModel (  )  [virtual]

destructor


Member Function Documentation

void addNewState ( HMMState state  ) 

registers a new state to the HMM

void addNewState ( const String name  ) 

registers a new state to the HMM

void addSynonymTransition ( const String name1,
const String name2,
const String synonym1,
const String synonym2 
)

add a new synonym transition to the given state names

void calculateBackwardPart_ (  )  [protected]

performs the backward algorithm

void calculateEmissionProbabilities ( Map< HMMState *, DoubleReal > &  emission_probs  ) 

calculates the emission probabilities of the HMM (of course only of the non-hidden states)

void calculateForwardPart_ (  )  [protected]

performs the forward algorithm

void clear (  ) 

clears all data

void clearInitialTransitionProbabilities (  ) 

clears the initial probabilities

void clearTrainingEmissionProbabilities (  ) 

clear the emission probabilities

void copy_ ( const HiddenMarkovModel source  )  [private]
void disableTransition ( const String s1,
const String s2 
)

disables the transition; deletes the nodes from the predeccessor/successor list repsectively

void disableTransition_ ( HMMState s1,
HMMState s2 
) [protected]

disables the transition; deletes the nodes from the predeccessor/successor list repsectively

void disableTransitions (  ) 

disables all transitions

void dump (  ) 

writes some stats to cerr

void enableTransition ( const String s1,
const String s2 
)

enables a transition; adds s1 to the predecessor list of s2 and s2 to the successor list of s1

void enableTransition_ ( HMMState s1,
HMMState s2 
) [protected]

enables a transition; adds s1 to the predecessor list of s2 and s2 to the successor list of s1

void estimateUntrainedTransitions (  ) 

builds a synonyms structure, needed when synonyms are used

estimates the transition probabilities of not trained transitions by averages similar trained ones

void evaluate (  ) 

evaluate the HMM, estimates the transition probabilities from the training

void forwardDump (  ) 

writes some info of the forward "matrix" to cerr

DoubleReal getBackwardVariable_ ( HMMState  )  [protected]

returns the backward variable

DoubleReal getForwardVariable_ ( HMMState  )  [protected]

returns the forward variable

Size getNumberOfStates (  )  const

return the number of states

DoubleReal getPseudoCounts (  )  const

returns the pseudo counts

HMMState* getState ( const String name  ) 

returns the state with the given name

const HMMState* getState ( const String name  )  const

returns the state with the given name

DoubleReal getTransitionProbability ( const String s1,
const String s2 
) const

returns the transition probability of the given state names

DoubleReal getTransitionProbability_ ( HMMState s1,
HMMState s2 
) const [protected]

returns the transition probability of the given states

HiddenMarkovModel& operator= ( const HiddenMarkovModel  ) 

assignment operator

void setInitialTransitionProbability ( const String state,
DoubleReal  prob 
)

sets the initial transition probability of the given state to prob

void setPseudoCounts ( DoubleReal  pseudo_counts  ) 

sets the pseudo count that are added instead of zero

void setTrainingEmissionProbability ( const String state,
DoubleReal  prob 
)

sets the emission probability of the given state to prob

void setTrainingEmissionProbability_ ( HMMState state,
DoubleReal  prob 
) [protected]

sets the emission probability of the given state to prob

void setTransitionProbability ( const String s1,
const String s2,
DoubleReal  prob 
)

sets the transition probability of the given state names to prob

void setTransitionProbability_ ( HMMState s1,
HMMState s2,
DoubleReal  prob 
) [protected]

sets the transition probability of the given states to prob

void setVariableModifications ( const StringList modifications  ) 
void train (  ) 

trains the HMM; initial probabilities and emission probabilities of the emitting states should be set

void write ( std::ostream &  out  )  const

writes the HMM into an outstream

void writeGraphMLFile ( const String filename  ) 

writes the HMM into a file in GraphML format

Accessors A detailed description of the GraphML format can be found under http://graphml.graphdrawing.org/


Member Data Documentation

Map<HMMState *, Map<HMMState *, std::vector<DoubleReal> > > count_trans_all_ [private]
Map<HMMState *, std::set<HMMState *> > enabled_trans_ [private]
std::set<HMMState *> states_ [private]
Map<HMMState *, Map<HMMState *, std::pair<HMMState *, HMMState *> > > synonym_trans_ [private]
Map<String, Map<String, std::pair<String, String> > > synonym_trans_names_ [private]
Map<HMMState *, Map<HMMState *, std::vector<DoubleReal> > > train_count_trans_all_ [private]
std::set<std::pair<HMMState *, HMMState *> > trained_trans_ [private]
Map<HMMState *, Map<HMMState *, DoubleReal> > trans_ [private]

OpenMS / TOPP release 1.10.0 Documentation generated on Thu Mar 7 2013 09:42:49 using doxygen 1.7.1