19 using namespace shogun;
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")