22 using namespace shogun;
55 CFeatures* trainfeatures=
ui->ui_features->get_train_features();
57 SG_ERROR(
"Assign train features first.\n");
60 SG_ERROR(
"Features must be STRING of type WORD.\n");
76 CFeatures* trainfeatures=
ui->ui_features->get_train_features();
78 SG_ERROR(
"Assign train features first.\n");
81 SG_ERROR(
"Features must be STRING of type WORD.\n");
94 SG_ERROR(
"Assign observation first.\n");
104 SG_ERROR(
"Assign observation first.\n");
114 SG_ERROR(
"Assign observation first.\n");
124 CFeatures* trainfeatures=
ui->ui_features->get_train_features();
126 SG_ERROR(
"Assign train features first.\n");
129 SG_ERROR(
"Features must be STRING of type WORD.\n");
132 ui_features->get_train_features());
134 bool right_align=
false;
137 SG_INFO(
"Using alignment to right.\n");
141 SG_INFO(
"Using alignment to left.\n");
150 ui_features->get_test_features();
163 for (int32_t i=0; i<num_vec; i++)
174 ui_features->get_test_features();
194 ui_features->get_test_features();
204 for (int32_t i=0; i<num_vec; i++)
216 ui_features->get_test_features();
226 for (int32_t i=0; i<num_vec; i++)
239 ui_features->get_test_features();
259 FILE* model_file=fopen(filename,
"r");
261 SG_ERROR(
"Opening file %s failed.\n", filename);
268 SG_ERROR(
"Reading file %s failed.\n", filename);
272 SG_INFO(
"File %s successfully read.\n", filename);
275 if (base1!=-1 && base2!=-1)
280 for (int32_t i=0; i<h->
get_M(); i++)
340 if (strncmp(target,
"POS", 3)==0)
346 else if (strncmp(target,
"NEG", 3)==0)
352 else if (strncmp(target,
"TEST", 4)==0)
359 SG_ERROR(
"Target POS|NEG|TEST is missing.\n");
368 FILE* model_file=fopen(filename,
"r");
370 SG_ERROR(
"Opening file %s failed.\n", filename);
378 SG_INFO(
"Loaded HMM successfully from file %s.\n", filename);
394 FILE* file=fopen(filename,
"w");
403 if (!file || !result)
404 SG_ERROR(
"Writing to file %s failed!\n", filename);
406 SG_INFO(
"Successfully written model into %s!\n", filename);
420 FILE* def_file=fopen(filename,
"r");
422 SG_ERROR(
"Opening file %s failed\n", filename);
426 SG_INFO(
"Definitions successfully read from %s.\n", filename);
430 SG_ERROR(
"Couldn't load definitions form file %s.\n", filename);
443 FILE* file=fopen(filename,
"w");
454 if (!file || !result)
455 SG_ERROR(
"Writing to file %s failed!\n", filename);
457 SG_INFO(
"Successfully written likelihoods into %s!\n", filename);
471 FILE* file=fopen(filename,
"w");
479 ui_features->get_test_features();
486 if (!file || !result)
487 SG_ERROR(
"Writing to file %s failed!\n", filename);
489 SG_INFO(
"Successfully written path into %s!\n", filename);
565 SG_ERROR(
"Set pos and neg HMM first!\n");
571 if (pos_M!=neg_M || pos_N!=neg_N)
572 SG_ERROR(
"Pos and neg HMM's differ in number of emissions or states.\n");
580 for (int32_t i=0; i<pos_N; i++)
582 for (int32_t j=0; j<pos_M; j++)
609 for (int32_t i=0; i<n; i++)
611 for (int32_t j=0; j<m; j++)
628 SG_ERROR(
"Set observations first.\n");
float64_t one_class_classify_example(int32_t idx)
void chop(float64_t value)
set any model parameter with probability smaller than value to ZERO
CLabels * linear_one_class_classify(CLabels *output=NULL)
CLabels * classify(CLabels *output=NULL)
bool save_likelihood(FILE *file)
virtual EFeatureType get_feature_type()=0
bool set_label(int32_t idx, float64_t label)
int32_t get_M() const
access function for number of observations M
static float64_t relative_entropy(float64_t *p, float64_t *q, int32_t len)
bool save_model(FILE *file)
void set_observations(CStringFeatures< uint16_t > *obs, CHMM *hmm=NULL)
The class Labels models labels, i.e. class assignments of objects.
bool linear_train(char align='l')
bool permutation_entropy(int32_t width=0, int32_t seq_num=-1)
bool append_model(char *filename, int32_t base1=-1, int32_t base2=-1)
viterbi only for defined transitions/observations
baum welch only for defined transitions/observations
bool viterbi_train_defined()
bool linear_train(bool right_align=false)
estimates linear model from observations.
bool save_model_bin(FILE *file)
float64_t get_b(T_STATES line_, uint16_t column) const
bool baum_welch_viterbi_train(BaumWelchViterbiType type)
floatmax_t get_max_num_symbols()
bool baum_welch_train_defined()
virtual int32_t get_num_vectors() const
uint16_t get_best_path_state(int32_t dim, int32_t t)
CStringFeatures< uint16_t > * get_observations()
return observation pointer
bool entropy(float64_t *&values, int32_t &len)
virtual int32_t get_vector_length(int32_t vec_num)
float64_t model_probability(int32_t dimension=-1)
inline proxy for model probability.
bool set_hmm_as(char *target)
Class SGObject is the base class of all shogun objects.
virtual EFeatureClass get_feature_class()=0
floatmax_t get_original_num_symbols()
bool permutation_entropy(int32_t window_width, int32_t sequence_number)
compute permutation entropy
void add_states(int32_t num_states, float64_t default_val=0)
bool convergence_criteria(int32_t num_iterations=100, float64_t epsilon=0.001)
bool save_likelihood(char *filename, bool is_binary=false)
floatmax_t get_num_symbols()
float64_t classify_example(int32_t idx)
static float64_t entropy(float64_t *p, int32_t len)
returns entropy of p which is given in logspace
bool relative_entropy(float64_t *&values, int32_t &len)
float64_t best_path(int32_t dimension)
bool set_epsilon(float64_t eps)
bool append_model(CHMM *append_model, float64_t *cur_out, float64_t *app_out)
bool load_definitions(FILE *file, bool verbose, bool initialize=true)
bool set_iterations(int32_t num)
bool add_states(int32_t num_states=1, float64_t value=0)
float64_t linear_model_probability(int32_t dimension)
baum welch only for specified transitions
bool new_hmm(int32_t n, int32_t m)
bool load_definitions(char *filename, bool do_init=false)
The class Features is the base class of all feature objects.
bool load(char *filename)
bool baum_welch_trans_train()
CLabels * one_class_classify(CLabels *output=NULL)
bool normalize(bool keep_dead_states=false)
bool chop(float64_t value)
void output_model_defined(bool verbose=false)
performs output_model only for the defined transitions etc
bool save(char *filename, bool is_binary=false)
void output_model(bool verbose=false)
bool output_hmm_defined()
bool save_path(char *filename, bool is_binary=false)
void normalize(bool keep_dead_states=false)
normalize the model to satisfy stochasticity
bool set_pseudo(float64_t pseudo)
#define SG_MALLOC(type, len)
T_STATES get_N() const
access function for number of states N
bool best_path(int32_t from=0, int32_t to=100)
bool save_path(FILE *file)