22 :
CSGObject(), ui(ui_), train_features(NULL), test_features(NULL),
49 char* filename,
char* fclass,
char* type,
char* target, int32_t size,
50 int32_t comp_features)
55 if (strncmp(target,
"TRAIN", 5)==0)
60 else if (strncmp(target,
"TEST", 4)==0)
66 SG_ERROR(
"Unknown target %s, neither TRAIN nor TEST.\n", target)
72 if (strncmp(fclass,
"SIMPLE", 6)==0)
74 if (strncmp(type,
"REAL", 4)==0)
78 else if (strncmp(type,
"BYTE", 4)==0)
83 else if (strncmp(type,
"CHAR", 4)==0)
88 else if (strncmp(type,
"SHORT", 5)==0)
98 else if (strncmp(fclass,
"SPARSE", 6)==0)
102 else if (strncmp(fclass,
"STRING", 6)==0)
104 if (strncmp(type,
"REAL", 4)==0)
108 else if (strncmp(type,
"BYTE", 4)==0)
113 else if (strncmp(type,
"CHAR", 4)==0)
118 else if (strncmp(type,
"SHORT", 5)==0)
122 else if (strncmp(type,
"WORD", 4)==0)
126 else if (strncmp(type,
"ULONG", 5)==0)
147 if (strncmp(target,
"TRAIN", 5)==0)
151 else if (strncmp(target,
"TEST", 4)==0)
156 SG_ERROR(
"Unknown target %s, neither TRAIN nor TEST.\n", target)
163 if (strncmp(type,
"REAL", 4)==0)
167 else if (strncmp(type,
"BYTE", 4)==0)
171 else if (strncmp(type,
"CHAR", 4)==0)
175 else if (strncmp(type,
"SHORT", 5)==0)
179 else if (strncmp(type,
"WORD", 4)==0)
192 SG_ERROR(
"Writing to file %s failed!\n", filename)
195 SG_INFO(
"Successfully written features into \"%s\" !\n", filename)
206 if (strncmp(target,
"TRAIN", 5)==0)
208 else if (strncmp(target,
"TEST", 4)==0)
211 SG_ERROR(
"Unknown target %s, neither TRAIN nor TEST.\n", target)
220 if (strncmp(target,
"TRAIN", 5)==0)
225 else if (strncmp(target,
"TEST", 4)==0)
232 SG_ERROR(
"Invalid target %s\n", target)
239 SG_INFO(
"reshape data to %d x %d\n", num_feat, num_vec)
240 result=(*f_ptr)->reshape(num_feat, num_vec);
253 if (strncmp(target,
"TEST", 4)==0)
255 else if (strncmp(target,
"TRAIN", 5)==0)
270 if (strncmp(target,
"TEST", 4)==0)
272 else if (strncmp(target,
"TRAIN", 5)==0)
289 if (strncmp(target,
"TEST", 4)==0)
306 SG_INFO(
"Attempting to convert dense feature matrix to a sparse one.\n")
315 SG_ERROR(
"No SIMPLE DREAL features available.\n")
329 for (int32_t i=0; i<num_vec; i++)
334 strings[i].
slen=len ;
335 for (int32_t j=0; j<len; j++)
341 strings[i].
string=SG_MALLOC(
char, strings[i].slen);
343 for (int32_t j=0; j<strings[i].
slen; j++)
344 strings[i].
string[j]=str[j];
346 if (strings[i].slen> max_len)
347 max_len=strings[i].
slen;
357 SG_ERROR(
"No features of class/type SIMPLE/CHAR available.\n")
379 for (int32_t i=0; i<num_vec; i++)
386 for (int32_t j=0; j<num_feat; j++)
398 SG_ERROR(
"No SIMPLE WORD features or PluginEstimator available.\n")
413 SG_INFO(
"Converting to TOP features.\n")
415 if (
ui->ui_hmm->get_pos() &&
ui->ui_hmm->get_neg())
417 ui->ui_hmm->get_pos()->set_observations(src);
418 ui->ui_hmm->get_neg()->set_observations(src);
420 bool neglinear=
false;
421 bool poslinear=
false;
424 0,
ui->ui_hmm->get_pos(),
ui->ui_hmm->get_neg(),
425 neglinear, poslinear);
429 SG_ERROR(
"HMMs not correctly assigned!\n")
432 SG_ERROR(
"No SIMPLE WORD features available.\n")
442 SG_INFO(
"Converting to FK features.\n")
444 if (
ui->ui_hmm->get_pos() &&
ui->ui_hmm->get_neg())
447 ui->ui_hmm->get_pos()->get_observations();
449 ui->ui_hmm->get_neg()->get_observations();
452 ui->ui_hmm->get_pos()->set_observations(string_feat);
453 ui->ui_hmm->get_neg()->set_observations(string_feat);
456 0,
ui->ui_hmm->get_pos(),
ui->ui_hmm->get_neg());
461 SG_ERROR(
"Need train features to set optimal a.\n")
465 ui->ui_hmm->get_pos()->set_observations(old_obs_pos);
466 ui->ui_hmm->get_neg()->set_observations(old_obs_neg);
469 SG_ERROR(
"HMMs not correctly assigned!\n")
483 SG_INFO(
"Attempting to convert sparse feature matrix to a dense one.\n")
493 SG_ERROR(
"No SPARSE REAL features available.\n")
512 SG_INFO(
"Converting CHAR features to REAL ones.\n")
517 SG_INFO(
"Start aligment with gapCost=%1.2f.\n", gap_cost)
520 SG_INFO(
"Conversion was successful.\n")
525 SG_ERROR(
"No SIMPLE CHAR features available.\n")
533 if (strncmp(target,
"TRAIN", 5)==0)
541 else if (strncmp(target,
"TEST", 4)==0)
578 SG_ERROR(
"appending feature object failed\n")
596 SG_ERROR(
"Trainfeatures not based on DotFeatures.\n")
610 SG_ERROR(
"appending dot feature object failed\n")
627 SG_ERROR(
"Trainfeatures not based on DotFeatures.\n")
641 SG_ERROR(
"Appending feature object failed.\n")
669 SG_ERROR(
"Appending feature object failed.\n")
675 if (strncmp(target,
"TRAIN", 5)==0)
678 SG_ERROR(
"No train features available.\n")
680 SG_ERROR(
"Train features are not combined features.\n")
684 else if (strncmp(target,
"TEST", 4)==0)
687 SG_ERROR(
"No test features available.\n")
689 SG_ERROR(
"Test features are not combined features.\n")
694 SG_ERROR(
"Unknown target %s, neither TRAIN nor TEST.\n", target)
697 SG_ERROR(
"No features available to delete.\n")
float64_t set_opt_a(float64_t a=-1)
void add_train_features(CFeatures *f)
CFeatures * test_features
CDenseFeatures< float64_t > * convert_simple_word_to_simple_salzberg(CDenseFeatures< uint16_t > *src)
Template class StringFeatures implements a list of strings.
ST * get_feature_vector(int32_t num, int32_t &len, bool &dofree)
int32_t get_num_features() const
int32_t get_num_feature_obj()
bool set_test_features(CFeatures *f)
CTOPFeatures * convert_string_word_to_simple_top(CStringFeatures< uint16_t > *src)
CStringFeatures< char > * convert_simple_char_to_string_char(CDenseFeatures< char > *src)
CExplicitSpecFeatures * convert_string_byte_to_spec_word(CStringFeatures< uint16_t > *src, bool use_norm)
SGMatrix< ST > get_feature_matrix()
bool load(char *filename, char *fclass, char *type, char *target, int32_t size, int32_t comp_features)
void set_feature_matrix(SGMatrix< ST > matrix)
virtual float64_t * set_feature_matrix()
virtual int32_t get_num_vectors() const =0
#define SG_NOTIMPLEMENTED
The class Alphabet implements an alphabet and alphabet utility functions.
float64_t get_parameterwise_log_odds(uint16_t obs, int32_t position)
bool save(char *filename, char *type, char *target)
virtual void remove_rhs()
takes all necessary steps if the rhs is removed from kernel
Features that support dot products among other operations.
bool del_last_feature_obj(char *target)
CFKFeatures * convert_string_word_to_simple_fk(CStringFeatures< uint16_t > *src)
Class CSVFile used to read data from comma-separated values (CSV) files. See http://en.wikipedia.org/wiki/Comma-separated_values.
void add_test_dotfeatures(CDotFeatures *f)
Class SGObject is the base class of all shogun objects.
virtual int32_t get_num_vectors() const
bool set_convert_features(CFeatures *features, char *target)
virtual EFeatureClass get_feature_class() const
void add_test_features(CFeatures *f)
CSparseFeatures< float64_t > * convert_simple_real_to_sparse_real(CDenseFeatures< float64_t > *src)
virtual EFeatureClass get_feature_class() const
virtual void set_full_feature_matrix(SGMatrix< ST > full)
virtual EFeatureClass get_feature_class() const =0
CFeatures * get_train_features()
bool set_train_features(CFeatures *f)
virtual EFeatureType get_feature_type() const
virtual EFeatureType get_feature_type() const
Features that compute the Spectrum Kernel feature space explicitly.
The class TOPFeatures implements TOP kernel features obtained from two Hidden Markov models...
all of classes and functions are contained in the shogun namespace
void free_feature_vector(ST *feat_vec, int32_t num, bool dofree)
CFeatures * get_test_features()
virtual EFeatureClass get_feature_class() const
virtual float64_t * set_feature_matrix()
CDenseFeatures< float64_t > * convert_simple_char_to_simple_align(CDenseFeatures< char > *src, float64_t gap_cost=0)
The class Features is the base class of all feature objects.
bool set_reference_features(char *target)
virtual void remove_lhs()
Features that allow stacking of a number of DotFeatures.
void add_train_dotfeatures(CDotFeatures *f)
virtual EFeatureType get_feature_type() const
bool reshape(char *target, int32_t num_feat, int32_t num_vec)
CFeatures * train_features
SGMatrix< ST > get_full_feature_matrix()
bool has_property(EFeatureProperty p) const
The class CombinedFeatures is used to combine a number of of feature objects into a single CombinedFe...
bool delete_feature_obj(int32_t idx)
CDenseFeatures< float64_t > * convert_sparse_real_to_simple_real(CSparseFeatures< float64_t > *src)
The class FKFeatures implements Fischer kernel features obtained from two Hidden Markov models...
bool append_feature_obj(CFeatures *obj)
void set_features(SGStringList< ST > feats)
CFeatures * get_convert_features(char *target)