CHMM Class Reference

Inheritance diagram for CHMM:

Inheritance graph
[legend]

List of all members.


Detailed Description

Hidden Markov Model. Structure and Function collection. This Class implements a Hidden Markov Model. Several functions for tasks such as training,reading/writing models, reading observations, calculation of derivatives are supplied.

Definition at line 358 of file HMM.h.


Public Member Functions

bool alloc_state_dependend_arrays ()
 allocates memory that depends on N
void free_state_dependend_arrays ()
 free memory that depends on N
bool linear_train (bool right_align=false)
 estimates linear model from observations.
bool permutation_entropy (INT window_width, INT sequence_number)
 compute permutation entropy
virtual INT get_num_relevant_model_parameters ()
virtual DREAL get_log_likelihood_sample ()
virtual void get_log_likelihood (DREAL **dst, INT *num)
virtual DREAL get_model_parameter (INT num_param)
virtual DREAL get_derivative (INT num_param, INT num_example)
virtual DREAL get_likelihood_example (INT num_example)
virtual void set_features (CFeatures *f)
virtual CFeaturesget_features ()
virtual void set_pseudo_count (DREAL pseudo)
virtual DREAL get_pseudo_count ()
Constructor/Destructor and helper function
Train definitions. Encapsulates Modelparameters that are constant/shall be learned. Consists of structures and access functions for learning only defined transitions and constants.

 CHMM (INT N, INT M, CModel *model, DREAL PSEUDO)
 CHMM (CStringFeatures< WORD > *obs, INT N, INT M, DREAL PSEUDO)
 CHMM (INT N, double *p, double *q, double *a)
 CHMM (INT N, double *p, double *q, int num_trans, double *a_trans)
 CHMM (FILE *model_file, DREAL PSEUDO)
 CHMM (CHMM *h)
 Constructor - Clone model h.
virtual ~CHMM ()
 Destructor - Cleanup.
virtual bool train ()
virtual INT get_num_model_parameters ()
virtual DREAL get_log_model_parameter (INT num_param)
virtual DREAL get_log_derivative (INT num_param, INT num_example)
virtual DREAL get_log_likelihood_example (INT num_example)
bool initialize (CModel *model, DREAL PSEUDO, FILE *model_file=NULL)
probability functions.
forward/backward/viterbi algorithm

DREAL forward_comp (INT time, INT state, INT dimension)
DREAL forward_comp_old (INT time, INT state, INT dimension)
DREAL backward_comp (INT time, INT state, INT dimension)
DREAL backward_comp_old (INT time, INT state, INT dimension)
DREAL best_path (INT dimension)
WORD get_best_path_state (INT dim, INT t)
DREAL model_probability_comp ()
DREAL model_probability (INT dimension=-1)
 inline proxy for model probability.
DREAL linear_model_probability (INT dimension)
convergence criteria
bool set_iterations (INT num)
INT get_iterations ()
bool set_epsilon (DREAL eps)
DREAL get_epsilon ()
bool baum_welch_viterbi_train (BaumWelchViterbiType type)
model training
void estimate_model_baum_welch (CHMM *train)
void estimate_model_baum_welch_old (CHMM *train)
void estimate_model_baum_welch_trans (CHMM *train)
void estimate_model_baum_welch_defined (CHMM *train)
void estimate_model_viterbi (CHMM *train)
void estimate_model_viterbi_defined (CHMM *train)
output functions.
void output_model (bool verbose=false)
void output_model_defined (bool verbose=false)
 performs output_model only for the defined transitions etc
model helper functions.
void normalize (bool keep_dead_states=false)
 normalize the model to satisfy stochasticity
void add_states (INT num_states, DREAL default_val=0)
bool append_model (CHMM *append_model, DREAL *cur_out, DREAL *app_out)
bool append_model (CHMM *append_model)
void chop (DREAL value)
 set any model parameter with probability smaller than value to ZERO
void convert_to_log ()
 convert model to log probabilities
void init_model_random ()
 init model with random values
void init_model_defined ()
void clear_model ()
 initializes model with log(PSEUDO)
void clear_model_defined ()
 initializes only parameters in learn_x with log(PSEUDO)
void copy_model (CHMM *l)
 copies the the modelparameters from l
void invalidate_model ()
bool get_status () const
DREAL get_pseudo () const
 returns current pseudo value
void set_pseudo (DREAL pseudo)
 sets current pseudo value
void set_observations (CStringFeatures< WORD > *obs, CHMM *lambda=NULL)
void set_observation_nocache (CStringFeatures< WORD > *obs)
CStringFeatures< WORD > * get_observations ()
 return observation pointer
load/save functions.
for observations/model/traindefinitions

bool load_definitions (FILE *file, bool verbose, bool initialize=true)
bool load_model (FILE *file)
bool save_model (FILE *file)
bool save_model_derivatives (FILE *file)
bool save_model_derivatives_bin (FILE *file)
bool save_model_bin (FILE *file)
bool check_model_derivatives ()
 numerically check whether derivates were calculated right
bool check_model_derivatives_combined ()
T_STATESget_path (INT dim, DREAL &prob)
bool save_path (FILE *file)
bool save_path_derivatives (FILE *file)
bool save_path_derivatives_bin (FILE *file)
bool save_likelihood_bin (FILE *file)
bool save_likelihood (FILE *file)
access functions for model parameters
for all the arrays a,b,p,q,A,B,psi and scalar model parameters like N,M

