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");
317 SG_ERROR(
"No SIMPLE DREAL features available.\n");
331 for (int32_t i=0; i<num_vec; i++)
336 strings[i].
slen=len ;
337 for (int32_t j=0; j<len; j++)
345 for (int32_t j=0; j<strings[i].
slen; j++)
346 strings[i].
string[j]=str[j];
348 if (strings[i].slen> max_len)
349 max_len=strings[i].
slen;
359 SG_ERROR(
"No features of class/type SIMPLE/CHAR available.\n");
381 for (int32_t i=0; i<num_vec; i++)
388 for (int32_t j=0; j<num_feat; j++)
400 SG_ERROR(
"No SIMPLE WORD features or PluginEstimator available.\n");
415 SG_INFO(
"Converting to TOP features.\n");
417 if (
ui->ui_hmm->get_pos() &&
ui->ui_hmm->get_neg())
419 ui->ui_hmm->get_pos()->set_observations(src);
420 ui->ui_hmm->get_neg()->set_observations(src);
422 bool neglinear=
false;
423 bool poslinear=
false;
426 0,
ui->ui_hmm->get_pos(),
ui->ui_hmm->get_neg(),
427 neglinear, poslinear);
431 SG_ERROR(
"HMMs not correctly assigned!\n");
434 SG_ERROR(
"No SIMPLE WORD features available.\n");
444 SG_INFO(
"Converting to FK features.\n");
446 if (
ui->ui_hmm->get_pos() &&
ui->ui_hmm->get_neg())
449 ui->ui_hmm->get_pos()->get_observations();
451 ui->ui_hmm->get_neg()->get_observations();
454 ui->ui_hmm->get_pos()->set_observations(string_feat);
455 ui->ui_hmm->get_neg()->set_observations(string_feat);
458 0,
ui->ui_hmm->get_pos(),
ui->ui_hmm->get_neg());
463 SG_ERROR(
"Need train features to set optimal a.\n");
467 ui->ui_hmm->get_pos()->set_observations(old_obs_pos);
468 ui->ui_hmm->get_neg()->set_observations(old_obs_neg);
471 SG_ERROR(
"HMMs not correctly assigned!\n");
485 SG_INFO(
"Attempting to convert sparse feature matrix to a dense one.\n");
495 SG_ERROR(
"No SPARSE REAL features available.\n");
514 SG_INFO(
"Converting CHAR features to REAL ones.\n");
519 SG_INFO(
"Start aligment with gapCost=%1.2f.\n", gap_cost);
522 SG_INFO(
"Conversion was successful.\n");
527 SG_ERROR(
"No SIMPLE CHAR features available.\n");
535 if (strncmp(target,
"TRAIN", 5)==0)
543 else if (strncmp(target,
"TEST", 4)==0)
580 SG_ERROR(
"appending feature object failed\n");
598 SG_ERROR(
"Trainfeatures not based on DotFeatures.\n");
612 SG_ERROR(
"appending dot feature object failed\n");
629 SG_ERROR(
"Trainfeatures not based on DotFeatures.\n");
643 SG_ERROR(
"Appending feature object failed.\n");
671 SG_ERROR(
"Appending feature object failed.\n");
677 if (strncmp(target,
"TRAIN", 5)==0)
680 SG_ERROR(
"No train features available.\n");
682 SG_ERROR(
"Train features are not combined features.\n");
686 else if (strncmp(target,
"TEST", 4)==0)
689 SG_ERROR(
"No test features available.\n");
691 SG_ERROR(
"Test features are not combined features.\n");
696 SG_ERROR(
"Unknown target %s, neither TRAIN nor TEST.\n", target);
699 SG_ERROR(
"No features available to delete.\n");