SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
List of all members | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes
CHMM Class Reference

Detailed Description

Hidden Markov Model.

Structure and Function collection. This Class implements a Hidden Markov Model. For a tutorial on HMMs see Rabiner et.al A Tutorial on Hidden Markov Models and Selected Applications in Speech Recognition, 1989

Several functions for tasks such as training,reading/writing models, reading observations, calculation of derivatives are supplied.

Definition at line 369 of file HMM.h.

Inheritance diagram for CHMM:
[legend]

Public Member Functions

 CHMM ()
 
bool alloc_state_dependend_arrays ()
 allocates memory that depends on N More...
 
void free_state_dependend_arrays ()
 free memory that depends on N More...
 
bool linear_train (bool right_align=false)
 estimates linear model from observations. More...
 
bool permutation_entropy (int32_t window_width, int32_t sequence_number)
 compute permutation entropy More...
 
virtual const char * get_name () const
 
virtual int32_t get_num_relevant_model_parameters ()
 
virtual float64_t get_log_likelihood_sample ()
 
virtual SGVector< float64_tget_log_likelihood ()
 
virtual float64_t get_model_parameter (int32_t num_param)
 
virtual float64_t get_derivative (int32_t num_param, int32_t num_example)
 
virtual float64_t get_likelihood_example (int32_t num_example)
 
virtual SGVector< float64_tget_likelihood_for_all_examples ()
 
virtual void set_features (CFeatures *f)
 
virtual CFeaturesget_features ()
 
virtual void set_pseudo_count (float64_t pseudo)
 
virtual float64_t get_pseudo_count ()
 
virtual float64_t update_params_em (float64_t *alpha_k, int32_t len)
 
virtual CSGObjectshallow_copy () const
 
virtual CSGObjectdeep_copy () const
 
virtual bool is_generic (EPrimitiveType *generic) const
 
template<class T >
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
template<>
void set_generic ()
 
void unset_generic ()
 
virtual void print_serializable (const char *prefix="")
 
virtual bool save_serializable (CSerializableFile *file, const char *prefix="")
 
virtual bool load_serializable (CSerializableFile *file, const char *prefix="")
 
void set_global_io (SGIO *io)
 
SGIOget_global_io ()
 
void set_global_parallel (Parallel *parallel)
 
Parallelget_global_parallel ()
 
void set_global_version (Version *version)
 
Versionget_global_version ()
 
SGStringList< char > get_modelsel_names ()
 
void print_modsel_params ()
 
char * get_modsel_param_descr (const char *param_name)
 
index_t get_modsel_param_index (const char *param_name)
 
void build_gradient_parameter_dictionary (CMap< TParameter *, CSGObject * > *dict)
 
bool has (const std::string &name) const
 
template<typename T >
bool has (const Tag< T > &tag) const
 
template<typename T , typename U = void>
bool has (const std::string &name) const
 
template<typename T >
void set (const Tag< T > &_tag, const T &value)
 
template<typename T , typename U = void>
void set (const std::string &name, const T &value)
 
template<typename T >
get (const Tag< T > &_tag) const
 
template<typename T , typename U = void>
get (const std::string &name) const
 
virtual void update_parameter_hash ()
 
virtual bool parameter_hash_changed ()
 
virtual bool equals (CSGObject *other, float64_t accuracy=0.0, bool tolerant=false)
 
virtual CSGObjectclone ()
 
Constructor/Destructor and helper function
 CHMM (int32_t N, int32_t M, Model *model, float64_t PSEUDO)
 
 CHMM (CStringFeatures< uint16_t > *obs, int32_t N, int32_t M, float64_t PSEUDO)
 
 CHMM (int32_t N, float64_t *p, float64_t *q, float64_t *a)
 
 CHMM (int32_t N, float64_t *p, float64_t *q, int32_t num_trans, float64_t *a_trans)
 
 CHMM (FILE *model_file, float64_t PSEUDO)
 
 CHMM (CHMM *h)
 Constructor - Clone model h. More...
 
virtual ~CHMM ()
 Destructor - Cleanup. More...
 
virtual bool train (CFeatures *data=NULL)
 
virtual int32_t get_num_model_parameters ()
 
virtual float64_t get_log_model_parameter (int32_t num_param)
 
virtual float64_t get_log_derivative (int32_t num_param, int32_t num_example)
 
virtual float64_t get_log_likelihood_example (int32_t num_example)
 
bool initialize_hmm (Model *model, float64_t PSEUDO, FILE *model_file=NULL)
 
probability functions.

forward/backward/viterbi algorithm

float64_t forward_comp (int32_t time, int32_t state, int32_t dimension)
 
float64_t forward_comp_old (int32_t time, int32_t state, int32_t dimension)
 
float64_t backward_comp (int32_t time, int32_t state, int32_t dimension)
 
float64_t backward_comp_old (int32_t time, int32_t state, int32_t dimension)
 
float64_t best_path (int32_t dimension)
 
uint16_t get_best_path_state (int32_t dim, int32_t t)
 
float64_t model_probability_comp ()
 
float64_t model_probability (int32_t dimension=-1)
 inline proxy for model probability. More...
 
float64_t linear_model_probability (int32_t dimension)
 
convergence criteria
bool set_iterations (int32_t num)
 
int32_t get_iterations ()
 
bool set_epsilon (float64_t eps)
 
float64_t get_epsilon ()
 
bool baum_welch_viterbi_train (BaumWelchViterbiType type)
 
model training
void estimate_model_baum_welch (CHMM *train)
 
void estimate_model_baum_welch_trans (CHMM *train)
 