T_STATES get_N () const
 access function for number of states N
INT get_M () const
 access function for number of observations M
void set_q (T_STATES offset, DREAL value)
void set_p (T_STATES offset, DREAL value)
void set_A (T_STATES line_, T_STATES column, DREAL value)
void set_a (T_STATES line_, T_STATES column, DREAL value)
void set_B (T_STATES line_, WORD column, DREAL value)
void set_b (T_STATES line_, WORD column, DREAL value)
void set_psi (INT time, T_STATES state, T_STATES value, INT dimension)
DREAL get_q (T_STATES offset) const
DREAL get_p (T_STATES offset) const
DREAL get_A (T_STATES line_, T_STATES column) const
DREAL get_a (T_STATES line_, T_STATES column) const
DREAL get_B (T_STATES line_, WORD column) const
DREAL get_b (T_STATES line_, WORD column) const
T_STATES get_psi (INT time, T_STATES state, INT dimension) const
functions for observations
management and access functions for observation matrix

DREAL state_probability (INT time, INT state, INT dimension)
 calculates probability of being in state i at time t for dimension
DREAL transition_probability (INT time, INT state_i, INT state_j, INT dimension)
 calculates probability of being in state i at time t and state j at time t+1 for dimension
derivatives of model probabilities.
computes log dp(lambda)/d lambda_i
Parameters:
dimension dimension for that derivatives are calculated
i,j parameter specific


DREAL linear_model_derivative (T_STATES i, WORD j, INT dimension)
DREAL model_derivative_p (T_STATES i, INT dimension)
DREAL model_derivative_q (T_STATES i, INT dimension)
DREAL model_derivative_a (T_STATES i, T_STATES j, INT dimension)
 computes log dp(lambda)/d a_ij.
DREAL model_derivative_b (T_STATES i, WORD j, INT dimension)
 computes log dp(lambda)/d b_ij.
derivatives of path probabilities.
computes d log p(lambda,best_path)/d lambda_i
Parameters:
dimension dimension for that derivatives are calculated
i,j parameter specific


DREAL path_derivative_p (T_STATES i, INT dimension)
 computes d log p(lambda,best_path)/d p_i
DREAL path_derivative_q (T_STATES i, INT dimension)
 computes d log p(lambda,best_path)/d q_i
DREAL path_derivative_a (T_STATES i, T_STATES j, INT dimension)
 computes d log p(lambda,best_path)/d a_ij
DREAL path_derivative_b (T_STATES i, WORD j, INT dimension)
 computes d log p(lambda,best_path)/d b_ij

Static Public Attributes

static CParallel parallel
static CIO io
static CVersion version

Protected Member Functions

void prepare_path_derivative (INT dim)
 initialization function that is called before path_derivatives are calculated
DREAL forward (INT time, INT state, INT dimension)
 inline proxies for forward pass
DREAL backward (INT time, INT state, INT dimension)
 inline proxies for backward pass
input helper functions.
for reading model/definition/observation files

bool get_numbuffer (FILE *file, CHAR *buffer, INT length)
 put a sequence of numbers into the buffer
void open_bracket (FILE *file)
 expect open bracket.
void close_bracket (FILE *file)
 expect closing bracket
bool comma_or_space (FILE *file)
 expect comma or space.
void error (INT p_line, const CHAR *str)
 parse error messages

Protected Attributes

DREALarrayN1
DREALarrayN2
T_ALPHA_BETA alpha_cache
 cache for forward variables can be terrible HUGE O(T*N)
T_ALPHA_BETA beta_cache
 cache for backward variables can be terrible HUGE O(T*N)
T_STATESstates_per_observation_psi
 backtracking table for viterbi can be terrible HUGE O(T*N)
T_STATESpath
 best path (=state sequence) through model
bool path_prob_updated
 true if path probability is up to date
INT path_prob_dimension
 dimension for which path_prob was calculated
CFeaturesfeatures
DREAL pseudo_count
model specific variables.
these are p,q,a,b,N,M etc

INT M
 number of observation symbols eg. ACGT -> 0123
INT N
 number of states
DREAL PSEUDO
 define pseudocounts against overfitting
INT line
CStringFeatures< WORD > * p_observations
 observation matrix
CModelmodel
DREALtransition_matrix_A
 matrix of absolute counts of transitions
DREALobservation_matrix_B
 matrix of absolute counts of observations within each state
DREALtransition_matrix_a
 transition matrix
DREALinitial_state_distribution_p
 initial distribution of states
DREALend_state_distribution_q
 distribution of end-states
DREALobservation_matrix_b
 distribution of observations within each state
INT iterations
 convergence criterion iterations
INT iteration_count
DREAL epsilon
 convergence criterion epsilon
INT conv_it
DREAL all_pat_prob
 probability of best path
DREAL pat_prob
 probability of best path
DREAL mod_prob
 probability of model
bool mod_prob_updated
 true if model probability is up to date
bool all_path_prob_updated
 true if path probability is up to date
INT path_deriv_dimension
 dimension for which path_deriv was calculated
bool path_deriv_updated
 true if path derivative is up to date
bool loglikelihood
bool status
bool reused_caches

Static Protected Attributes

