SHOGUN
v1.1.0
|
00001 /* 00002 * This program is free software; you can redistribute it and/or modify 00003 * it under the terms of the GNU General Public License as published by 00004 * the Free Software Foundation; either version 3 of the License, or 00005 * (at your option) any later version. 00006 * 00007 * Written (W) 1999-2008 Soeren Sonnenburg 00008 * Written (W) 1999-2008 Gunnar Raetsch 00009 * Copyright (C) 1999-2008 Fraunhofer Institute FIRST and Max-Planck-Society 00010 */ 00011 00012 #ifndef __GUIHMM__H 00013 #define __GUIHMM__H 00014 00015 #include <shogun/lib/config.h> 00016 #include <shogun/base/SGObject.h> 00017 #include <shogun/distributions/HMM.h> 00018 #include <shogun/features/Labels.h> 00019 00020 namespace shogun 00021 { 00022 class CSGInterface; 00023 00025 class CGUIHMM : public CSGObject 00026 { 00027 public: 00029 CGUIHMM() { }; 00033 CGUIHMM(CSGInterface* interface); 00035 ~CGUIHMM(); 00036 00038 bool new_hmm(int32_t n, int32_t m); 00040 bool load(char* filename); 00042 bool save(char* filename, bool is_binary=false); 00043 00047 bool set_num_hmm_tables(char* param) ; 00049 bool baum_welch_train(); 00051 bool baum_welch_trans_train(); 00053 bool baum_welch_train_defined(); 00055 bool viterbi_train_defined(); 00057 bool viterbi_train(); 00061 bool linear_train(char align='l'); 00065 bool linear_train_from_file(char* param); 00067 bool append_model(char* filename, int32_t base1=-1, int32_t base2=-1); 00069 bool add_states(int32_t num_states=1, float64_t value=0); 00071 bool set_hmm_as(char* target); 00073 bool set_pseudo(float64_t pseudo); 00075 bool convergence_criteria( 00076 int32_t num_iterations=100, float64_t epsilon=0.001); 00078 bool output_hmm(); 00080 bool output_hmm_defined(); 00082 bool best_path(int32_t from=0, int32_t to=100); 00086 bool normalize(bool keep_dead_states=false); 00091 bool save_path(char* filename, bool is_binary=false); 00093 bool save_likelihood(char* filename, bool is_binary=false); 00098 bool load_definitions(char* filename, bool do_init=false); 00102 bool set_max_dim(char* param); 00104 bool likelihood(); 00106 bool chop(float64_t value); 00111 bool relative_entropy(float64_t*& values, int32_t& len); 00116 bool entropy(float64_t*& values, int32_t& len); 00118 bool permutation_entropy(int32_t width=0, int32_t seq_num=-1); 00120 inline CHMM* get_pos() { return pos; } 00122 inline CHMM* get_neg() { return neg; } 00124 inline CHMM* get_test() { return test; } 00128 inline void set_current(CHMM* h) { working=h; } 00130 inline CHMM* get_current() { return working; } 00132 inline float64_t get_pseudo() { return PSEUDO; } 00133 00137 CLabels* classify(CLabels* output=NULL); 00141 float64_t classify_example(int32_t idx); 00145 CLabels* one_class_classify(CLabels* output=NULL); 00149 CLabels* linear_one_class_classify(CLabels* output=NULL); 00153 float64_t one_class_classify_example(int32_t idx); 00154 00156 inline virtual const char* get_name() const { return "GUIHMM"; } 00157 00158 protected: 00163 bool converge(float64_t x, float64_t y); 00168 void switch_model(CHMM** m1, CHMM** m2); 00169 00171 CHMM* working; 00172 00174 CHMM* pos; 00176 CHMM* neg; 00178 CHMM* test; 00179 00181 float64_t PSEUDO; 00183 int32_t M; 00184 00185 protected: 00187 CSGInterface* ui; 00188 }; 00189 } 00190 #endif