SHOGUN
4.1.0
|
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.
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_t > | get_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_t > | get_likelihood_for_all_examples () | ||||
virtual void | set_features (CFeatures *f) | ||||
virtual CFeatures * | get_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 CSGObject * | shallow_copy () const | ||||
virtual CSGObject * | deep_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) | ||||
SGIO * | get_global_io () | ||||
void | set_global_parallel (Parallel *parallel) | ||||
Parallel * | get_global_parallel () | ||||
void | set_global_version (Version *version) | ||||
Version * | get_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) | ||||
virtual void | update_parameter_hash () | ||||
virtual bool | parameter_hash_changed () | ||||
virtual bool | equals (CSGObject *other, float64_t accuracy=0.0, bool tolerant=false) | ||||
virtual CSGObject * | clone () | ||||
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_STATES * | get_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
| |||||
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
| |||||
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 CDistribution * | obtain_from_generic (CSGObject *object) |
Public Attributes | |
SGIO * | io |
Parallel * | parallel |
Version * | version |
Parameter * | m_parameters |
Parameter * | m_model_selection_parameters |
Parameter * | m_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) |
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_t * | arrayN1 |
float64_t * | arrayN2 |
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_STATES * | states_per_observation_psi |
backtracking table for viterbi can be terrible HUGE O(T*N) More... | |
T_STATES * | path |
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... | |
CFeatures * | features |
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... | |
Model * | model |
float64_t * | transition_matrix_A |
matrix of absolute counts of transitions More... | |
float64_t * | observation_matrix_B |
matrix of absolute counts of observations within each state More... | |
float64_t * | transition_matrix_a |
transition matrix More... | |
float64_t * | initial_state_distribution_p |
initial distribution of states More... | |
float64_t * | end_state_distribution_q |
distribution of end-states More... | |
float64_t * | observation_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) |
CHMM | ( | ) |
CHMM | ( | CStringFeatures< uint16_t > * | obs, |
int32_t | N, | ||
int32_t | M, | ||
float64_t | PSEUDO | ||
) |
void add_states | ( | int32_t | num_states, |
float64_t | default_val = 0 |
||
) |
bool alloc_state_dependend_arrays | ( | ) |
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
bool append_model | ( | CHMM * | append_model | ) |
|
protected |
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
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} |
float64_t backward_comp_old | ( | int32_t | time, |
int32_t | state, | ||
int32_t | dimension | ||
) |
bool baum_welch_viterbi_train | ( | BaumWelchViterbiType | type | ) |
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
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} |
|
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.
dict | dictionary of parameters to be built. |
Definition at line 597 of file SGObject.cpp.
bool check_model_derivatives | ( | ) |
void chop | ( | float64_t | value | ) |
void clear_model_defined | ( | ) |
|
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.
Definition at line 714 of file SGObject.cpp.
|
protected |
|
protected |
void copy_model | ( | CHMM * | l | ) |
|
virtualinherited |
A deep copy. All the instance variables will also be copied.
Definition at line 198 of file SGObject.cpp.
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.
other | object to compare with |
accuracy | accuracy to use for comparison (optional) |
tolerant | allows linient check on float equality (within accuracy) |
Definition at line 618 of file SGObject.cpp.
|
protected |
void estimate_model_baum_welch | ( | CHMM * | train | ) |
void estimate_model_baum_welch_defined | ( | CHMM * | train | ) |
void estimate_model_viterbi | ( | CHMM * | train | ) |
void estimate_model_viterbi_defined | ( | CHMM * | train | ) |
|
protected |
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
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} |
float64_t forward_comp_old | ( | int32_t | time, |
int32_t | state, | ||
int32_t | dimension | ||
) |
void free_state_dependend_arrays | ( | ) |
|
virtualinherited |
get partial derivative of likelihood function
num_param | partial derivative against which param |
num_example | which example |
Definition at line 134 of file Distribution.h.
|
virtualinherited |
|
inherited |
|
inherited |
|
inherited |
|
virtualinherited |
compute likelihood for example
num_example | which example |
Reimplemented in CGMM, and CLinearHMM.
Definition at line 145 of file Distribution.h.
compute likelihood for all vectors in sample
Definition at line 65 of file Distribution.cpp.
|
virtual |
get partial derivative of likelihood function (logarithmic)
abstract base method
num_param | derivative against which param |
num_example | which example |
Implements CDistribution.
compute log likelihood for each example
Definition at line 39 of file Distribution.cpp.
|
virtual |
compute log likelihood for example
abstract base method
num_example | which example |
Implements CDistribution.
|
virtualinherited |
compute log likelihood for whole sample
Definition at line 28 of file Distribution.cpp.
|
virtual |
get model parameter (logarithmic)
abstract base method
Implements CDistribution.
int32_t get_M | ( | ) | const |
|
virtualinherited |
get model parameter
num_param | which param |
Definition at line 123 of file Distribution.h.
|
inherited |
Definition at line 498 of file SGObject.cpp.
|
inherited |
Returns description of a given parameter string, if it exists. SG_ERROR otherwise
param_name | name of the parameter |
Definition at line 522 of file SGObject.cpp.
|
inherited |
Returns index of model selection parameter with provided index
param_name | name of model selection parameter |
Definition at line 535 of file SGObject.cpp.
T_STATES get_N | ( | ) | const |
|
virtual |
|
virtual |
get number of parameters in model
abstract base method
Implements CDistribution.
|
virtualinherited |
get number of parameters in model that are relevant, i.e. > ALMOST_NEG_INFTY
Definition at line 52 of file Distribution.cpp.
|
protected |
CStringFeatures<uint16_t>* get_observations | ( | ) |
|
virtualinherited |
bool get_status | ( | ) | const |
void init_model_defined | ( | ) |
void invalidate_model | ( | ) |
|
virtualinherited |
If the SGSerializable is a class template then TRUE will be returned and GENERIC is set to the type of the generic.
generic | set to the type of the generic if returning TRUE |
Definition at line 296 of file SGObject.cpp.
float64_t linear_model_probability | ( | int32_t | dimension | ) |
bool linear_train | ( | bool | right_align = false | ) |
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] ];
file | filehandle to definitions file |
verbose | true for verbose messages |
initialize | true to initialize to underlying HMM |
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]; ];
file | filehandle to model file |
|
virtualinherited |
Load this object from file. If it will fail (returning FALSE) then this object will contain inconsistent data and should not be used!
file | where to load from |
prefix | prefix for members |
Definition at line 369 of file SGObject.cpp.
|
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.
ShogunException | will be thrown if an error occurs. |
Reimplemented in CKernel, CWeightedDegreePositionStringKernel, CList, CAlphabet, CLinearHMM, CGaussianKernel, CInverseMultiQuadricKernel, CCircularKernel, and CExponentialKernel.
Definition at line 426 of file SGObject.cpp.
|
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.
ShogunException | will 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 421 of file SGObject.cpp.
float64_t model_probability | ( | int32_t | dimension = -1 | ) |
float64_t model_probability_comp | ( | ) |
void normalize | ( | bool | keep_dead_states = false | ) |
|
staticinherited |
obtain from generic
object | generic object |
Definition at line 85 of file Distribution.cpp.
|
protected |
void output_model | ( | bool | verbose = false | ) |
void output_model_defined | ( | bool | verbose = false | ) |
|
virtualinherited |
Definition at line 262 of file SGObject.cpp.
bool permutation_entropy | ( | int32_t | window_width, |
int32_t | sequence_number | ||
) |
|
protected |
|
inherited |
prints all parameter registered for model selection and their type
Definition at line 474 of file SGObject.cpp.
|
virtualinherited |
prints registered parameters out
prefix | prefix for members |
Definition at line 308 of file SGObject.cpp.
bool save_likelihood | ( | FILE * | file | ) |
bool save_likelihood_bin | ( | FILE * | file | ) |
bool save_model | ( | FILE * | file | ) |
bool save_model_bin | ( | FILE * | file | ) |
bool save_model_derivatives | ( | FILE * | file | ) |
bool save_model_derivatives_bin | ( | FILE * | file | ) |
bool save_path | ( | FILE * | file | ) |
bool save_path_derivatives | ( | FILE * | file | ) |
bool save_path_derivatives_bin | ( | FILE * | file | ) |
|
virtualinherited |
Save this object to file.
file | where to save the object; will be closed during returning if PREFIX is an empty string. |
prefix | prefix for members |
Definition at line 314 of file SGObject.cpp.
|
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.
ShogunException | will be thrown if an error occurs. |
Reimplemented in CKernel.
Definition at line 436 of file SGObject.cpp.
|
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.
ShogunException | will 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 431 of file SGObject.cpp.
|
virtualinherited |
|
inherited |
Definition at line 41 of file SGObject.cpp.
|
inherited |
Definition at line 46 of file SGObject.cpp.
|
inherited |
Definition at line 51 of file SGObject.cpp.
|
inherited |
Definition at line 56 of file SGObject.cpp.
|
inherited |
Definition at line 61 of file SGObject.cpp.
|
inherited |
Definition at line 66 of file SGObject.cpp.
|
inherited |
Definition at line 71 of file SGObject.cpp.
|
inherited |
Definition at line 76 of file SGObject.cpp.
|
inherited |
Definition at line 81 of file SGObject.cpp.
|
inherited |
Definition at line 86 of file SGObject.cpp.
|
inherited |
Definition at line 91 of file SGObject.cpp.
|
inherited |
Definition at line 96 of file SGObject.cpp.
|
inherited |
Definition at line 101 of file SGObject.cpp.
|
inherited |
Definition at line 106 of file SGObject.cpp.
|
inherited |
Definition at line 111 of file SGObject.cpp.
|
inherited |
set generic type to T
|
inherited |
|
inherited |
set the parallel object
parallel | parallel object to use |
Definition at line 241 of file SGObject.cpp.
|
inherited |
set the version object
version | version object to use |
Definition at line 283 of file SGObject.cpp.
void set_observation_nocache | ( | CStringFeatures< uint16_t > * | obs | ) |
void set_observations | ( | CStringFeatures< uint16_t > * | obs, |
CHMM * | hmm = NULL |
||
) |
|
virtualinherited |
|
virtualinherited |
A shallow copy. All the SGObject instance variables will be simply assigned and SG_REF-ed.
Reimplemented in CGaussianKernel.
Definition at line 192 of file SGObject.cpp.
float64_t state_probability | ( | int32_t | time, |
int32_t | state, | ||
int32_t | dimension | ||
) |
|
virtual |
learn distribution
data | training data (parameter can be avoided if distance or kernel-based classifiers are used and distance/kernels are initialized with train data) |
Implements CDistribution.
float64_t transition_probability | ( | int32_t | time, |
int32_t | state_i, | ||
int32_t | state_j, | ||
int32_t | dimension | ||
) |
|
inherited |
unset generic type
this has to be called in classes specializing a template class
Definition at line 303 of file SGObject.cpp.
|
virtualinherited |
Updates the hash of current parameter combination
Definition at line 248 of file SGObject.cpp.
update parameters in the em maximization step for mixture model of which this distribution is a part
abstract base method
alpha_k | "belongingness" values of various data points |
len | length of alpha_k array |
Reimplemented in CGaussian.
Definition at line 78 of file Distribution.cpp.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protectedinherited |
feature vectors
Definition at line 209 of file Distribution.h.
|
protected |
|
inherited |
io
Definition at line 369 of file SGObject.h.
|
protected |
|
protected |
|
inherited |
parameters wrt which we can compute gradients
Definition at line 384 of file SGObject.h.
|
inherited |
Hash of parameter values
Definition at line 387 of file SGObject.h.
|
inherited |
model selection parameters
Definition at line 381 of file SGObject.h.
|
inherited |
parameters
Definition at line 378 of file SGObject.h.
|
protected |
|
protected |
|
protected |
|
protected |
|
inherited |
parallel
Definition at line 372 of file SGObject.h.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protectedinherited |
pseudo count
Definition at line 211 of file Distribution.h.
|
protected |
|
protected |
|
inherited |
version
Definition at line 375 of file SGObject.h.