static const INT GOTN = (1<<1)
static const INT GOTM = (1<<2)
static const INT GOTO = (1<<3)
static const INT GOTa = (1<<4)
static const INT GOTb = (1<<5)
static const INT GOTp = (1<<6)
static const INT GOTq = (1<<7)
static const INT GOTlearn_a = (1<<1)
static const INT GOTlearn_b = (1<<2)
static const INT GOTlearn_p = (1<<3)
static const INT GOTlearn_q = (1<<4)
static const INT GOTconst_a = (1<<5)
static const INT GOTconst_b = (1<<6)
static const INT GOTconst_p = (1<<7)
static const INT GOTconst_q = (1<<8)

Constructor & Destructor Documentation

CHMM::CHMM ( INT  N,
INT  M,
CModel model,
DREAL  PSEUDO 
)

Constructor

Parameters:
N number of states
M number of emissions
model model which holds definitions of states to be learned + consts
PSEUDO Pseudo Value

Definition at line 162 of file HMM.cpp.

CHMM::CHMM ( CStringFeatures< WORD > *  obs,
INT  N,
INT  M,
DREAL  PSEUDO 
)

Definition at line 174 of file HMM.cpp.

CHMM::CHMM ( INT  N,
double *  p,
double *  q,
double *  a 
)

Definition at line 187 of file HMM.cpp.

CHMM::CHMM ( INT  N,
double *  p,
double *  q,
int  num_trans,
double *  a_trans 
)

Definition at line 235 of file HMM.cpp.

CHMM::CHMM ( FILE *  model_file,
DREAL  PSEUDO 
)

Constructor - Initialization from model file.

Parameters:
model_file Filehandle to a hmm model file (*.mod)
PSEUDO Pseudo Value

Definition at line 339 of file HMM.cpp.

CHMM::CHMM ( CHMM h  ) 

Constructor - Clone model h.

Definition at line 150 of file HMM.cpp.

CHMM::~CHMM (  )  [virtual]

Destructor - Cleanup.

Definition at line 347 of file HMM.cpp.


Member Function Documentation

virtual bool CHMM::train (  )  [virtual]

train distribution

abstrace base method

Returns:
if training was successful

Implements CDistribution.

Definition at line 491 of file HMM.h.

virtual INT CHMM::get_num_model_parameters (  )  [virtual]

get number of parameters in model

abstract base method

Returns:
number of parameters in model

Implements CDistribution.

Definition at line 492 of file HMM.h.

DREAL CHMM::get_log_model_parameter ( INT  num_param  )  [virtual]

get model parameter (logarithmic)

abstrac base method

Returns:
model parameter (logarithmic)

Implements CDistribution.

Definition at line 5724 of file HMM.cpp.

DREAL CHMM::get_log_derivative ( INT  num_param,
INT  num_example 
) [virtual]

get derivative of likelihood function (logarithmic)

abstract base method

Parameters:
num_param which param
num_example which example
Returns:
derivative of likelihood (logarithmic)

Implements CDistribution.

Definition at line 5699 of file HMM.cpp.

virtual DREAL CHMM::get_log_likelihood_example ( INT  num_example  )  [virtual]

compute log likelihood for example

abstract base method

Parameters:
num_example which example
Returns:
log likeliehood for example

Implements CDistribution.

Definition at line 495 of file HMM.h.

bool CHMM::initialize ( CModel model,
DREAL  PSEUDO,
FILE *  model_file = NULL 
)

initialization function - gets called by constructors.

Parameters:
model model which holds definitions of states to be learned + consts
PSEUDO Pseudo Value
model_file Filehandle to a hmm model file (*.mod)

Definition at line 522 of file HMM.cpp.

bool CHMM::alloc_state_dependend_arrays (  ) 

allocates memory that depends on N

Definition at line 433 of file HMM.cpp.

void CHMM::free_state_dependend_arrays (  ) 

free memory that depends on N

Definition at line 487 of file HMM.cpp.

DREAL CHMM::forward_comp ( INT  time,
INT  state,
INT  dimension 
)

forward algorithm. calculates Pr[O_0,O_1, ..., O_t, q_time=S_i| lambda] for 0<= time <= T-1 Pr[O|lambda] for time > T

