1 #ifndef __SGINTERFACE__H_ 2 #define __SGINTERFACE__H_ 101 MKL_RELATIVE_DUALITY_GAP,
103 MKL_ABSOLUTE_DUALITY_GAP
107 class CSGInterface :
public CSGObject
113 CSGInterface(
bool print_copyrights=
true);
119 virtual void reset();
122 void translate_arg(CSGInterface* source, CSGInterface* target);
126 bool cmd_load_features();
128 bool cmd_save_features();
130 bool cmd_clean_features();
132 bool cmd_get_features();
134 bool cmd_add_features();
136 bool cmd_add_multiple_features();
138 bool cmd_add_dotfeatures();
140 bool cmd_set_features();
142 bool cmd_set_reference_features();
144 bool cmd_del_last_features();
150 bool cmd_load_labels();
152 bool cmd_set_labels();
154 bool cmd_get_labels();
157 bool cmd_set_kernel_normalization();
159 bool cmd_set_kernel();
161 bool cmd_add_kernel();
163 bool cmd_del_last_kernel();
165 bool cmd_init_kernel();
167 bool cmd_clean_kernel();
169 bool cmd_save_kernel();
171 bool cmd_load_kernel_init();
173 bool cmd_save_kernel_init();
175 bool cmd_get_kernel_matrix();
177 bool cmd_set_WD_position_weights();
179 bool cmd_get_subkernel_weights();
181 bool cmd_set_subkernel_weights();
183 bool cmd_set_subkernel_weights_combined();
185 bool cmd_get_dotfeature_weights_combined();
187 bool cmd_set_dotfeature_weights_combined();
189 bool cmd_set_last_subkernel_weights();
191 bool cmd_get_WD_position_weights();
193 bool cmd_get_last_subkernel_weights();
195 bool cmd_compute_by_subkernels();
197 bool cmd_init_kernel_optimization();
199 bool cmd_get_kernel_optimization();
201 bool cmd_delete_kernel_optimization();
203 bool cmd_use_diagonal_speedup();
205 bool cmd_set_kernel_optimization_type();
207 bool cmd_set_solver();
209 bool cmd_set_constraint_generator();
211 bool cmd_set_prior_probs();
213 bool cmd_set_prior_probs_from_labels();
218 bool cmd_set_distance();
220 bool cmd_init_distance();
222 bool cmd_get_distance_matrix();
225 bool cmd_get_SPEC_consensus();
227 bool cmd_get_SPEC_scoring();
229 bool cmd_get_WD_consensus();
231 bool cmd_compute_POIM_WD();
233 bool cmd_get_WD_scoring();
236 bool cmd_new_classifier();
238 bool cmd_load_classifier();
240 bool cmd_save_classifier();
244 bool cmd_get_num_svms();
248 bool cmd_set_linear_classifier();
252 bool cmd_classify_example();
254 bool cmd_get_classifier();
256 bool cmd_get_svm_objective();
258 bool cmd_compute_svm_primal_objective();
260 bool cmd_compute_svm_dual_objective();
262 bool cmd_compute_mkl_dual_objective();
264 bool cmd_compute_relative_mkl_duality_gap();
266 bool cmd_compute_absolute_mkl_duality_gap();
268 bool cmd_train_classifier();
270 bool cmd_do_auc_maximization();
272 bool cmd_set_perceptron_parameters();
274 bool cmd_set_svm_qpsize();
276 bool cmd_set_svm_max_qpsize();
278 bool cmd_set_svm_bufsize();
280 bool cmd_set_svm_C();
282 bool cmd_set_svm_epsilon();
284 bool cmd_set_svr_tube_epsilon();
286 bool cmd_set_svm_nu();
288 bool cmd_set_svm_mkl_parameters();
290 bool cmd_set_elasticnet_lambda();
292 bool cmd_set_mkl_block_norm();
294 bool cmd_set_max_train_time();
296 bool cmd_set_svm_mkl_enabled();
298 bool cmd_set_svm_shrinking_enabled();
300 bool cmd_set_svm_batch_computation_enabled();
302 bool cmd_set_svm_linadd_enabled();
304 bool cmd_set_svm_bias_enabled();
306 bool cmd_set_mkl_interleaved_enabled();
308 bool cmd_set_krr_tau();
311 bool cmd_add_preproc();
313 bool cmd_del_preproc();
315 bool cmd_attach_preproc();
317 bool cmd_clean_preproc();
320 bool cmd_set_converter();
322 bool cmd_apply_converter();
333 bool cmd_hmm_classify();
335 bool cmd_hmm_classify_example();
337 bool cmd_one_class_linear_hmm_classify();
339 bool cmd_one_class_hmm_classify();
341 bool cmd_one_class_hmm_classify_example();
343 bool cmd_output_hmm();
345 bool cmd_output_hmm_defined();
347 bool cmd_hmm_likelihood();
349 bool cmd_likelihood();
351 bool cmd_save_likelihood();
353 bool cmd_get_viterbi_path();
355 bool cmd_viterbi_train_defined();
357 bool cmd_viterbi_train();
359 bool cmd_baum_welch_train();
361 bool cmd_baum_welch_train_defined();
363 bool cmd_baum_welch_trans_train();
365 bool cmd_linear_train();
367 bool cmd_save_path();
369 bool cmd_append_hmm();
371 bool cmd_append_model();
375 bool cmd_set_hmm_as();
381 bool cmd_set_pseudo();
383 bool cmd_load_definitions();
385 bool cmd_convergence_criteria();
387 bool cmd_normalize();
389 bool cmd_add_states();
391 bool cmd_permutation_entropy();
393 bool cmd_relative_entropy();
397 bool cmd_new_plugin_estimator();
399 bool cmd_train_estimator();
401 bool cmd_plugin_estimate_classify_example();
403 bool cmd_plugin_estimate_classify();
405 bool cmd_set_plugin_estimate();
407 bool cmd_get_plugin_estimate();
409 bool cmd_best_path();
411 bool cmd_best_path_2struct();
417 bool cmd_set_plif_struct();
424 bool cmd_get_plif_struct();
428 bool cmd_precompute_subkernels();
432 bool cmd_signals_set_model() {
return false; };
436 bool cmd_signals_set_positions();
440 bool cmd_signals_set_labels();
444 bool cmd_signals_set_split();
448 bool cmd_signals_set_train_mask();
452 bool cmd_signals_add_feature();
456 bool cmd_signals_add_kernel();
460 bool cmd_signals_run();
473 bool cmd_precompute_content_svms();
477 bool cmd_get_lin_feat();
481 bool cmd_set_lin_feat();
486 bool cmd_init_dyn_prog();
491 bool cmd_clean_up_dyn_prog();
496 bool cmd_init_intron_list();
499 bool cmd_long_transition_settings();
509 bool cmd_precompute_tiling_features();
521 bool cmd_set_model();
526 bool cmd_set_feature_matrix_sparse();
531 bool cmd_set_feature_matrix();
533 bool cmd_best_path_trans();
535 bool cmd_best_path_trans_deriv();
537 bool cmd_best_path_no_b();
539 bool cmd_best_path_no_b_trans();
550 bool cmd_set_output();
552 bool cmd_set_threshold();
554 bool cmd_init_random();
556 bool cmd_set_num_threads();
558 bool cmd_translate_string();
574 bool cmd_syntax_highlight();
576 bool cmd_get_version();
582 bool cmd_send_command();
584 virtual bool cmd_run_python();
586 virtual bool cmd_run_octave();
588 virtual bool cmd_run_r();
590 virtual bool cmd_pr_loqo();
594 virtual IFType get_argument_type()=0;
598 virtual int32_t get_int()=0;
602 virtual bool get_bool()=0;
607 virtual char* get_string(int32_t& len)=0;
613 virtual void get_vector(
bool*& vector, int32_t& len);
618 virtual void get_vector(uint8_t*& vector, int32_t& len)=0;
623 virtual void get_vector(
char*& vector, int32_t& len)=0;
628 virtual void get_vector(int32_t*& vector, int32_t& len)=0;
633 virtual void get_vector(
float64_t*& vector, int32_t& len)=0;
638 virtual void get_vector(
float32_t*& vector, int32_t& len)=0;
643 virtual void get_vector(int16_t*& vector, int32_t& len)=0;
648 virtual void get_vector(uint16_t*& vector, int32_t& len)=0;
655 virtual void get_matrix(
656 uint8_t*& matrix, int32_t& num_feat, int32_t& num_vec)=0;
662 virtual void get_matrix(
663 char*& matrix, int32_t& num_feat, int32_t& num_vec)=0;
669 virtual void get_matrix(
670 int32_t*& matrix, int32_t& num_feat, int32_t& num_vec)=0;
676 virtual void get_matrix(
677 float32_t*& matrix, int32_t& num_feat, int32_t& num_vec)=0;
683 virtual void get_matrix(
684 float64_t*& matrix, int32_t& num_feat, int32_t& num_vec)=0;
690 virtual void get_matrix(
691 int16_t*& matrix, int32_t& num_feat, int32_t& num_vec)=0;
697 virtual void get_matrix(
698 uint16_t*& matrix, int32_t& num_feat, int32_t& num_vec)=0;
705 virtual void get_ndarray(
706 uint8_t*& array, int32_t*& dims, int32_t& num_dims)=0;
712 virtual void get_ndarray(
713 char*& array, int32_t*& dims, int32_t& num_dims)=0;
719 virtual void get_ndarray(
720 int32_t*& array, int32_t*& dims, int32_t& num_dims)=0;
726 virtual void get_ndarray(
727 float32_t*& array, int32_t*& dims, int32_t& num_dims)=0;
733 virtual void get_ndarray(
734 float64_t*& array, int32_t*& dims, int32_t& num_dims)=0;
740 virtual void get_ndarray(
741 int16_t*& array, int32_t*& dims, int32_t& num_dims)=0;
747 virtual void get_ndarray(
748 uint16_t*& array, int32_t*& dims, int32_t& num_dims)=0;
755 virtual void get_sparse_matrix(
756 SGSparseVector<float64_t>*& matrix, int32_t& num_feat, int32_t& num_vec)=0;
772 virtual void get_string_list(
773 SGString<uint8_t>*& strings, int32_t& num_str,
774 int32_t& max_string_len)=0;
780 virtual void get_string_list(
781 SGString<char>*& strings, int32_t& num_str,
782 int32_t& max_string_len)=0;
788 virtual void get_string_list(
789 SGString<int32_t>*& strings, int32_t& num_str,
790 int32_t& max_string_len)=0;
796 virtual void get_string_list(
797 SGString<int16_t>*& strings, int32_t& num_str,
798 int32_t& max_string_len)=0;
804 virtual void get_string_list(
805 SGString<uint16_t>*& strings, int32_t& num_str,
806 int32_t& max_string_len)=0;
811 virtual void get_attribute_struct(
812 const CDynamicArray<T_ATTRIBUTE>* &attrs)=0;
818 virtual bool create_return_values(int32_t num_val)=0;
823 virtual void set_int(int32_t scalar)=0;
827 virtual void set_real(
float64_t scalar)=0;
831 virtual void set_bool(
bool scalar)=0;
837 virtual void set_vector(
const bool* vector, int32_t len);
842 virtual void set_vector(
const uint8_t* vector, int32_t len)=0;
847 virtual void set_vector(
const char* vector, int32_t len)=0;
852 virtual void set_vector(
const int32_t* vector, int32_t len)=0;
857 virtual void set_vector(
const float32_t* vector, int32_t len)=0;
862 virtual void set_vector(
const float64_t* vector, int32_t len)=0;
867 virtual void set_vector(
const int16_t* vector, int32_t len)=0;
872 virtual void set_vector(
const uint16_t* vector, int32_t len)=0;
879 virtual void set_matrix(
880 const uint8_t* matrix, int32_t num_feat, int32_t num_vec)=0;
886 virtual void set_matrix(
887 const char* matrix, int32_t num_feat, int32_t num_vec)=0;
893 virtual void set_matrix(
894 const int32_t* matrix, int32_t num_feat, int32_t num_vec)=0;
900 virtual void set_matrix(
901 const float32_t* matrix, int32_t num_feat, int32_t num_vec)=0;
907 virtual void set_matrix(
908 const float64_t* matrix, int32_t num_feat, int32_t num_vec)=0;
914 virtual void set_matrix(
915 const int16_t* matrix, int32_t num_feat, int32_t num_vec)=0;
921 virtual void set_matrix(
922 const uint16_t* matrix, int32_t num_feat, int32_t num_vec)=0;
930 virtual void set_sparse_matrix(
931 const SGSparseVector<float64_t>* matrix, int32_t num_feat,
932 int32_t num_vec, int64_t nnz)=0;
947 virtual void set_string_list(
948 const SGString<uint8_t>* strings, int32_t num_str)=0;
953 virtual void set_string_list(
954 const SGString<char>* strings, int32_t num_str)=0;
959 virtual void set_string_list(
960 const SGString<int32_t>* strings, int32_t num_str)=0;
965 virtual void set_string_list(
966 const SGString<int16_t>* strings, int32_t num_str)=0;
971 virtual void set_string_list(
972 const SGString<uint16_t>* strings, int32_t num_str)=0;
977 virtual void set_attribute_struct(
978 const CDynamicArray<T_ATTRIBUTE>* attrs)=0;
987 int32_t get_nlhs() {
return m_nlhs; }
990 int32_t get_nrhs() {
return m_nrhs; }
995 CGUIClassifier* ui_classifier;
997 CGUIDistance* ui_distance;
999 CGUIFeatures* ui_features;
1003 CGUIKernel* ui_kernel;
1005 CGUILabels* ui_labels;
1009 CGUIPluginEstimate* ui_pluginestimate;
1011 CGUIPreprocessor* ui_preproc;
1015 CGUIStructure* ui_structure;
1017 CGUIConverter* ui_converter;
1027 static bool strmatch(
const char* str,
const char* cmd, int32_t len=-1)
1032 if (strlen(str)!=(
size_t) len)
1036 return (strncmp(str, cmd, len)==0);
1043 static bool strendswith(
const char* str,
const char* cmd)
1045 size_t idx=strlen(str);
1046 size_t len=strlen(cmd);
1048 if (strlen(str) < len)
1053 return (strncmp(str, cmd, len)==0);
1056 char* get_command(int32_t &len)
1060 SG_SERROR("No input arguments supplied.\n")
1062 return get_string(len);
1066 bool do_compute_objective(E_WHICH_OBJ obj);
1068 bool do_hmm_classify(
bool linear=false,
bool one_class=false);
1070 bool do_hmm_classify_example(
bool one_class=false);
1072 bool do_set_features(
bool add=false,
bool check_dot=false, int32_t repetitions=1);
1075 void convert_to_bitembedding(CFeatures* &features,
bool convert_to_word,
bool convert_to_ulong);
1077 void obtain_from_single_string(CFeatures* features);
1079 bool obtain_from_position_list(CFeatures* features);
1081 bool obtain_by_sliding_window(CFeatures* features);
1083 CKernel* create_kernel();
1086 CFeatures* create_custom_string_features(CStringFeatures<uint8_t>* f);
1088 CFeatures* create_custom_real_features(CDenseFeatures<
float64_t>* orig_feat);
1090 char* get_str_from_str_or_direct(int32_t& len);
1091 int32_t get_int_from_int_or_str();
1093 bool get_bool_from_bool_or_str();
1094 void get_vector_from_int_vector_or_str(
1095 int32_t*& vector, int32_t& len);
1096 void get_vector_from_real_vector_or_str(
1098 int32_t get_vector_len_from_str(int32_t expected_len=0);
1099 char* get_str_from_str(int32_t& len);
1100 int32_t get_num_args_in_str();
1104 char* get_line(FILE* infile=stdin,
bool show_prompt=true);
1108 int32_t m_lhs_counter;
1110 int32_t m_rhs_counter;
1125 char* m_legacy_strptr;
1129 typedef
bool (CSGInterface::*CSGInterfacePtr)();
1131 #ifndef DOXYGEN_SHOULD_SKIP_THIS 1135 const char* command;
1137 CSGInterfacePtr method;
1139 const char* usage_prefix;
1141 const char* usage_suffix;
1142 } CSGInterfaceMethod;
1146 #endif // __SGINTERFACE__H_
#define UNDEFINED(function, type)
void add(Matrix A, Matrix B, Matrix C, typename Matrix::Scalar alpha=1.0, typename Matrix::Scalar beta=1.0)
all of classes and functions are contained in the shogun namespace