void estimate_model_baum_welch_old (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 More...
 
model helper functions.
void normalize (bool keep_dead_states=false)
 normalize the model to satisfy stochasticity More...
 
void add_states (int32_t num_states, float64_t default_val=0)
 
bool append_model (CHMM *append_model, float64_t *cur_out, float64_t *app_out)
 
bool append_model (CHMM *append_model)
 
void chop (float64_t value)
 set any model parameter with probability smaller than value to ZERO More...
 
void convert_to_log ()
 convert model to log probabilities More...
 
void init_model_random ()
 init model with random values More...
 
void init_model_defined ()
 
void clear_model ()
 initializes model with log(PSEUDO) More...
 
void clear_model_defined ()
 initializes only parameters in learn_x with log(PSEUDO) More...
 
void copy_model (CHMM *l)
 copies the the modelparameters from l More...
 
void invalidate_model ()
 
bool get_status () const
 
float64_t get_pseudo () const
 returns current pseudo value More...
 
void set_pseudo (float64_t pseudo)
 sets current pseudo value More...
 
void set_observations (CStringFeatures< uint16_t > *obs, CHMM *hmm=NULL)
 
void set_observation_nocache (CStringFeatures< uint16_t > *obs)
 
CStringFeatures< uint16_t > * get_observations ()
 return observation pointer More...
 
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 More...
 
bool check_model_derivatives_combined ()
 
T_STATESget_path (int32_t dim, float64_t &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 More...
 
int32_t get_M () const
 access function for number of observations M More...
 
void set_q (T_STATES offset, float64_t value)
 
void set_p (T_STATES offset, float64_t value)
 
void set_A (T_STATES line_, T_STATES column, float64_t value)
 
void set_a (T_STATES line_, T_STATES column, float64_t value)
 
void set_B (T_STATES line_, uint16_t column, float64_t value)
 
void set_b (T_STATES line_, uint16_t column, float64_t value)
 
void set_psi (int32_t time, T_STATES state, T_STATES value, int32_t dimension)
 
float64_t get_q (T_STATES offset) const
 
float64_t get_p (T_STATES offset) const
 
float64_t get_A (T_STATES line_, T_STATES column) const
 
float64_t get_a (T_STATES line_, T_STATES column) const
 
float64_t get_B (T_STATES line_, uint16_t column) const
 
float64_t get_b (T_STATES line_, uint16_t column) const
 
T_STATES get_psi (int32_t time, T_STATES state, int32_t dimension) const
 
functions for observations

management and access functions for observation matrix

float64_t state_probability (int32_t time, int32_t state, int32_t dimension)
 calculates probability of being in state i at time t for dimension More...
 
float64_t transition_probability (int32_t time, int32_t state_i, int32_t state_j, int32_t dimension)
 calculates probability of being in state i at time t and state j at time t+1 for dimension More...
 
derivatives of model probabilities.

computes log dp(lambda)/d lambda_i

Parameters
dimensiondimension for that derivatives are calculated
i,jparameter specific
float64_t linear_model_derivative (T_STATES i, uint16_t j, int32_t dimension)
 
float64_t model_derivative_p (T_STATES i, int32_t dimension)
 
float64_t model_derivative_q (T_STATES i, int32_t dimension)
 
float64_t model_derivative_a (T_STATES i, T_STATES j, int32_t dimension)
 computes log dp(lambda)/d a_ij. More...
 
float64_t model_derivative_b (T_STATES i, uint16_t j, int32_t dimension)
 computes log dp(lambda)/d b_ij. More...
 
derivatives of path probabilities.

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

Parameters
dimensiondimension for that derivatives are calculated
i,jparameter specific
float64_t path_derivative_p (T_STATES i, int32_t dimension)
 computes d log p(lambda,best_path)/d p_i More...
 
float64_t path_derivative_q (T_STATES i, int32_t dimension)
 computes d log p(lambda,best_path)/d q_i More...
 
float64_t path_derivative_a (T_STATES i, T_STATES j, int32_t dimension)
 computes d log p(lambda,best_path)/d a_ij More...
 
float64_t path_derivative_b (T_STATES i, uint16_t j, int32_t dimension)
 computes d log p(lambda,best_path)/d b_ij More...
 

Static Public Member Functions

static CDistributionobtain_from_generic (CSGObject *object)
 

Public Attributes

SGIOio
 
Parallelparallel
 
Versionversion
 
Parameterm_parameters
 
Parameterm_model_selection_parameters
 
Parameterm_gradient_parameters
 
uint32_t m_hash
 

Protected Member Functions

void prepare_path_derivative (int32_t dim)
 initialization function that is called before path_derivatives are calculated More...
 
float64_t forward (int32_t time, int32_t state, int32_t dimension)
 inline proxies for forward pass More...
 
float64_t backward (int32_t time, int32_t state, int32_t dimension)
 inline proxies for backward pass More...
 
virtual void load_serializable_pre () throw (ShogunException)
 
virtual void load_serializable_post () throw (ShogunException)
 
virtual void save_serializable_pre () throw (ShogunException)
 
virtual void save_serializable_post () throw (ShogunException)
 
template<typename T >
void register_param (Tag< T > &_tag, const T &value)
 
template<typename T >
void register_param (const std::string &name, const T &value)
 
input helper functions.

for reading model/definition/observation files

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

Protected Attributes

float64_tarrayN1
 
float64_tarrayN2
 
T_ALPHA_BETA alpha_cache
 cache for forward variables can be terrible HUGE O(T*N) More...
 
T_ALPHA_BETA beta_cache
 cache for backward variables can be terrible HUGE O(T*N) More...
 
T_STATESstates_per_observation_psi
 backtracking table for viterbi can be terrible HUGE O(T*N) More...
 
T_STATESpath
 best path (=state sequence) through model More...
 
bool path_prob_updated
 true if path probability is up to date More...
 
int32_t path_prob_dimension
 dimension for which path_prob was calculated More...
 
CFeaturesfeatures
 
float64_t pseudo_count
 
model specific variables.

these are p,q,a,b,N,M etc

int32_t M
 number of observation symbols eg. ACGT -> 0123 More...
 
int32_t N
 number of states More...
 
float64_t PSEUDO
 define pseudocounts against overfitting More...
 
int32_t line
 
CStringFeatures< uint16_t > * p_observations
 observation matrix More...
 
Modelmodel
 
float64_ttransition_matrix_A
 matrix of absolute counts of transitions More...
 
float64_tobservation_matrix_B
 matrix of absolute counts of observations within each state More...
 
float64_ttransition_matrix_a
 transition matrix More...
 
float64_tinitial_state_distribution_p
 initial distribution of states More...
 
float64_tend_state_distribution_q
 distribution of end-states More...
 
float64_tobservation_matrix_b
 distribution of observations within each state More...
 
int32_t iterations
 convergence criterion iterations More...
 
int32_t iteration_count
 
float64_t epsilon
 convergence criterion epsilon More...
 
int32_t conv_it
 
float64_t all_pat_prob
 probability of best path More...
 
float64_t pat_prob
 probability of best path More...
 
float64_t mod_prob
 probability of model More...
 
bool mod_prob_updated
 true if model probability is up to date More...
 
bool all_path_prob_updated
 true if path probability is up to date More...
 
int32_t path_deriv_dimension
 dimension for which path_deriv was calculated More...
 
bool path_deriv_updated
 true if path derivative is up to date More...
 
bool loglikelihood
 
bool status
 
bool reused_caches
 

Static Protected Attributes

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

Constructor & Destructor Documentation

CHMM ( )

Train definitions. Encapsulates Modelparameters that are constant/shall be learned. Consists of structures and access functions for learning only defined transitions and constants.default constructor

Definition at line 143 of file HMM.cpp.

CHMM ( int32_t  N,
int32_t  M,
Model model,
float64_t  PSEUDO 
)

Constructor

Parameters
Nnumber of states
Mnumber of emissions
modelmodel which holds definitions of states to be learned + consts
PSEUDOPseudo Value

Definition at line 198 of file HMM.cpp.

CHMM ( CStringFeatures< uint16_t > *  obs,
int32_t  N,
int32_t  M,
float64_t  PSEUDO 
)

Definition at line 212 of file HMM.cpp.

CHMM ( int32_t  N,
float64_t p,
float64_t q,
float64_t a 
)

Definition at line 229 of file HMM.cpp.

CHMM ( int32_t  N,
float64_t p,
float64_t q,
int32_t  num_trans,
float64_t a_trans 
)

Definition at line 279 of file HMM.cpp.

CHMM ( FILE *  model_file,
float64_t  PSEUDO 
)

Constructor - Initialization from model file.

Parameters
model_fileFilehandle to a hmm model file (*.mod)
PSEUDOPseudo Value

Definition at line 389 of file HMM.cpp.

CHMM ( CHMM h)

Constructor - Clone model h.

Definition at line 184 of file HMM.cpp.

~CHMM ( )
virtual

Destructor - Cleanup.

Definition at line 399 of file HMM.cpp.

Member Function Documentation

void add_states ( int32_t  num_states,
float64_t  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 5063 of file HMM.cpp.

bool alloc_state_dependend_arrays ( )

allocates memory that depends on N

Definition at line 503 of file HMM.cpp.

bool append_model ( CHMM append_model,
float64_t cur_out,
float64_t 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 4955 of file HMM.cpp.

bool 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 4863 of file HMM.cpp.

float64_t backward ( int32_t  time,
int32_t  state,
int32_t  dimension 
)
protected

inline proxies for backward pass

Definition at line 1560 of file HMM.h.

float64_t backward_comp ( int32_t  time,
int32_t  state,
int32_t  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
timet
statei
dimensiondimension 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 923 of file HMM.cpp.

float64_t backward_comp_old ( int32_t  time,
int32_t  state,
int32_t  dimension 
)

Definition at line 1022 of file HMM.cpp.

bool baum_welch_viterbi_train ( BaumWelchViterbiType  type)

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

Parameters
typetype of BaumWelch/Viterbi training

Definition at line 5580 of file HMM.cpp.

float64_t best_path ( int32_t  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
dimensiondimension 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 1154 of file HMM.cpp.

void build_gradient_parameter_dictionary ( CMap< TParameter *, CSGObject * > *  dict)
inherited

Builds a dictionary of all parameters in SGObject as well of those of SGObjects that are parameters of this object. Dictionary maps parameters to the objects that own them.

Parameters
dictdictionary of parameters to be built.

Definition at line 630 of file SGObject.cpp.

bool check_model_derivatives ( )

numerically check whether derivates were calculated right

Definition at line 4620 of file HMM.cpp.

bool check_model_derivatives_combined ( )

Definition at line 4550 of file HMM.cpp.

void chop ( float64_t  value)

set any model parameter with probability smaller than value to ZERO

Definition at line 5123 of file HMM.cpp.

void clear_model ( )

initializes model with log(PSEUDO)

Definition at line 2662 of file HMM.cpp.

void clear_model_defined ( )

initializes only parameters in learn_x with log(PSEUDO)

Definition at line 2678 of file HMM.cpp.

CSGObject * clone ( )
virtualinherited

Creates a clone of the current object. This is done via recursively traversing all parameters, which corresponds to a deep copy. Calling equals on the cloned object always returns true although none of the memory of both objects overlaps.

Returns
an identical copy of the given object, which is disjoint in memory. NULL if the clone fails. Note that the returned object is SG_REF'ed

Definition at line 747 of file SGObject.cpp.

void close_bracket ( FILE *  file)
protected

expect closing bracket

Definition at line 2825 of file HMM.cpp.

bool comma_or_space ( FILE *  file)
protected

expect comma or space.

Definition at line 2838 of file HMM.cpp.

void convert_to_log ( )

convert model to log probabilities

Definition at line 2395 of file HMM.cpp.

void copy_model ( CHMM l)

copies the the modelparameters from l

Definition at line 2701 of file HMM.cpp.

CSGObject * deep_copy ( ) const
virtualinherited

A deep copy. All the instance variables will also be copied.

Definition at line 231 of file SGObject.cpp.

bool equals ( CSGObject other,
float64_t  accuracy = 0.0,
bool  tolerant = false 
)
virtualinherited

Recursively compares the current SGObject to another one. Compares all registered numerical parameters, recursion upon complex (SGObject) parameters. Does not compare pointers!

May be overwritten but please do with care! Should not be necessary in most cases.

Parameters
otherobject to compare with
accuracyaccuracy to use for comparison (optional)
tolerantallows linient check on float equality (within accuracy)
Returns
true if all parameters were equal, false if not

Definition at line 651 of file SGObject.cpp.

void error ( int32_t  p_line,
const char *  str 
)
protected

parse error messages

Definition at line 1505 of file HMM.h.

void estimate_model_baum_welch ( CHMM train)

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

Parameters
trainmodel from which the new model is estimated

Definition at line 1530 of file HMM.cpp.

void estimate_model_baum_welch_defined ( CHMM train)

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

Parameters
trainmodel from which the new model is estimated

Definition at line 1771 of file HMM.cpp.

void estimate_model_baum_welch_old ( CHMM train)

Definition at line 1616 of file HMM.cpp.

void estimate_model_baum_welch_trans ( CHMM train)

Definition at line 1701 of file HMM.cpp.

void estimate_model_viterbi ( CHMM train)

uses viterbi training to train a fully connected HMM

Parameters
trainmodel from which the new model is estimated

Definition at line 1947 of file HMM.cpp.

void estimate_model_viterbi_defined ( CHMM train)

uses viterbi training to train the defined transitions etc.

Parameters
trainmodel from which the new model is estimated

Definition at line 2074 of file HMM.cpp.

float64_t forward ( int32_t  time,
int32_t  state,
int32_t  dimension 
)
protected

inline proxies for forward pass

Definition at line 1543 of file HMM.h.

float64_t forward_comp ( int32_t  time,
int32_t  state,
int32_t  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
timet
statei
dimensiondimension 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 687 of file HMM.cpp.

float64_t forward_comp_old ( int32_t  time,
int32_t  state,
int32_t  dimension 
)

Definition at line 791 of file HMM.cpp.

void free_state_dependend_arrays ( )

free memory that depends on N

Definition at line 560 of file HMM.cpp.

T get ( const Tag< T > &  _tag) const
inherited

Getter for a class parameter, identified by a Tag. Throws an exception if the class does not have such a parameter.

Parameters
_tagname and type information of parameter
Returns
value of the parameter identified by the input tag

Definition at line 367 of file SGObject.h.

T get ( const std::string &  name) const
inherited

Getter for a class parameter, identified by a name. Throws an exception if the class does not have such a parameter.

Parameters
namename of the parameter
Returns
value of the parameter corresponding to the input name and type

Definition at line 388 of file SGObject.h.

float64_t get_A ( T_STATES  line_,
T_STATES  column 
) const

access function for matrix A

Parameters
line_row in matrix 0...N-1
columncolumn in matrix 0...N-1
Returns
value at position line colum

Definition at line 1115 of file HMM.h.

float64_t get_a ( T_STATES  line_,
T_STATES  column 
) const

access function for matrix a

Parameters
line_row in matrix 0...N-1
columncolumn in matrix 0...N-1
Returns
value at position line colum

Definition at line 1129 of file HMM.h.

float64_t get_B ( T_STATES  line_,
uint16_t  column 
) const

access function for matrix B

Parameters
line_row in matrix 0...N-1
columncolumn in matrix 0...M-1
Returns
value at position line colum

Definition at line 1143 of file HMM.h.

float64_t get_b ( T_STATES  line_,
uint16_t  column 
) const

access function for matrix b

Parameters
line_row in matrix 0...N-1
columncolumn in matrix 0...M-1
Returns
value at position line colum

Definition at line 1157 of file HMM.h.

uint16_t get_best_path_state ( int32_t  dim,
int32_t  t 
)

Definition at line 563 of file HMM.h.

virtual float64_t get_derivative ( int32_t  num_param,
int32_t  num_example 
)
virtualinherited

get partial derivative of likelihood function

Parameters
num_parampartial derivative against which param
num_examplewhich example
Returns
derivative of likelihood function

Definition at line 134 of file Distribution.h.

float64_t get_epsilon ( )

Definition at line 628 of file HMM.h.

virtual CFeatures* get_features ( )
virtualinherited

get feature vectors

Returns
feature vectors

Definition at line 171 of file Distribution.h.

SGIO * get_global_io ( )
inherited

get the io object

Returns
io object

Definition at line 268 of file SGObject.cpp.

Parallel * get_global_parallel ( )
inherited

get the parallel object

Returns
parallel object

Definition at line 310 of file SGObject.cpp.

Version * get_global_version ( )
inherited

get the version object

Returns
version object

Definition at line 323 of file SGObject.cpp.

int32_t get_iterations ( )

Definition at line 626 of file HMM.h.

virtual float64_t get_likelihood_example ( int32_t  num_example)
virtualinherited

compute likelihood for example

Parameters
num_examplewhich example
Returns
likelihood for example

Reimplemented in CGMM, and CLinearHMM.

Definition at line 145 of file Distribution.h.

SGVector< float64_t > get_likelihood_for_all_examples ( )
virtualinherited

compute likelihood for all vectors in sample

Returns
likelihood vector for all examples

Definition at line 65 of file Distribution.cpp.

float64_t get_log_derivative ( int32_t  num_param,
int32_t  num_example 
)
virtual

get partial derivative of likelihood function (logarithmic)

abstract base method

Parameters
num_paramderivative against which param
num_examplewhich example
Returns
derivative of likelihood (logarithmic)

Implements CDistribution.

Definition at line 5513 of file HMM.cpp.

SGVector< float64_t > get_log_likelihood ( )
virtualinherited

compute log likelihood for each example

Returns
log likelihood vector

Definition at line 39 of file Distribution.cpp.

virtual float64_t get_log_likelihood_example ( int32_t  num_example)
virtual

compute log likelihood for example

abstract base method

Parameters
num_examplewhich example
Returns
log likelihood for example

Implements CDistribution.

Definition at line 513 of file HMM.h.

float64_t get_log_likelihood_sample ( )
virtualinherited

compute log likelihood for whole sample

Returns
log likelihood for whole sample

Definition at line 28 of file Distribution.cpp.

float64_t get_log_model_parameter ( int32_t  num_param)
virtual

get model parameter (logarithmic)

abstract base method

Returns
model parameter (logarithmic)

Implements CDistribution.

Definition at line 5538 of file HMM.cpp.

int32_t get_M ( ) const

access function for number of observations M

Definition at line 984 of file HMM.h.

virtual float64_t get_model_parameter ( int32_t  num_param)
virtualinherited

get model parameter

Parameters
num_paramwhich param
Returns
model parameter

Definition at line 123 of file Distribution.h.

SGStringList< char > get_modelsel_names ( )
inherited
Returns
vector of names of all parameters which are registered for model selection

Definition at line 531 of file SGObject.cpp.

char * get_modsel_param_descr ( const char *  param_name)
inherited

Returns description of a given parameter string, if it exists. SG_ERROR otherwise

Parameters
param_namename of the parameter
Returns
description of the parameter

Definition at line 555 of file SGObject.cpp.

index_t get_modsel_param_index ( const char *  param_name)
inherited

Returns index of model selection parameter with provided index

Parameters
param_namename of model selection parameter
Returns
index of model selection parameter with provided name, -1 if there is no such

Definition at line 568 of file SGObject.cpp.

T_STATES get_N ( ) const

access function for number of states N

Definition at line 981 of file HMM.h.

virtual const char* get_name ( ) const
virtual
Returns
object name

Implements CSGObject.

Definition at line 1186 of file HMM.h.

virtual int32_t 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 510 of file HMM.h.

int32_t get_num_relevant_model_parameters ( )
virtualinherited

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

Returns
number of relevant model parameters

Definition at line 52 of file Distribution.cpp.

bool get_numbuffer ( FILE *  file,
char *  buffer,
int32_t  length 
)
protected

put a sequence of numbers into the buffer

Definition at line 2865 of file HMM.cpp.

CStringFeatures<uint16_t>* get_observations ( )

return observation pointer

Definition at line 799 of file HMM.h.

float64_t get_p ( T_STATES  offset) const

access function for probability of initial states

Parameters
offsetindex 0...N-1
Returns
value at offset

Definition at line 1101 of file HMM.h.

T_STATES * get_path ( int32_t  dim,
float64_t prob 
)

get viterbi path and path probability

Parameters
dimdimension for which to obtain best path
problikelihood of path
Returns
viterbi path

Definition at line 4074 of file HMM.cpp.

float64_t get_pseudo ( ) const

returns current pseudo value

Definition at line 752 of file HMM.h.

virtual float64_t get_pseudo_count ( )
virtualinherited

get pseudo count

Returns
pseudo count

Definition at line 187 of file Distribution.h.

T_STATES get_psi ( int32_t  time,
T_STATES  state,
int32_t  dimension 
) const

access function for backtracking table psi

Parameters
timetime 0...T-1
statestate 0...N-1
dimensiondimension of observations 0...DIMENSION-1
Returns
state at specified time and position

Definition at line 1173 of file HMM.h.

float64_t get_q ( T_STATES  offset) const

access function for probability of end states

Parameters
offsetindex 0...N-1
Returns
value at offset

Definition at line 1088 of file HMM.h.

bool get_status ( ) const

get status

Returns
true if everything is ok, else false

Definition at line 746 of file HMM.h.

bool has ( const std::string &  name) const
inherited

Checks if object has a class parameter identified by a name.

Parameters
namename of the parameter
Returns
true if the parameter exists with the input name

Definition at line 289 of file SGObject.h.

bool has ( const Tag< T > &  tag) const
inherited

Checks if object has a class parameter identified by a Tag.

Parameters
tagtag of the parameter containing name and type information
Returns
true if the parameter exists with the input tag

Definition at line 301 of file SGObject.h.

bool has ( const std::string &  name) const
inherited

Checks if a type exists for a class parameter identified by a name.

Parameters
namename of the parameter
Returns
true if the parameter exists with the input name and type

Definition at line 312 of file SGObject.h.

void 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 2508 of file HMM.cpp.

void init_model_random ( )

init model with random values

Definition at line 2442 of file HMM.cpp.

bool initialize_hmm ( Model model,
float64_t  PSEUDO,
FILE *  model_file = NULL 
)

initialization function - gets called by constructors.

Parameters
modelmodel which holds definitions of states to be learned + consts
PSEUDOPseudo Value
model_fileFilehandle to a hmm model file (*.mod)

Definition at line 598 of file HMM.cpp.

void 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 2717 of file HMM.cpp.

bool is_generic ( EPrimitiveType *  generic) const
virtualinherited

If the SGSerializable is a class template then TRUE will be returned and GENERIC is set to the type of the generic.

Parameters
genericset to the type of the generic if returning TRUE
Returns
TRUE if a class template.

Definition at line 329 of file SGObject.cpp.

float64_t linear_model_derivative ( T_STATES  i,
uint16_t  j,
int32_t  dimension 
)

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

Definition at line 1393 of file HMM.h.

float64_t linear_model_probability ( int32_t  dimension)

calculates likelihood for linear model on observations in MEMORY

Parameters
dimensiondimension for which probability is calculated
Returns
model probability

Definition at line 593 of file HMM.h.

bool linear_train ( bool  right_align = false)

estimates linear model from observations.

Definition at line 5151 of file HMM.cpp.

bool 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=[ [int32_t,int32_t]; [int32_t,int32_t]; [int32_t,int32_t]; ........ [int32_t,int32_t]; [-1,-1]; ];

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

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

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

const_a=[ [int32_t,int32_t,float64_t]; [int32_t,int32_t,float64_t]; [int32_t,int32_t,float64_t]; ........ [int32_t,int32_t,float64_t]; [-1,-1,-1]; ];

const_b=[ [int32_t,int32_t,int32_t,...,int32_t,float64_t]; [int32_t,int32_t,int32_t,...,int32_t,float64_t]; [int32_t,int32_t,int32_t,...,int32_t,<DOUBLE]; ........ [int32_t,int32_t,int32_t,...,int32_t,float64_t]; [-1,-1,-1]; ];

const_p[]=[ [int32_t, float64_t], ... , [int32_t,float64_t], [-1,-1] ]; const_q[]=[ [int32_t, float64_t], ... , [int32_t,float64_t], [-1,-1] ];

Parameters
filefilehandle to definitions file
verbosetrue for verbose messages
initializetrue to initialize to underlying HMM

Definition at line 3273 of file HMM.cpp.

bool 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=int32_t; M=int32_t;

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

a=[ [float64_t,float64_t...float64_t]; [float64_t,float64_t...float64_t]; [float64_t,float64_t...float64_t]; [float64_t,float64_t...float64_t]; [float64_t,float64_t...float64_t]; ];

b=[ [float64_t,float64_t...float64_t]; [float64_t,float64_t...float64_t]; [float64_t,float64_t...float64_t]; [float64_t,float64_t...float64_t]; [float64_t,float64_t...float64_t]; ];

Parameters
filefilehandle to model file

Definition at line 2974 of file HMM.cpp.

bool load_serializable ( CSerializableFile file,
const char *  prefix = "" 
)
virtualinherited

Load this object from file. If it will fail (returning FALSE) then this object will contain inconsistent data and should not be used!

Parameters
filewhere to load from
prefixprefix for members
Returns
TRUE if done, otherwise FALSE

Definition at line 402 of file SGObject.cpp.

void load_serializable_post ( )
throw (ShogunException
)
protectedvirtualinherited

Can (optionally) be overridden to post-initialize some member variables which are not PARAMETER::ADD'ed. Make sure that at first the overridden method BASE_CLASS::LOAD_SERIALIZABLE_POST is called.

Exceptions
ShogunExceptionwill be thrown if an error occurs.

Reimplemented in CKernel, CWeightedDegreePositionStringKernel, CList, CAlphabet, CLinearHMM, CGaussianKernel, CInverseMultiQuadricKernel, CCircularKernel, and CExponentialKernel.

Definition at line 459 of file SGObject.cpp.

void load_serializable_pre ( )
throw (ShogunException
)
protectedvirtualinherited

Can (optionally) be overridden to pre-initialize some member variables which are not PARAMETER::ADD'ed. Make sure that at first the overridden method BASE_CLASS::LOAD_SERIALIZABLE_PRE is called.

Exceptions
ShogunExceptionwill be thrown if an error occurs.

Reimplemented in CDynamicArray< T >, CDynamicArray< float64_t >, CDynamicArray< float32_t >, CDynamicArray< int32_t >, CDynamicArray< char >, CDynamicArray< bool >, and CDynamicObjectArray.

Definition at line 454 of file SGObject.cpp.

float64_t model_derivative_a ( T_STATES  i,
T_STATES  j,
int32_t  dimension 
)

computes log dp(lambda)/d a_ij.

Definition at line 1424 of file HMM.h.

float64_t model_derivative_b ( T_STATES  i,
uint16_t  j,
int32_t  dimension 
)

computes log dp(lambda)/d b_ij.

Definition at line 1435 of file HMM.h.

float64_t model_derivative_p ( T_STATES  i,
int32_t  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 1410 of file HMM.h.

float64_t model_derivative_q ( T_STATES  i,
int32_t  dimension 
)

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

Definition at line 1418 of file HMM.h.

float64_t model_probability ( int32_t  dimension = -1)

inline proxy for model probability.

Definition at line 574 of file HMM.h.

float64_t model_probability_comp ( )

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

Definition at line 1282 of file HMM.cpp.

void normalize ( bool  keep_dead_states = false)

normalize the model to satisfy stochasticity

Definition at line 4828 of file HMM.cpp.

CDistribution * obtain_from_generic ( CSGObject object)
staticinherited

obtain from generic

Parameters
objectgeneric object
Returns
Distribution object

Definition at line 85 of file Distribution.cpp.

void open_bracket ( FILE *  file)
protected

expect open bracket.

Definition at line 2804 of file HMM.cpp.

void output_model ( bool  verbose = false)

prints the model parameters on screen.

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

Definition at line 2256 of file HMM.cpp.

void output_model_defined ( bool  verbose = false)

performs output_model only for the defined transitions etc

Definition at line 2340 of file HMM.cpp.

bool parameter_hash_changed ( )
virtualinherited
Returns
whether parameter combination has changed since last update

Definition at line 295 of file SGObject.cpp.

float64_t path_derivative_a ( T_STATES  i,
T_STATES  j,
int32_t  dimension 
)

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

Definition at line 1471 of file HMM.h.

float64_t path_derivative_b ( T_STATES  i,
uint16_t  j,
int32_t  dimension 
)

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

Definition at line 1478 of file HMM.h.

float64_t path_derivative_p ( T_STATES  i,
int32_t  dimension 
)

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

Definition at line 1457 of file HMM.h.

float64_t path_derivative_q ( T_STATES  i,
int32_t  dimension 
)

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

Definition at line 1464 of file HMM.h.

bool permutation_entropy ( int32_t  window_width,
int32_t  sequence_number 
)

compute permutation entropy

Definition at line 5455 of file HMM.cpp.

void prepare_path_derivative ( int32_t  dim)
protected

initialization function that is called before path_derivatives are calculated

Definition at line 1515 of file HMM.h.

void print_modsel_params ( )
inherited

prints all parameter registered for model selection and their type

Definition at line 507 of file SGObject.cpp.

void print_serializable ( const char *  prefix = "")
virtualinherited

prints registered parameters out

Parameters
prefixprefix for members

Definition at line 341 of file SGObject.cpp.

void register_param ( Tag< T > &  _tag,
const T &  value 
)
protectedinherited

Registers a class parameter which is identified by a tag. This enables the parameter to be modified by set() and retrieved by get(). Parameters can be registered in the constructor of the class.

Parameters
_tagname and type information of parameter
valuevalue of the parameter

Definition at line 439 of file SGObject.h.

void register_param ( const std::string &  name,
const T &  value 
)
protectedinherited

Registers a class parameter which is identified by a name. This enables the parameter to be modified by set() and retrieved by get(). Parameters can be registered in the constructor of the class.

Parameters
namename of the parameter
valuevalue of the parameter along with type information

Definition at line 452 of file SGObject.h.

bool save_likelihood ( FILE *  file)

save model probability in ascii format

Parameters
filefilehandle

Definition at line 4128 of file HMM.cpp.

bool save_likelihood_bin ( FILE *  file)

save model probability in binary format

Parameters
filefilehandle

Definition at line 4111 of file HMM.cpp.

bool save_model ( FILE *  file)

save model to file.

Parameters
filefilehandle to model file

Definition at line 3978 of file HMM.cpp.

bool save_model_bin ( FILE *  file)

save model in binary format.

Parameters
filefilehandle

Definition at line 4149 of file HMM.cpp.

bool save_model_derivatives ( FILE *  file)

save model derivatives to file in ascii format.

Parameters
filefilehandle

Definition at line 4502 of file HMM.cpp.

bool save_model_derivatives_bin ( FILE *  file)

save model derivatives to file in binary format.

Parameters
filefilehandle

Definition at line 4381 of file HMM.cpp.

bool save_path ( FILE *  file)

save viterbi path in ascii format

Parameters
filefilehandle

Definition at line 4087 of file HMM.cpp.

bool save_path_derivatives ( FILE *  file)

save viterbi path in ascii format

Parameters
filefilehandle

Definition at line 4251 of file HMM.cpp.

bool save_path_derivatives_bin ( FILE *  file)

save viterbi path in binary format

Parameters
filefilehandle

Definition at line 4298 of file HMM.cpp.

bool save_serializable ( CSerializableFile file,
const char *  prefix = "" 
)
virtualinherited

Save this object to file.

Parameters
filewhere to save the object; will be closed during returning if PREFIX is an empty string.
prefixprefix for members
Returns
TRUE if done, otherwise FALSE

Definition at line 347 of file SGObject.cpp.

void save_serializable_post ( )
throw (ShogunException
)
protectedvirtualinherited

Can (optionally) be overridden to post-initialize some member variables which are not PARAMETER::ADD'ed. Make sure that at first the overridden method BASE_CLASS::SAVE_SERIALIZABLE_POST is called.

Exceptions
ShogunExceptionwill be thrown if an error occurs.

Reimplemented in CKernel.

Definition at line 469 of file SGObject.cpp.

void save_serializable_pre ( )
throw (ShogunException
)
protectedvirtualinherited

Can (optionally) be overridden to pre-initialize some member variables which are not PARAMETER::ADD'ed. Make sure that at first the overridden method BASE_CLASS::SAVE_SERIALIZABLE_PRE is called.

Exceptions
ShogunExceptionwill be thrown if an error occurs.

Reimplemented in CKernel, CDynamicArray< T >, CDynamicArray< float64_t >, CDynamicArray< float32_t >, CDynamicArray< int32_t >, CDynamicArray< char >, CDynamicArray< bool >, and CDynamicObjectArray.

Definition at line 464 of file SGObject.cpp.

void set ( const Tag< T > &  _tag,
const T &  value 
)
inherited

Setter for a class parameter, identified by a Tag. Throws an exception if the class does not have such a parameter.

Parameters
_tagname and type information of parameter
valuevalue of the parameter

Definition at line 328 of file SGObject.h.

void set ( const std::string &  name,
const T &  value 
)
inherited

Setter for a class parameter, identified by a name. Throws an exception if the class does not have such a parameter.

Parameters
namename of the parameter
valuevalue of the parameter along with type information

Definition at line 354 of file SGObject.h.

void set_A ( T_STATES  line_,
T_STATES  column,
float64_t  value 
)

access function for matrix A

Parameters
line_row in matrix 0...N-1
columncolumn in matrix 0...N-1
valuevalue to be set

Definition at line 1017 of file HMM.h.

void set_a ( T_STATES  line_,
T_STATES  column,
float64_t  value 
)

access function for matrix a

Parameters
line_row in matrix 0...N-1
columncolumn in matrix 0...N-1
valuevalue to be set

Definition at line 1031 of file HMM.h.

void set_B ( T_STATES  line_,
uint16_t  column,
float64_t  value 
)

access function for matrix B

Parameters
line_row in matrix 0...N-1
columncolumn in matrix 0...M-1
valuevalue to be set

Definition at line 1045 of file HMM.h.

void set_b ( T_STATES  line_,
uint16_t  column,
float64_t  value 
)

access function for matrix b

Parameters
line_row in matrix 0...N-1
columncolumn in matrix 0...M-1
valuevalue to be set

Definition at line 1059 of file HMM.h.

bool set_epsilon ( float64_t  eps)

Definition at line 627 of file HMM.h.

virtual void set_features ( CFeatures f)
virtualinherited

set feature vectors

Parameters
fnew feature vectors

Definition at line 160 of file Distribution.h.

void set_generic ( )
inherited

Definition at line 74 of file SGObject.cpp.

void set_generic ( )
inherited

Definition at line 79 of file SGObject.cpp.

void set_generic ( )
inherited

Definition at line 84 of file SGObject.cpp.

void set_generic ( )
inherited

Definition at line 89 of file SGObject.cpp.

void set_generic ( )
inherited

Definition at line 94 of file SGObject.cpp.

void set_generic ( )
inherited

Definition at line 99 of file SGObject.cpp.

void set_generic ( )
inherited

Definition at line 104 of file SGObject.cpp.

void set_generic ( )
inherited

Definition at line 109 of file SGObject.cpp.

void set_generic ( )
inherited

Definition at line 114 of file SGObject.cpp.

void set_generic ( )
inherited

Definition at line 119 of file SGObject.cpp.

void set_generic ( )
inherited

Definition at line 124 of file SGObject.cpp.

void set_generic ( )
inherited

Definition at line 129 of file SGObject.cpp.

void set_generic ( )
inherited

Definition at line 134 of file SGObject.cpp.

void set_generic ( )
inherited

Definition at line 139 of file SGObject.cpp.

void set_generic ( )
inherited

Definition at line 144 of file SGObject.cpp.

void set_generic ( )
inherited

set generic type to T

void set_global_io ( SGIO io)
inherited

set the io object

Parameters
ioio object to use

Definition at line 261 of file SGObject.cpp.

void set_global_parallel ( Parallel parallel)
inherited

set the parallel object

Parameters
parallelparallel object to use

Definition at line 274 of file SGObject.cpp.

void set_global_version ( Version version)
inherited

set the version object

Parameters
versionversion object to use

Definition at line 316 of file SGObject.cpp.

bool set_iterations ( int32_t  num)

Definition at line 625 of file HMM.h.

void set_observation_nocache ( CStringFeatures< uint16_t > *  obs)

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

Definition at line 5268 of file HMM.cpp.

void set_observations ( CStringFeatures< uint16_t > *  obs,
CHMM hmm = NULL 
)

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

Definition at line 5310 of file HMM.cpp.

void set_p ( T_STATES  offset,
float64_t  value 
)

access function for probability of first state

Parameters
offsetindex 0...N-1
valuevalue to be set

Definition at line 1003 of file HMM.h.

void set_pseudo ( float64_t  pseudo)

sets current pseudo value

Definition at line 758 of file HMM.h.

virtual void set_pseudo_count ( float64_t  pseudo)
virtualinherited

set pseudo count

Parameters
pseudonew pseudo count

Definition at line 181 of file Distribution.h.

void set_psi ( int32_t  time,
T_STATES  state,
T_STATES  value,
int32_t  dimension 
)

access function for backtracking table psi

Parameters
timetime 0...T-1
statestate 0...N-1
valuevalue to be set
dimensiondimension of observations 0...DIMENSION-1

Definition at line 1074 of file HMM.h.

void set_q ( T_STATES  offset,
float64_t  value 
)

access function for probability of end states

Parameters
offsetindex 0...N-1
valuevalue to be set

Definition at line 990 of file HMM.h.

CSGObject * shallow_copy ( ) const
virtualinherited

A shallow copy. All the SGObject instance variables will be simply assigned and SG_REF-ed.

Reimplemented in CGaussianKernel.

Definition at line 225 of file SGObject.cpp.

float64_t state_probability ( int32_t  time,
int32_t  state,
int32_t  dimension 
)

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

Definition at line 1369 of file HMM.h.

bool train ( CFeatures data = NULL)
virtual

learn distribution

Parameters
datatraining data (parameter can be avoided if distance or kernel-based classifiers are used and distance/kernels are initialized with train data)
Returns
whether training was successful

Implements CDistribution.

Definition at line 489 of file HMM.cpp.

float64_t transition_probability ( int32_t  time,
int32_t  state_i,
int32_t  state_j,
int32_t  dimension 
)

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

Definition at line 1376 of file HMM.h.

void unset_generic ( )
inherited

unset generic type

this has to be called in classes specializing a template class

Definition at line 336 of file SGObject.cpp.

void update_parameter_hash ( )
virtualinherited

Updates the hash of current parameter combination

Definition at line 281 of file SGObject.cpp.

float64_t update_params_em ( float64_t alpha_k,
int32_t  len 
)
virtualinherited

update parameters in the em maximization step for mixture model of which this distribution is a part

abstract base method

Parameters
alpha_k"belongingness" values of various data points
lenlength of alpha_k array
Returns
sum of alpha_k values

Reimplemented in CGaussian.

Definition at line 78 of file Distribution.cpp.

Member Data Documentation

float64_t all_pat_prob
protected

probability of best path

Definition at line 1238 of file HMM.h.

bool all_path_prob_updated
protected

true if path probability is up to date

Definition at line 1250 of file HMM.h.

T_ALPHA_BETA alpha_cache
protected

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

Definition at line 1311 of file HMM.h.

float64_t* arrayN1
protected

array of size N for temporary calculations

Definition at line 1275 of file HMM.h.

float64_t* arrayN2
protected

array of size N for temporary calculations

Definition at line 1277 of file HMM.h.

T_ALPHA_BETA beta_cache
protected

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

Definition at line 1313 of file HMM.h.

int32_t conv_it
protected

Definition at line 1235 of file HMM.h.

float64_t* end_state_distribution_q
protected

distribution of end-states

Definition at line 1224 of file HMM.h.

float64_t epsilon
protected

convergence criterion epsilon

Definition at line 1234 of file HMM.h.

CFeatures* features
protectedinherited

feature vectors

Definition at line 209 of file Distribution.h.

const int32_t GOTa = (1<<4)
staticprotected

GOTa

Definition at line 1337 of file HMM.h.

const int32_t GOTb = (1<<5)
staticprotected

GOTb

Definition at line 1339 of file HMM.h.

const int32_t GOTconst_a = (1<<5)
staticprotected

GOTconst_a

Definition at line 1354 of file HMM.h.

const int32_t GOTconst_b = (1<<6)
staticprotected

GOTconst_b

Definition at line 1356 of file HMM.h.

const int32_t GOTconst_p = (1<<7)
staticprotected

GOTconst_p

Definition at line 1358 of file HMM.h.

const int32_t GOTconst_q = (1<<8)
staticprotected

GOTconst_q

Definition at line 1360 of file HMM.h.

const int32_t GOTlearn_a = (1<<1)
staticprotected

GOTlearn_a

Definition at line 1346 of file HMM.h.

const int32_t GOTlearn_b = (1<<2)
staticprotected

GOTlearn_b

Definition at line 1348 of file HMM.h.

const int32_t GOTlearn_p = (1<<3)
staticprotected

GOTlearn_p

Definition at line 1350 of file HMM.h.

const int32_t GOTlearn_q = (1<<4)
staticprotected

GOTlearn_q

Definition at line 1352 of file HMM.h.

const int32_t GOTM = (1<<2)
staticprotected

GOTM

Definition at line 1333 of file HMM.h.

const int32_t GOTN = (1<<1)
staticprotected

GOTN

Definition at line 1331 of file HMM.h.

const int32_t GOTO = (1<<3)
staticprotected

GOTO

Definition at line 1335 of file HMM.h.

const int32_t GOTp = (1<<6)
staticprotected

GOTp

Definition at line 1341 of file HMM.h.

const int32_t GOTq = (1<<7)
staticprotected

GOTq

Definition at line 1343 of file HMM.h.

float64_t* initial_state_distribution_p
protected

initial distribution of states

Definition at line 1221 of file HMM.h.

SGIO* io
inherited

io

Definition at line 537 of file SGObject.h.

int32_t iteration_count
protected

Definition at line 1231 of file HMM.h.

int32_t iterations
protected

convergence criterion iterations

Definition at line 1230 of file HMM.h.

int32_t line
protected

Definition at line 1203 of file HMM.h.

bool loglikelihood
protected

Definition at line 1259 of file HMM.h.

int32_t M
protected

number of observation symbols eg. ACGT -> 0123

Definition at line 1194 of file HMM.h.

Parameter* m_gradient_parameters
inherited

parameters wrt which we can compute gradients

Definition at line 552 of file SGObject.h.

uint32_t m_hash
inherited

Hash of parameter values

Definition at line 555 of file SGObject.h.

Parameter* m_model_selection_parameters
inherited

model selection parameters

Definition at line 549 of file SGObject.h.

Parameter* m_parameters
inherited

parameters

Definition at line 546 of file SGObject.h.

float64_t mod_prob
protected

probability of model

Definition at line 1244 of file HMM.h.

bool mod_prob_updated
protected

true if model probability is up to date

Definition at line 1247 of file HMM.h.

Model* model
protected

Definition at line 1209 of file HMM.h.

int32_t N
protected

number of states

Definition at line 1197 of file HMM.h.

float64_t* observation_matrix_B
protected

matrix of absolute counts of observations within each state

Definition at line 1215 of file HMM.h.

float64_t* observation_matrix_b
protected

distribution of observations within each state

Definition at line 1227 of file HMM.h.

CStringFeatures<uint16_t>* p_observations
protected

observation matrix

Definition at line 1206 of file HMM.h.

Parallel* parallel
inherited

parallel

Definition at line 540 of file SGObject.h.

float64_t pat_prob
protected

probability of best path

Definition at line 1241 of file HMM.h.

T_STATES* path
protected

best path (=state sequence) through model

Definition at line 1319 of file HMM.h.

int32_t path_deriv_dimension
protected

dimension for which path_deriv was calculated

Definition at line 1253 of file HMM.h.

bool path_deriv_updated
protected

true if path derivative is up to date

Definition at line 1256 of file HMM.h.

int32_t path_prob_dimension
protected

dimension for which path_prob was calculated

Definition at line 1325 of file HMM.h.

bool path_prob_updated
protected

true if path probability is up to date

Definition at line 1322 of file HMM.h.

float64_t PSEUDO
protected

define pseudocounts against overfitting

Definition at line 1200 of file HMM.h.

float64_t pseudo_count
protectedinherited

pseudo count

Definition at line 211 of file Distribution.h.

bool reused_caches
protected

Definition at line 1265 of file HMM.h.

T_STATES* states_per_observation_psi
protected

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

Definition at line 1316 of file HMM.h.

bool status
protected

Definition at line 1262 of file HMM.h.

float64_t* transition_matrix_A
protected

matrix of absolute counts of transitions

Definition at line 1212 of file HMM.h.

float64_t* transition_matrix_a
protected

transition matrix

Definition at line 1218 of file HMM.h.

Version* version
inherited

version

Definition at line 543 of file SGObject.h.


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

SHOGUN Machine Learning Toolbox - Documentation