Parameters:
time t
state i
dimension dimension of observation (observations are a matrix, where a row stands for one dimension i.e. 0_0,O_1,...,O_{T-1}

Definition at line 622 of file HMM.cpp.

DREAL CHMM::forward_comp_old ( INT  time,
INT  state,
INT  dimension 
)

Definition at line 726 of file HMM.cpp.

DREAL CHMM::backward_comp ( INT  time,
INT  state,
INT  dimension 
)

backward algorithm. calculates Pr[O_t+1,O_t+2, ..., O_T-1| q_time=S_i, lambda] for 0<= time <= T-1 Pr[O|lambda] for time >= T

Parameters:
time t
state i
dimension dimension of observation (observations are a matrix, where a row stands for one dimension i.e. 0_0,O_1,...,O_{T-1}

Definition at line 858 of file HMM.cpp.

DREAL CHMM::backward_comp_old ( INT  time,
INT  state,
INT  dimension 
)

Definition at line 957 of file HMM.cpp.

DREAL CHMM::best_path ( INT  dimension  ) 

calculates probability of best state sequence s_0,...,s_T-1 AND path itself using viterbi algorithm. The path can be found in the array PATH(dimension)[0..T-1] afterwards

Parameters:
dimension dimension of observation for which the most probable path is calculated (observations are a matrix, where a row stands for one dimension i.e. 0_0,O_1,...,O_{T-1}

Definition at line 1089 of file HMM.cpp.

WORD CHMM::get_best_path_state ( INT  dim,
INT  t 
)

Definition at line 544 of file HMM.h.

DREAL CHMM::model_probability_comp (  ) 

calculates probability that observations were generated by the model using forward algorithm.

Definition at line 1221 of file HMM.cpp.

DREAL CHMM::model_probability ( INT  dimension = -1  ) 

inline proxy for model probability.

Definition at line 556 of file HMM.h.

DREAL CHMM::linear_model_probability ( INT  dimension  ) 

calculates likelihood for linear model on observations in MEMORY

Parameters:
dimension dimension for which probability is calculated
Returns:
model probability

Definition at line 575 of file HMM.h.

bool CHMM::set_iterations ( INT  num  ) 

Definition at line 605 of file HMM.h.

INT CHMM::get_iterations (  ) 

Definition at line 606 of file HMM.h.

bool CHMM::set_epsilon ( DREAL  eps  ) 

Definition at line 607 of file HMM.h.

DREAL CHMM::get_epsilon (  ) 

Definition at line 608 of file HMM.h.

bool CHMM::baum_welch_viterbi_train ( BaumWelchViterbiType  type  ) 

interface for e.g. GUIHMM to run BaumWelch or Viterbi training

Parameters:
type type of BaumWelch/Viterbi training

Definition at line 5775 of file HMM.cpp.

void CHMM::estimate_model_baum_welch ( CHMM train  ) 

uses baum-welch-algorithm to train a fully connected HMM.

Parameters:
train model from which the new model is estimated

Definition at line 1484 of file HMM.cpp.

void CHMM::estimate_model_baum_welch_old ( CHMM train  ) 

Definition at line 1640 of file HMM.cpp.

void CHMM::estimate_model_baum_welch_trans ( CHMM train  ) 

Definition at line 1571 of file HMM.cpp.

void CHMM::estimate_model_baum_welch_defined ( CHMM train  ) 

uses baum-welch-algorithm to train the defined transitions etc.

Parameters:
train model from which the new model is estimated

Definition at line 1953 of file HMM.cpp.

void CHMM::estimate_model_viterbi ( CHMM train  ) 

uses viterbi training to train a fully connected HMM

Parameters:
train model from which the new model is estimated

Definition at line 2128 of file HMM.cpp.

void CHMM::estimate_model_viterbi_defined ( CHMM train  ) 

uses viterbi training to train the defined transitions etc.

Parameters:
train model from which the new model is estimated

Definition at line 2253 of file HMM.cpp.

bool CHMM::linear_train ( bool  right_align = false  ) 

estimates linear model from observations.

Definition at line 5342 of file HMM.cpp.

bool CHMM::permutation_entropy ( INT  window_width,
INT  sequence_number 
)

compute permutation entropy

Definition at line 5644 of file HMM.cpp.

void CHMM::output_model ( bool  verbose = false  ) 

prints the model parameters on screen.

Parameters:
verbose when false only the model probability will be printed when true the whole model will be printed additionally

Definition at line 2438 of file HMM.cpp.

void CHMM::output_model_defined ( bool  verbose = false  ) 

performs output_model only for the defined transitions etc

Definition at line 2522 of file HMM.cpp.

void CHMM::normalize ( bool  keep_dead_states = false  ) 

normalize the model to satisfy stochasticity

Definition at line 5019 of file HMM.cpp.

void CHMM::add_states ( INT  num_states,
DREAL  default_val = 0 
)

increases the number of states by num_states the new a/b/p/q values are given the value default_val where 0<=default_val<=1

Definition at line 5254 of file HMM.cpp.

bool CHMM::append_model ( CHMM append_model,
DREAL cur_out,
DREAL app_out 
)

appends the append_model to the current hmm, i.e. two extra states are created. one is the end state of the current hmm with outputs cur_out (of size M) and the other state is the start state of the append_model. transition probability from state 1 to states 1 is 1

Definition at line 5146 of file HMM.cpp.

bool CHMM::append_model ( CHMM append_model  ) 

appends the append_model to the current hmm, here no extra states are created. former q_i are multiplied by q_ji to give the a_ij from the current hmm to the append_model

Definition at line 5054 of file HMM.cpp.

void CHMM::chop ( DREAL  value  ) 

set any model parameter with probability smaller than value to ZERO

Definition at line 5314 of file HMM.cpp.

void CHMM::convert_to_log (  ) 

convert model to log probabilities

Definition at line 2577 of file HMM.cpp.

void CHMM::init_model_random (  ) 

init model with random values

Definition at line 2624 of file HMM.cpp.

void CHMM::init_model_defined (  ) 

init model according to const_x, learn_x. first model is initialized with 0 for all parameters then parameters in learn_x are initialized with random values finally const_x parameters are set and model is normalized.

Definition at line 2690 of file HMM.cpp.

void CHMM::clear_model (  ) 

initializes model with log(PSEUDO)

Definition at line 2844 of file HMM.cpp.

void CHMM::clear_model_defined (  ) 

initializes only parameters in learn_x with log(PSEUDO)

Definition at line 2860 of file HMM.cpp.

void CHMM::copy_model ( CHMM l  ) 

copies the the modelparameters from l

Definition at line 2883 of file HMM.cpp.

void CHMM::invalidate_model (  ) 

invalidates all caches. this function has to be called when direct changes to the model have been made. this is necessary for the forward/backward/viterbi algorithms to not work with old tables

Definition at line 2899 of file HMM.cpp.

bool CHMM::get_status (  )  const

get status

Returns:
true if everything is ok, else false

Definition at line 722 of file HMM.h.

DREAL CHMM::get_pseudo (  )  const

returns current pseudo value

Definition at line 728 of file HMM.h.

void CHMM::set_pseudo ( DREAL  pseudo  ) 

sets current pseudo value

Definition at line 734 of file HMM.h.

void CHMM::set_observations ( CStringFeatures< WORD > *  obs,
CHMM lambda = NULL 
)

observation functions set/get observation matrix set new observations sets the observation pointer and initializes observation-dependent caches if lambda is given, then the caches of the model lambda are used

Definition at line 5497 of file HMM.cpp.

void CHMM::set_observation_nocache ( CStringFeatures< WORD > *  obs  ) 

set new observations only set the observation pointer and drop caches if there were any

Definition at line 5453 of file HMM.cpp.

CStringFeatures<WORD>* CHMM::get_observations (  ) 

return observation pointer

Definition at line 782 of file HMM.h.

bool CHMM::load_definitions ( FILE *  file,
bool  verbose,
bool  initialize = true 
)

read definitions file (learn_x,const_x) used for training. -format specs: definition_file (train.def) % HMM-TRAIN - specification % learn_a - elements in state_transition_matrix to be learned % learn_b - elements in oberservation_per_state_matrix to be learned % note: each line stands for % state, observation(0), observation(1)...observation(NOW) % learn_p - elements in initial distribution to be learned % learn_q - elements in the end-state distribution to be learned % % const_x - specifies initial values of elements % rest is assumed to be 0.0 % % NOTE: IMPLICIT DEFINES: % define A 0 % define C 1 % define G 2 % define T 3

learn_a=[ [INT,INT]; [INT,INT]; [INT,INT]; ........ [INT,INT]; [-1,-1]; ];

learn_b=[ [INT,INT,INT,...,INT]; [INT,INT,INT,...,INT]; [INT,INT,INT,...,INT]; ........ [INT,INT,INT,...,INT]; [-1,-1]; ];

learn_p= [ INT, ... , INT, -1 ];

learn_q= [ INT, ... , INT, -1 ];

const_a=[ [INT,INT,DREAL]; [INT,INT,DREAL]; [INT,INT,DREAL]; ........ [INT,INT,DREAL]; [-1,-1,-1]; ];

const_b=[ [INT,INT,INT,...,INT,DREAL]; [INT,INT,INT,...,INT,DREAL]; [INT,INT,INT,...,INT,<DOUBLE]; ........ [INT,INT,INT,...,INT,DREAL]; [-1,-1,-1]; ];

const_p[]=[ [INT, DREAL], ... , [INT,DREAL], [-1,-1] ]; const_q[]=[ [INT, DREAL], ... , [INT,DREAL], [-1,-1] ];

Parameters:
file filehandle to definitions file
verbose true for verbose messages
initialize true to initialize to underlying HMM

Definition at line 3460 of file HMM.cpp.

bool CHMM::load_model ( FILE *  file  ) 

read model from file. -format specs: model_file (model.hmm) % HMM - specification % N - number of states % M - number of observation_tokens % a is state_transition_matrix % size(a)= [N,N] % % b is observation_per_state_matrix % size(b)= [N,M] % % p is initial distribution % size(p)= [1, N]

N=INT; M=INT;

p=[DREAL,DREAL...DREAL]; q=[DREAL,DREAL...DREAL];

a=[ [DREAL,DREAL...DREAL]; [DREAL,DREAL...DREAL]; [DREAL,DREAL...DREAL]; [DREAL,DREAL...DREAL]; [DREAL,DREAL...DREAL]; ];

b=[ [DREAL,DREAL...DREAL]; [DREAL,DREAL...DREAL]; [DREAL,DREAL...DREAL]; [DREAL,DREAL...DREAL]; [DREAL,DREAL...DREAL]; ];

Parameters:
file filehandle to model file

Definition at line 3162 of file HMM.cpp.

bool CHMM::save_model ( FILE *  file  ) 

save model to file.

Parameters:
file filehandle to model file

Definition at line 4165 of file HMM.cpp.

bool CHMM::save_model_derivatives ( FILE *  file  ) 

save model derivatives to file in ascii format.

Parameters:
file filehandle

Definition at line 4693 of file HMM.cpp.

bool CHMM::save_model_derivatives_bin ( FILE *  file  ) 

save model derivatives to file in binary format.

Parameters:
file filehandle

Definition at line 4573 of file HMM.cpp.

bool CHMM::save_model_bin ( FILE *  file  ) 

save model in binary format.

Parameters:
file filehandle

Definition at line 4338 of file HMM.cpp.

bool CHMM::check_model_derivatives (  ) 

numerically check whether derivates were calculated right

Definition at line 4811 of file HMM.cpp.

bool CHMM::check_model_derivatives_combined (  ) 

Definition at line 4741 of file HMM.cpp.

T_STATES * CHMM::get_path ( INT  dim,
DREAL prob 
)

get viterbi path and path probability

Parameters:
dim dimension for which to obtain best path
prob likelihood of path
Returns:
viterbi path

Definition at line 4262 of file HMM.cpp.

bool CHMM::save_path ( FILE *  file  ) 

save viterbi path in ascii format

Parameters:
file filehandle

Definition at line 4275 of file HMM.cpp.

bool CHMM::save_path_derivatives ( FILE *  file  ) 

save viterbi path in ascii format

Parameters:
file filehandle

Definition at line 4441 of file HMM.cpp.

bool CHMM::save_path_derivatives_bin ( FILE *  file  ) 

save viterbi path in binary format

Parameters:
file filehandle

Definition at line 4489 of file HMM.cpp.

bool CHMM::save_likelihood_bin ( FILE *  file  ) 

save model probability in binary format

Parameters:
file filehandle

Definition at line 4300 of file HMM.cpp.

bool CHMM::save_likelihood ( FILE *  file  ) 

save model probability in ascii format

Parameters:
file filehandle

Definition at line 4317 of file HMM.cpp.

T_STATES CHMM::get_N (  )  const

access function for number of states N

Definition at line 964 of file HMM.h.

INT CHMM::get_M (  )  const

access function for number of observations M

Definition at line 967 of file HMM.h.

void CHMM::set_q ( T_STATES  offset,
DREAL  value 
)

access function for probability of end states

Parameters:
offset index 0...N-1
value value to be set

Definition at line 973 of file HMM.h.

void CHMM::set_p ( T_STATES  offset,
DREAL  value 
)

access function for probability of first state

Parameters:
offset index 0...N-1
value value to be set

Definition at line 986 of file HMM.h.

void CHMM::set_A ( T_STATES  line_,
T_STATES  column,
DREAL  value 
)

access function for matrix A

Parameters:
line_ row in matrix 0...N-1
column column in matrix 0...N-1
value value to be set

Definition at line 1000 of file HMM.h.

void CHMM::set_a ( T_STATES  line_,
T_STATES  column,
DREAL  value 
)

access function for matrix a

Parameters:
line_ row in matrix 0...N-1
column column in matrix 0...N-1
value value to be set

Definition at line 1014 of file HMM.h.

void CHMM::set_B ( T_STATES  line_,
WORD  column,
DREAL  value 
)

access function for matrix B

Parameters:
line_ row in matrix 0...N-1
column column in matrix 0...M-1
value value to be set

Definition at line 1028 of file HMM.h.

void CHMM::set_b ( T_STATES  line_,
WORD  column,
DREAL  value 
)

access function for matrix b

Parameters:
line_ row in matrix 0...N-1
column column in matrix 0...M-1
value value to be set

Definition at line 1042 of file HMM.h.

void CHMM::set_psi ( INT  time,
T_STATES  state,
T_STATES  value,
INT  dimension 
)

access function for backtracking table psi

Parameters:
time time 0...T-1
state state 0...N-1
value value to be set
dimension dimension of observations 0...DIMENSION-1

Definition at line 1058 of file HMM.h.

DREAL CHMM::get_q ( T_STATES  offset  )  const

access function for probability of end states

Parameters:
offset index 0...N-1
Returns:
value at offset

Definition at line 1072 of file HMM.h.

DREAL CHMM::get_p ( T_STATES  offset  )  const

access function for probability of initial states

Parameters:
offset index 0...N-1
Returns:
value at offset

Definition at line 1085 of file HMM.h.

DREAL CHMM::get_A ( T_STATES  line_,
T_STATES  column 
) const

access function for matrix A

Parameters:
line_ row in matrix 0...N-1
column column in matrix 0...N-1
Returns:
value at position line colum

Definition at line 1099 of file HMM.h.

DREAL CHMM::get_a ( T_STATES  line_,
T_STATES  column 
) const

access function for matrix a

Parameters:
line_ row in matrix 0...N-1
column column in matrix 0...N-1
Returns:
value at position line colum

Definition at line 1113 of file HMM.h.

DREAL CHMM::get_B ( T_STATES  line_,
WORD  column 
) const

access function for matrix B

Parameters:
line_ row in matrix 0...N-1
column column in matrix 0...M-1
Returns:
value at position line colum

Definition at line 1127 of file HMM.h.

DREAL CHMM::get_b ( T_STATES  line_,
WORD  column 
) const

access function for matrix b

Parameters:
line_ row in matrix 0...N-1
column column in matrix 0...M-1
Returns:
value at position line colum

Definition at line 1141 of file HMM.h.

T_STATES CHMM::get_psi ( INT  time,
T_STATES  state,
INT  dimension 
) const

access function for backtracking table psi

Parameters:
time time 0...T-1
state state 0...N-1
dimension dimension of observations 0...DIMENSION-1
Returns:
state at specified time and position

Definition at line 1158 of file HMM.h.

DREAL CHMM::state_probability ( INT  time,
INT  state,
INT  dimension 
)

calculates probability of being in state i at time t for dimension

Definition at line 1355 of file HMM.h.

DREAL CHMM::transition_probability ( INT  time,
INT  state_i,
INT  state_j,
INT  dimension 
)

calculates probability of being in state i at time t and state j at time t+1 for dimension

Definition at line 1361 of file HMM.h.

DREAL CHMM::linear_model_derivative ( T_STATES  i,
WORD  j,
INT  dimension 
)

computes log dp(lambda)/d b_ij for linear model

Definition at line 1377 of file HMM.h.

DREAL CHMM::model_derivative_p ( T_STATES  i,
INT  dimension 
)

computes log dp(lambda)/d p_i. backward path downto time 0 multiplied by observing first symbol in path at state i

Definition at line 1393 of file HMM.h.

DREAL CHMM::model_derivative_q ( T_STATES  i,
INT  dimension 
)

computes log dp(lambda)/d q_i. forward path upto time T-1

Definition at line 1401 of file HMM.h.

DREAL CHMM::model_derivative_a ( T_STATES  i,
T_STATES  j,
INT  dimension 
)

computes log dp(lambda)/d a_ij.

Definition at line 1407 of file HMM.h.

DREAL CHMM::model_derivative_b ( T_STATES  i,
WORD  j,
INT  dimension 
)

computes log dp(lambda)/d b_ij.

Definition at line 1418 of file HMM.h.

DREAL CHMM::path_derivative_p ( T_STATES  i,
INT  dimension 
)

computes d log p(lambda,best_path)/d p_i

Definition at line 1441 of file HMM.h.

DREAL CHMM::path_derivative_q ( T_STATES  i,
INT  dimension 
)

computes d log p(lambda,best_path)/d q_i

Definition at line 1448 of file HMM.h.

DREAL CHMM::path_derivative_a ( T_STATES  i,
T_STATES  j,
INT  dimension 
)

computes d log p(lambda,best_path)/d a_ij

Definition at line 1455 of file HMM.h.

DREAL CHMM::path_derivative_b ( T_STATES  i,
WORD  j,
INT  dimension 
)

computes d log p(lambda,best_path)/d b_ij

Definition at line 1462 of file HMM.h.

bool CHMM::get_numbuffer ( FILE *  file,
CHAR buffer,
INT  length 
) [protected]

put a sequence of numbers into the buffer

Definition at line 3053 of file HMM.cpp.

void CHMM::open_bracket ( FILE *  file  )  [protected]

expect open bracket.

Definition at line 2992 of file HMM.cpp.

void CHMM::close_bracket ( FILE *  file  )  [protected]

expect closing bracket

Definition at line 3013 of file HMM.cpp.

bool CHMM::comma_or_space ( FILE *  file  )  [protected]

expect comma or space.

Definition at line 3026 of file HMM.cpp.

void CHMM::error ( INT  p_line,
const CHAR str 
) [protected]

parse error messages

Definition at line 1489 of file HMM.h.

void CHMM::prepare_path_derivative ( INT  dim  )  [protected]

initialization function that is called before path_derivatives are calculated

Definition at line 1499 of file HMM.h.

DREAL CHMM::forward ( INT  time,
INT  state,
INT  dimension 
) [protected]

inline proxies for forward pass

Definition at line 1528 of file HMM.h.

DREAL CHMM::backward ( INT  time,
INT  state,
INT  dimension 
) [protected]

inline proxies for backward pass

Definition at line 1548 of file HMM.h.

INT CDistribution::get_num_relevant_model_parameters (  )  [virtual, inherited]

get number of parameters in model that are relevant, i.e. > ALMOST_NEG_INFTY

Returns:
number of relevant model parameters

Definition at line 48 of file Distribution.cpp.

DREAL CDistribution::get_log_likelihood_sample (  )  [virtual, inherited]

compute log likelihood for whole sample

Returns:
log likelihood for whole sample

Definition at line 24 of file Distribution.cpp.

void CDistribution::get_log_likelihood ( DREAL **  dst,
INT num 
) [virtual, inherited]

compute log likelihood for each example

Parameters:
dst where likelihood will be stored
num where number of likelihoods will be stored

Definition at line 35 of file Distribution.cpp.

virtual DREAL CDistribution::get_model_parameter ( INT  num_param  )  [virtual, inherited]

get model parameter

Parameters:
num_param which param
Returns:
model parameter

Definition at line 94 of file Distribution.h.

virtual DREAL CDistribution::get_derivative ( INT  num_param,
INT  num_example 
) [virtual, inherited]

get derivative of likelihood function

Parameters:
num_param which param
num_example which example
Returns:
derivative of likelihood function

Definition at line 105 of file Distribution.h.

virtual DREAL CDistribution::get_likelihood_example ( INT  num_example  )  [virtual, inherited]

compute likelihood for example

Parameters:
num_example which example
Returns:
likelihood for example

Definition at line 115 of file Distribution.h.

virtual void CDistribution::set_features ( CFeatures f  )  [virtual, inherited]

set feature vectors

Parameters:
f new feature vectors

Definition at line 124 of file Distribution.h.

virtual CFeatures* CDistribution::get_features (  )  [virtual, inherited]

get feature vectors

Returns:
feature vectors

Definition at line 130 of file Distribution.h.

virtual void CDistribution::set_pseudo_count ( DREAL  pseudo  )  [virtual, inherited]

set pseudo count

Parameters:
pseudo new pseudo count

Definition at line 136 of file Distribution.h.

virtual DREAL CDistribution::get_pseudo_count (  )  [virtual, inherited]

get pseudo count

Returns:
pseudo count

Definition at line 142 of file Distribution.h.


Member Data Documentation

INT CHMM::M [protected]

number of observation symbols eg. ACGT -> 0123

Definition at line 1174 of file HMM.h.

INT CHMM::N [protected]

number of states

Definition at line 1177 of file HMM.h.

DREAL CHMM::PSEUDO [protected]

define pseudocounts against overfitting

Definition at line 1180 of file HMM.h.

INT CHMM::line [protected]

Definition at line 1183 of file HMM.h.

observation matrix

Definition at line 1186 of file HMM.h.

CModel* CHMM::model [protected]

Definition at line 1189 of file HMM.h.

matrix of absolute counts of transitions

Definition at line 1192 of file HMM.h.

matrix of absolute counts of observations within each state

Definition at line 1195 of file HMM.h.

transition matrix

Definition at line 1198 of file HMM.h.

initial distribution of states

Definition at line 1201 of file HMM.h.

distribution of end-states

Definition at line 1204 of file HMM.h.

distribution of observations within each state

Definition at line 1207 of file HMM.h.

INT CHMM::iterations [protected]

convergence criterion iterations

Definition at line 1210 of file HMM.h.

Definition at line 1211 of file HMM.h.

DREAL CHMM::epsilon [protected]

convergence criterion epsilon

Definition at line 1214 of file HMM.h.

INT CHMM::conv_it [protected]

Definition at line 1215 of file HMM.h.

probability of best path

Definition at line 1219 of file HMM.h.

DREAL CHMM::pat_prob [protected]

probability of best path

Definition at line 1222 of file HMM.h.

DREAL CHMM::mod_prob [protected]

probability of model

Definition at line 1225 of file HMM.h.

bool CHMM::mod_prob_updated [protected]

true if model probability is up to date

Definition at line 1228 of file HMM.h.

bool CHMM::all_path_prob_updated [protected]

true if path probability is up to date

Definition at line 1231 of file HMM.h.

dimension for which path_deriv was calculated

Definition at line 1234 of file HMM.h.

bool CHMM::path_deriv_updated [protected]

true if path derivative is up to date

Definition at line 1237 of file HMM.h.

bool CHMM::loglikelihood [protected]

Definition at line 1241 of file HMM.h.

bool CHMM::status [protected]

Definition at line 1244 of file HMM.h.

bool CHMM::reused_caches [protected]

Definition at line 1247 of file HMM.h.

DREAL* CHMM::arrayN1 [protected]

array of size N for temporary calculations

Definition at line 1257 of file HMM.h.

DREAL* CHMM::arrayN2 [protected]

array of size N for temporary calculations

Definition at line 1259 of file HMM.h.

cache for forward variables can be terrible HUGE O(T*N)

Definition at line 1295 of file HMM.h.

cache for backward variables can be terrible HUGE O(T*N)

Definition at line 1297 of file HMM.h.

backtracking table for viterbi can be terrible HUGE O(T*N)

Definition at line 1301 of file HMM.h.

T_STATES* CHMM::path [protected]

best path (=state sequence) through model

Definition at line 1304 of file HMM.h.

bool CHMM::path_prob_updated [protected]

true if path probability is up to date

Definition at line 1307 of file HMM.h.

dimension for which path_prob was calculated

Definition at line 1310 of file HMM.h.

const INT CHMM::GOTN = (1<<1) [static, protected]

GOTN

Definition at line 1317 of file HMM.h.

const INT CHMM::GOTM = (1<<2) [static, protected]

GOTM

Definition at line 1319 of file HMM.h.

const INT CHMM::GOTO = (1<<3) [static, protected]

GOTO

Definition at line 1321 of file HMM.h.

const INT CHMM::GOTa = (1<<4) [static, protected]

GOTa

Definition at line 1323 of file HMM.h.

const INT CHMM::GOTb = (1<<5) [static, protected]

GOTb

Definition at line 1325 of file HMM.h.

const INT CHMM::GOTp = (1<<6) [static, protected]

GOTp

Definition at line 1327 of file HMM.h.

const INT CHMM::GOTq = (1<<7) [static, protected]

GOTq

Definition at line 1329 of file HMM.h.

const INT CHMM::GOTlearn_a = (1<<1) [static, protected]

GOTlearn_a

Definition at line 1332 of file HMM.h.

const INT CHMM::GOTlearn_b = (1<<2) [static, protected]

GOTlearn_b

Definition at line 1334 of file HMM.h.

const INT CHMM::GOTlearn_p = (1<<3) [static, protected]

GOTlearn_p

Definition at line 1336 of file HMM.h.

const INT CHMM::GOTlearn_q = (1<<4) [static, protected]

GOTlearn_q

Definition at line 1338 of file HMM.h.

const INT CHMM::GOTconst_a = (1<<5) [static, protected]

GOTconst_a

Definition at line 1340 of file HMM.h.

const INT CHMM::GOTconst_b = (1<<6) [static, protected]

GOTconst_b

Definition at line 1342 of file HMM.h.

const INT CHMM::GOTconst_p = (1<<7) [static, protected]

GOTconst_p

Definition at line 1344 of file HMM.h.

const INT CHMM::GOTconst_q = (1<<8) [static, protected]

GOTconst_q

Definition at line 1346 of file HMM.h.

CFeatures* CDistribution::features [protected, inherited]

feature vectors

Definition at line 146 of file Distribution.h.

DREAL CDistribution::pseudo_count [protected, inherited]

pseudo count

Definition at line 148 of file Distribution.h.

CParallel CSGObject::parallel [static, inherited]

Definition at line 105 of file SGObject.h.

CIO CSGObject::io [static, inherited]

Definition at line 106 of file SGObject.h.

CVersion CSGObject::version [static, inherited]

Definition at line 107 of file SGObject.h.


The documentation for this class was generated from the following files:

SHOGUN Machine Learning Toolbox - Documentation