/usr/include/shogun/ui/SGInterface.h is in libshogun-dev 3.2.0-7.3build4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 | #ifndef __SGINTERFACE__H_
#define __SGINTERFACE__H_
#include <shogun/lib/config.h>
#include <shogun/lib/common.h>
#include <shogun/base/SGObject.h>
#include <shogun/features/Features.h>
#include <shogun/features/StringFeatures.h>
#include <shogun/features/SparseFeatures.h>
#include <shogun/features/AttributeFeatures.h>
#include <shogun/kernel/Kernel.h>
#include <shogun/ui/GUIClassifier.h>
#include <shogun/ui/GUIDistance.h>
#include <shogun/ui/GUIFeatures.h>
#include <shogun/ui/GUIHMM.h>
#include <shogun/ui/GUIKernel.h>
#include <shogun/ui/GUILabels.h>
#include <shogun/ui/GUIMath.h>
#include <shogun/ui/GUIPluginEstimate.h>
#include <shogun/ui/GUIPreprocessor.h>
#include <shogun/ui/GUITime.h>
#include <shogun/ui/GUIStructure.h>
#include <shogun/ui/GUIConverter.h>
namespace shogun
{
/** Interface datatypes that shogun supports. Note that some interfaces like e.g.
* octave/matlab cannot distinguish between scalars and matrices and thus might
* always return more complex types like matrices.
*/
enum IFType
{
/// undefined
UNDEFINED,
///simple scalar/string types
SCALAR_INT,
SCALAR_REAL,
SCALAR_BOOL,
STANDARD_STRING,
///vector type
VECTOR_BOOL,
VECTOR_BYTE,
VECTOR_CHAR,
VECTOR_INT,
VECTOR_REAL,
VECTOR_SHORTREAL,
VECTOR_SHORT,
VECTOR_WORD,
///dense matrices
DENSE_INT,
DENSE_REAL,
DENSE_SHORTREAL,
DENSE_SHORT,
DENSE_WORD,
///dense nd arrays
NDARRAY_BYTE,
NDARRAY_CHAR,
NDARRAY_INT,
NDARRAY_REAL,
NDARRAY_SHORTREAL,
NDARRAY_SHORT,
NDARRAY_WORD,
///sparse matrices
SPARSE_BYTE,
SPARSE_CHAR,
SPARSE_INT,
SPARSE_REAL,
SPARSE_SHORT,
SPARSE_SHORTREAL,
SPARSE_WORD,
///strings of arbitrary type
STRING_BYTE,
STRING_CHAR,
STRING_INT,
STRING_SHORT,
STRING_WORD,
/// structures
ATTR_STRUCT
};
/** objective enumerate */
enum E_WHICH_OBJ
{
/// svm primal task
SVM_PRIMAL,
/// svm dual task
SVM_DUAL,
/// mkl primal task
MKL_PRIMAL,
/// mkl dual task
MKL_DUAL,
/// mkl relative duality gap
MKL_RELATIVE_DUALITY_GAP,
/// mkl absolute duality gap
MKL_ABSOLUTE_DUALITY_GAP
};
/** @brief shogun interface */
class CSGInterface : public CSGObject
{
public:
/** constructor
* @param print_copyrights
*/
CSGInterface(bool print_copyrights=true);
/** destructor */
~CSGInterface();
/// reset to clean state
virtual void reset();
/// translate matrix from language A to language B
void translate_arg(CSGInterface* source, CSGInterface* target);
/* commands */
/** load features from file */
bool cmd_load_features();
/** save features to file */
bool cmd_save_features();
/** clear/clean features */
bool cmd_clean_features();
/** get features */
bool cmd_get_features();
/** add features */
bool cmd_add_features();
/** add multiple features */
bool cmd_add_multiple_features();
/** add dot features */
bool cmd_add_dotfeatures();
/** set features */
bool cmd_set_features();
/** set reference features */
bool cmd_set_reference_features();
/** del last features from combined features */
bool cmd_del_last_features();
/** convert features */
bool cmd_convert();
/** reshape features */
bool cmd_reshape();
/** load labels from file */
bool cmd_load_labels();
/** set labels */
bool cmd_set_labels();
/** get labels */
bool cmd_get_labels();
/** set kernel normalization */
bool cmd_set_kernel_normalization();
/** set kernel */
bool cmd_set_kernel();
/** add kernel (to e.g. CombinedKernel) */
bool cmd_add_kernel();
/** delete last kernel from combined kernel */
bool cmd_del_last_kernel();
/** initialize kernel */
bool cmd_init_kernel();
/** clear/clean kernel */
bool cmd_clean_kernel();
/** save kernel to file */
bool cmd_save_kernel();
/** load kernel init from file */
bool cmd_load_kernel_init();
/** save kernel init to file */
bool cmd_save_kernel_init();
/** get kernel matrix */
bool cmd_get_kernel_matrix();
/** set WD position weights */
bool cmd_set_WD_position_weights();
/** get subkernel weights */
bool cmd_get_subkernel_weights();
/** set subkernel weights */
bool cmd_set_subkernel_weights();
/** set subkernel weights combined */
bool cmd_set_subkernel_weights_combined();
/** get dotfeature weights combined */
bool cmd_get_dotfeature_weights_combined();
/** set dotfeature weights combined */
bool cmd_set_dotfeature_weights_combined();
/** set last subkernel weights */
bool cmd_set_last_subkernel_weights();
/** get WD position weights */
bool cmd_get_WD_position_weights();
/** get last subkernel weights */
bool cmd_get_last_subkernel_weights();
/** compute by subkernels */
bool cmd_compute_by_subkernels();
/** initialize kernel optimization */
bool cmd_init_kernel_optimization();
/** get kernel optimization */
bool cmd_get_kernel_optimization();
/** delete kernel optimization */
bool cmd_delete_kernel_optimization();
/** set diagonal speedup */
bool cmd_use_diagonal_speedup();
/** set kernel optimization type */
bool cmd_set_kernel_optimization_type();
/** set solver type */
bool cmd_set_solver();
/** set constraint generator */
bool cmd_set_constraint_generator();
/** set Salzberg prior probs */
bool cmd_set_prior_probs();
/** set Salzberg prior probs from labels */
bool cmd_set_prior_probs_from_labels();
/** set distance */
bool cmd_set_distance();
/** init distance */
bool cmd_init_distance();
/** get distance matrix */
bool cmd_get_distance_matrix();
/** get SPEC consensus */
bool cmd_get_SPEC_consensus();
/** get SPEC scoring */
bool cmd_get_SPEC_scoring();
/** get WD consensus */
bool cmd_get_WD_consensus();
/** compute POIM WD */
bool cmd_compute_POIM_WD();
/** get WD scoring */
bool cmd_get_WD_scoring();
/** create new SVM/classifier */
bool cmd_new_classifier();
/** load SVM/classifier */
bool cmd_load_classifier();
/** save SVM/classifier */
bool cmd_save_classifier();
/** get SVM */
bool cmd_get_svm();
/** get number of SVMs in MultiClass */
bool cmd_get_num_svms();
/** set SVM */
bool cmd_set_svm();
/** set linear classifier */
bool cmd_set_linear_classifier();
/** classify */
bool cmd_classify();
/** classify example */
bool cmd_classify_example();
/** get classifier */
bool cmd_get_classifier();
/** get SVM objective */
bool cmd_get_svm_objective();
/** compute SVM objective from scratch*/
bool cmd_compute_svm_primal_objective();
/** compute SVM objective from scratch*/
bool cmd_compute_svm_dual_objective();
/** compute SVM objective from scratch*/
bool cmd_compute_mkl_dual_objective();
/** compute relative mkl duality gap */
bool cmd_compute_relative_mkl_duality_gap();
/** compute absolute mkl duality gap */
bool cmd_compute_absolute_mkl_duality_gap();
/** train classifier/SVM */
bool cmd_train_classifier();
/** do AUC maximization */
bool cmd_do_auc_maximization();
/** set perceptron parameters */
bool cmd_set_perceptron_parameters();
/** set SVM qpsize */
bool cmd_set_svm_qpsize();
/** set SVM max qpsize */
bool cmd_set_svm_max_qpsize();
/** set SVM bufsize */
bool cmd_set_svm_bufsize();
/** set SVM C */
bool cmd_set_svm_C();
/** set svm epsilon */
bool cmd_set_svm_epsilon();
/** set SVR tube epsilon */
bool cmd_set_svr_tube_epsilon();
/** set SVM OneClass nu */
bool cmd_set_svm_nu();
/** set SVM MKL parameters */
bool cmd_set_svm_mkl_parameters();
/** set ElasticnetMKL parameter lambda */
bool cmd_set_elasticnet_lambda();
/** set block norm parameter for block norm mkl */
bool cmd_set_mkl_block_norm();
/** set max train time */
bool cmd_set_max_train_time();
/** set SVM MKL enabled */
bool cmd_set_svm_mkl_enabled();
/** set SVM shrinking enabled */
bool cmd_set_svm_shrinking_enabled();
/** set SVM batch computation enabled */
bool cmd_set_svm_batch_computation_enabled();
/** set SVM linadd enabled */
bool cmd_set_svm_linadd_enabled();
/** set SVM bias enabled */
bool cmd_set_svm_bias_enabled();
/** set MKL intebias enabled */
bool cmd_set_mkl_interleaved_enabled();
/** set krr tau */
bool cmd_set_krr_tau();
/** add preproc */
bool cmd_add_preproc();
/** delete preproc */
bool cmd_del_preproc();
/** attach preproc to test/train */
bool cmd_attach_preproc();
/** clear/clean preproc */
bool cmd_clean_preproc();
/** create converter */
bool cmd_set_converter();
/** apply converter */
bool cmd_apply_converter();
/** embed features */
bool cmd_embed();
/** create new HMM */
bool cmd_new_hmm();
/** load HMM from file */
bool cmd_load_hmm();
/** save HMM to file */
bool cmd_save_hmm();
/** HMM classify */
bool cmd_hmm_classify();
/** HMM classify for a single example */
bool cmd_hmm_classify_example();
/** LinearHMM classify for 1-class examples */
bool cmd_one_class_linear_hmm_classify();
/** HMM classify for 1-class examples */
bool cmd_one_class_hmm_classify();
/** HMM classify for a single 1-class example */
bool cmd_one_class_hmm_classify_example();
/** output HMM */
bool cmd_output_hmm();
/** output HMM defined */
bool cmd_output_hmm_defined();
/** get HMM likelihood */
bool cmd_hmm_likelihood();
/** likelihood */
bool cmd_likelihood();
/** save HMM likelihoods to file */
bool cmd_save_likelihood();
/** get HMM's Viterbi Path */
bool cmd_get_viterbi_path();
/** train viterbi defined */
bool cmd_viterbi_train_defined();
/** train viterbi */
bool cmd_viterbi_train();
/** train baum welch */
bool cmd_baum_welch_train();
/** train defined baum welch */
bool cmd_baum_welch_train_defined();
/** train baum welch trans */
bool cmd_baum_welch_trans_train();
/** linear train */
bool cmd_linear_train();
/** save path to file */
bool cmd_save_path();
/** append HMM */
bool cmd_append_hmm();
/** append model (like HMM, but for CmdlineInterface */
bool cmd_append_model();
/** set HMM */
bool cmd_set_hmm();
/** set HMM as */
bool cmd_set_hmm_as();
/** get HMM */
bool cmd_get_hmm();
/** set chop value */
bool cmd_set_chop();
/** set pseudo value */
bool cmd_set_pseudo();
/** load definitions from file */
bool cmd_load_definitions();
/** convergence criteria */
bool cmd_convergence_criteria();
/** normalize HMM */
bool cmd_normalize();
/** add HMM states */
bool cmd_add_states();
/** permutation entropy */
bool cmd_permutation_entropy();
/** compute HMM relative entropy */
bool cmd_relative_entropy();
/** compute HMM entropy */
bool cmd_entropy();
/** create new plugin estimator */
bool cmd_new_plugin_estimator();
/** train plugin estimator */
bool cmd_train_estimator();
/** plugin estimate classify one example */
bool cmd_plugin_estimate_classify_example();
/** plugin estimate classify */
bool cmd_plugin_estimate_classify();
/** set plugin estimate */
bool cmd_set_plugin_estimate();
/** get plugin estimate */
bool cmd_get_plugin_estimate();
/** best path */
bool cmd_best_path();
/** best path 2struct */
bool cmd_best_path_2struct();
/**
* -assemble plif struct from a bunch of
* arrays of the same length corresponding
* to the fields of the plif-struct-array
*/
bool cmd_set_plif_struct();
/**
* -get plif struct as a bunch
* of arrays of the same length
* -each array corresponding to one
* field of the struct
*/
bool cmd_get_plif_struct();
/**
* precompute subkernels of a combined kernel
*/
bool cmd_precompute_subkernels();
/** cmd signals model
*
*/
bool cmd_signals_set_model() { return false; };
/** cmd signals set position
*
*/
bool cmd_signals_set_positions();
/** cmd signals set labels
*
*/
bool cmd_signals_set_labels();
/** cmd signals set split
*
*/
bool cmd_signals_set_split();
/** cmd signals set train mask
*
*/
bool cmd_signals_set_train_mask();
/** cmd signals add feature
*
*/
bool cmd_signals_add_feature();
/** cmd signals add kernel
*
*/
bool cmd_signals_add_kernel();
/** cmd signals run
*
*/
bool cmd_signals_run();
/**
* -precompute content svms
* and save the outputs
* in a matrix with dim nof contents times
* nof feature positions
*
* -the SVM score for a specific segment can be
* calculated by subtraction the
* the start and end position entries
* from the row corresponding to the segment
* type
*/
bool cmd_precompute_content_svms();
/**
* -get lin feat
*/
bool cmd_get_lin_feat();
/**
* -set lin feat
*/
bool cmd_set_lin_feat();
/**
* -init dyn prog
*/
bool cmd_init_dyn_prog();
/**
* clean up dyn prog
*/
bool cmd_clean_up_dyn_prog();
/**
* initialize list of introns as DynProg features
*/
bool cmd_init_intron_list();
/** settings for long transition approximation*/
bool cmd_long_transition_settings();
/**
* -precompute tiling features
* and save the outputs (# content types x
* # features positons) in a member variable
* of the DynProg Object
* -the tiling intensities are transformed
* and then stored as cumulative scores
*/
bool cmd_precompute_tiling_features();
/**
* -compute the matrix that links
* the plif ids to the transitions
*
* -the matrix has dimensions nof states
* times nof states times nof feature types
*
* - feature types are for example
* signal features, length features,
* content features and tiling features
*/
bool cmd_set_model();
/**
* set sparse feature matrix and
* all feature positions
*/
bool cmd_set_feature_matrix_sparse();
/**
* set feature matrix and
* all feature positions
*/
bool cmd_set_feature_matrix();
/** best path trans */
bool cmd_best_path_trans();
/** best path trans deriv */
bool cmd_best_path_trans_deriv();
/** best path no b */
bool cmd_best_path_no_b();
/** best path no b trans */
bool cmd_best_path_no_b_trans();
/** calculate CRC sum */
bool cmd_crc();
/** send command to operating system */
bool cmd_system();
/** exit/quit shogun/interface */
bool cmd_exit();
/** execute script from file */
bool cmd_exec();
/** set output target */
bool cmd_set_output();
/** set threshold */
bool cmd_set_threshold();
/** initialize random number generator */
bool cmd_init_random();
/** set number of threads */
bool cmd_set_num_threads();
/** translate string */
bool cmd_translate_string();
/** clear Shogun */
bool cmd_clear();
/** start timer */
bool cmd_tic();
/** stop timer */
bool cmd_toc();
/** echo */
bool cmd_echo();
/** print a message (for e.g. cmdline interface) */
bool cmd_print();
/** set loglevel */
bool cmd_loglevel();
/** set progress */
bool cmd_progress();
/** en/disable syntax hilighting */
bool cmd_syntax_highlight();
/** get version */
bool cmd_get_version();
/** issue help message */
bool cmd_help();
/** list alloc'd memory */
bool cmd_whos();
/** wrapper for compatibility send_command */
bool cmd_send_command();
/** execute code under python from octave,... */
virtual bool cmd_run_python();
/** execute code under octave from python,... */
virtual bool cmd_run_octave();
/** execute code under r from python,... */
virtual bool cmd_run_r();
/** call pr_loqo solver */
virtual bool cmd_pr_loqo();
/** get functions - to pass data from the target interface to shogun */
/// get type of current argument (does not increment argument counter)
virtual IFType get_argument_type()=0;
/** get int */
virtual int32_t get_int()=0;
/** get real */
virtual float64_t get_real()=0;
/** get bool */
virtual bool get_bool()=0;
/** get string
* @param len
*/
virtual char* get_string(int32_t& len)=0;
/** get vector
* @param vector
* @param len
*/
virtual void get_vector(bool*& vector, int32_t& len);
/** get vector
* @param vector
* @param len
*/
virtual void get_vector(uint8_t*& vector, int32_t& len)=0;
/** get vector
* @param vector
* @param len
*/
virtual void get_vector(char*& vector, int32_t& len)=0;
/** get vector
* @param vector
* @param len
*/
virtual void get_vector(int32_t*& vector, int32_t& len)=0;
/** get vector
* @param vector
* @param len
*/
virtual void get_vector(float64_t*& vector, int32_t& len)=0;
/** get vector
* @param vector
* @param len
*/
virtual void get_vector(float32_t*& vector, int32_t& len)=0;
/** get vector
* @param vector
* @param len
*/
virtual void get_vector(int16_t*& vector, int32_t& len)=0;
/** get vector
* @param vector
* @param len
*/
virtual void get_vector(uint16_t*& vector, int32_t& len)=0;
/** get matrix
* @param matrix
* @param num_feat
* @param num_vec
*/
virtual void get_matrix(
uint8_t*& matrix, int32_t& num_feat, int32_t& num_vec)=0;
/** get matrix
* @param matrix
* @param num_feat
* @param num_vec
*/
virtual void get_matrix(
char*& matrix, int32_t& num_feat, int32_t& num_vec)=0;
/** get matrix
* @param matrix
* @param num_feat
* @param num_vec
*/
virtual void get_matrix(
int32_t*& matrix, int32_t& num_feat, int32_t& num_vec)=0;
/** get matrix
* @param matrix
* @param num_feat
* @param num_vec
*/
virtual void get_matrix(
float32_t*& matrix, int32_t& num_feat, int32_t& num_vec)=0;
/** get matrix
* @param matrix
* @param num_feat
* @param num_vec
*/
virtual void get_matrix(
float64_t*& matrix, int32_t& num_feat, int32_t& num_vec)=0;
/** get matrix
* @param matrix
* @param num_feat
* @param num_vec
*/
virtual void get_matrix(
int16_t*& matrix, int32_t& num_feat, int32_t& num_vec)=0;
/** get matrix
* @param matrix
* @param num_feat
* @param num_vec
*/
virtual void get_matrix(
uint16_t*& matrix, int32_t& num_feat, int32_t& num_vec)=0;
/** get nd array
* @param array
* @param dims
* @param num_dims
*/
virtual void get_ndarray(
uint8_t*& array, int32_t*& dims, int32_t& num_dims)=0;
/** get nd array
* @param array
* @param dims
* @param num_dims
*/
virtual void get_ndarray(
char*& array, int32_t*& dims, int32_t& num_dims)=0;
/** get nd array
* @param array
* @param dims
* @param num_dims
*/
virtual void get_ndarray(
int32_t*& array, int32_t*& dims, int32_t& num_dims)=0;
/** get nd array
* @param array
* @param dims
* @param num_dims
*/
virtual void get_ndarray(
float32_t*& array, int32_t*& dims, int32_t& num_dims)=0;
/** get nd array
* @param array
* @param dims
* @param num_dims
*/
virtual void get_ndarray(
float64_t*& array, int32_t*& dims, int32_t& num_dims)=0;
/** get nd array
* @param array
* @param dims
* @param num_dims
*/
virtual void get_ndarray(
int16_t*& array, int32_t*& dims, int32_t& num_dims)=0;
/** get nd array
* @param array
* @param dims
* @param num_dims
*/
virtual void get_ndarray(
uint16_t*& array, int32_t*& dims, int32_t& num_dims)=0;
/** get sparse matrix
* @param matrix
* @param num_feat
* @param num_vec
*/
virtual void get_sparse_matrix(
SGSparseVector<float64_t>*& matrix, int32_t& num_feat, int32_t& num_vec)=0;
/* future versions might support types other than float64_t
virtual void get_sparse_matrix(SGSparseVector<uint8_t>*& matrix, int32_t& num_feat, int32_t& num_vec)=0;
virtual void get_sparse_matrix(SGSparseVector<char>*& matrix, int32_t& num_feat, int32_t& num_vec)=0;
virtual void get_sparse_matrix(SGSparseVector<int32_t>*& matrix, int32_t& num_feat, int32_t& num_vec)=0;
virtual void get_sparse_matrix(SGSparseVector<float32_t>*& matrix, int32_t& num_feat, int32_t& num_vec)=0;
virtual void get_sparse_matrix(SGSparseVector<int16_t>*& matrix, int32_t& num_feat, int32_t& num_vec)=0;
virtual void get_sparse_matrix(SGSparseVector<uint16_t>*& matrix, int32_t& num_feat, int32_t& num_vec)=0; */
/** get string list
* @param strings
* @param num_str
* @param max_string_len
*/
virtual void get_string_list(
SGString<uint8_t>*& strings, int32_t& num_str,
int32_t& max_string_len)=0;
/** get string list
* @param strings
* @param num_str
* @param max_string_len
*/
virtual void get_string_list(
SGString<char>*& strings, int32_t& num_str,
int32_t& max_string_len)=0;
/** get string list
* @param strings
* @param num_str
* @param max_string_len
*/
virtual void get_string_list(
SGString<int32_t>*& strings, int32_t& num_str,
int32_t& max_string_len)=0;
/** get string list
* @param strings
* @param num_str
* @param max_string_len
*/
virtual void get_string_list(
SGString<int16_t>*& strings, int32_t& num_str,
int32_t& max_string_len)=0;
/** get string list
* @param strings
* @param num_str
* @param max_string_len
*/
virtual void get_string_list(
SGString<uint16_t>*& strings, int32_t& num_str,
int32_t& max_string_len)=0;
/** get attribute struct
* @param attrs
*/
virtual void get_attribute_struct(
const CDynamicArray<T_ATTRIBUTE>* &attrs)=0;
// set functions - to pass data from shogun to the target interface
/** create return values
* @param num_val
*/
virtual bool create_return_values(int32_t num_val)=0;
/** set int
* @param scalar
*/
virtual void set_int(int32_t scalar)=0;
/** set real
* @param scalar
*/
virtual void set_real(float64_t scalar)=0;
/** set bool
* @param scalar
*/
virtual void set_bool(bool scalar)=0;
/** set vector
* @param vector
* @param len
*/
virtual void set_vector(const bool* vector, int32_t len);
/** set vector
* @param vector
* @param len
*/
virtual void set_vector(const uint8_t* vector, int32_t len)=0;
/** set vector
* @param vector
* @param len
*/
virtual void set_vector(const char* vector, int32_t len)=0;
/** set vector
* @param vector
* @param len
*/
virtual void set_vector(const int32_t* vector, int32_t len)=0;
/** set vector
* @param vector
* @param len
*/
virtual void set_vector(const float32_t* vector, int32_t len)=0;
/** set vector
* @param vector
* @param len
*/
virtual void set_vector(const float64_t* vector, int32_t len)=0;
/** set vector
* @param vector
* @param len
*/
virtual void set_vector(const int16_t* vector, int32_t len)=0;
/** set vector
* @param vector
* @param len
*/
virtual void set_vector(const uint16_t* vector, int32_t len)=0;
/** set matrix
* @param matrix
* @param num_feat
* @param num_vec
*/
virtual void set_matrix(
const uint8_t* matrix, int32_t num_feat, int32_t num_vec)=0;
/** set matrix
* @param matrix
* @param num_feat
* @param num_vec
*/
virtual void set_matrix(
const char* matrix, int32_t num_feat, int32_t num_vec)=0;
/** set matrix
* @param matrix
* @param num_feat
* @param num_vec
*/
virtual void set_matrix(
const int32_t* matrix, int32_t num_feat, int32_t num_vec)=0;
/** set matrix
* @param matrix
* @param num_feat
* @param num_vec
*/
virtual void set_matrix(
const float32_t* matrix, int32_t num_feat, int32_t num_vec)=0;
/** set matrix
* @param matrix
* @param num_feat
* @param num_vec
*/
virtual void set_matrix(
const float64_t* matrix, int32_t num_feat, int32_t num_vec)=0;
/** set matrix
* @param matrix
* @param num_feat
* @param num_vec
*/
virtual void set_matrix(
const int16_t* matrix, int32_t num_feat, int32_t num_vec)=0;
/** set matrix
* @param matrix
* @param num_feat
* @param num_vec
*/
virtual void set_matrix(
const uint16_t* matrix, int32_t num_feat, int32_t num_vec)=0;
/** set sparse matrix
* @param matrix
* @param num_feat
* @param num_vec
* @param nnz
*/
virtual void set_sparse_matrix(
const SGSparseVector<float64_t>* matrix, int32_t num_feat,
int32_t num_vec, int64_t nnz)=0;
/* future versions might support types other than float64_t
virtual void set_sparse_matrix(const SGSparseVector<uint8_t>* matrix, int32_t num_feat, int32_t num_vec)=0;
virtual void set_sparse_matrix(const SGSparseVector<char>* matrix, int32_t num_feat, int32_t num_vec)=0;
virtual void set_sparse_matrix(const SGSparseVector<int32_t>* matrix, int32_t num_feat, int32_t num_vec)=0;
virtual void set_sparse_matrix(const SGSparseVector<float32_t>* matrix, int32_t num_feat, int32_t num_vec)=0;
virtual void set_sparse_matrix(const SGSparseVector<int16_t>* matrix, int32_t num_feat, int32_t num_vec)=0;
virtual void set_sparse_matrix(const SGSparseVector<uint16_t>* matrix, int32_t num_feat, int32_t num_vec)=0; */
/** set string list
* @param strings
* @param num_str
*/
virtual void set_string_list(
const SGString<uint8_t>* strings, int32_t num_str)=0;
/** set string list
* @param strings
* @param num_str
*/
virtual void set_string_list(
const SGString<char>* strings, int32_t num_str)=0;
/** set string list
* @param strings
* @param num_str
*/
virtual void set_string_list(
const SGString<int32_t>* strings, int32_t num_str)=0;
/** set string list
* @param strings
* @param num_str
*/
virtual void set_string_list(
const SGString<int16_t>* strings, int32_t num_str)=0;
/** set string list
* @param strings
* @param num_str
*/
virtual void set_string_list(
const SGString<uint16_t>* strings, int32_t num_str)=0;
/** set attribute struct
* @param attrs
*/
virtual void set_attribute_struct(
const CDynamicArray<T_ATTRIBUTE>* attrs)=0;
/// general interface handler
bool handle();
/// print the shogun prompt
void print_prompt();
/// return number of lhs args
int32_t get_nlhs() { return m_nlhs; }
/// return number of lhs args
int32_t get_nrhs() { return m_nrhs; }
// ui lib
/** ui classifier */
CGUIClassifier* ui_classifier;
/** ui distance */
CGUIDistance* ui_distance;
/** ui features */
CGUIFeatures* ui_features;
/** ui hmm */
CGUIHMM* ui_hmm;
/** ui kernel */
CGUIKernel* ui_kernel;
/** ui labels */
CGUILabels* ui_labels;
/** ui math */
CGUIMath* ui_math;
/** ui pluginestimate */
CGUIPluginEstimate* ui_pluginestimate;
/** ui preproc */
CGUIPreprocessor* ui_preproc;
/** ui time */
CGUITime* ui_time;
/** ui structure */
CGUIStructure* ui_structure;
/** ui_converter */
CGUIConverter* ui_converter;
protected:
/** return true if str starts with cmd
*
* @param str string to look in, not necessarily 0-terminated
* @param cmd 0-terminated string const
* @param len number of char to compare, length of cmd if not given
*
*/
static bool strmatch(const char* str, const char* cmd, int32_t len=-1)
{
if (len==-1)
{
len=strlen(cmd);
if (strlen(str)!=(size_t) len) // match exact length
return false;
}
return (strncmp(str, cmd, len)==0);
}
/** ends with
* @param str
* @param cmd
*/
static bool strendswith(const char* str, const char* cmd)
{
size_t idx=strlen(str);
size_t len=strlen(cmd);
if (strlen(str) < len)
return false;
str=&str[idx-len];
return (strncmp(str, cmd, len)==0);
}
/// get command name like 'get_svm', 'new_hmm', etc.
char* get_command(int32_t &len)
{
ASSERT(m_rhs_counter==0)
if (m_nrhs<=0)
SG_SERROR("No input arguments supplied.\n")
return get_string(len);
}
private:
/** helper function for computing objective */
bool do_compute_objective(E_WHICH_OBJ obj);
/** helper function for hmm classify */
bool do_hmm_classify(bool linear=false, bool one_class=false);
/** helper function for hmm classify on 1 example */
bool do_hmm_classify_example(bool one_class=false);
/** helper function for add/set features */
bool do_set_features(bool add=false, bool check_dot=false, int32_t repetitions=1);
/** perform bit embedding */
void convert_to_bitembedding(CFeatures* &features, bool convert_to_word, bool convert_to_ulong);
/** obtain from single string */
void obtain_from_single_string(CFeatures* features);
/** obtain from position list */
bool obtain_from_position_list(CFeatures* features);
/** obtain by sliding window */
bool obtain_by_sliding_window(CFeatures* features);
/** helper function to create a kernel */
CKernel* create_kernel();
/** helper function to create certain string features */
CFeatures* create_custom_string_features(CStringFeatures<uint8_t>* f);
CFeatures* create_custom_real_features(CDenseFeatures<float64_t>* orig_feat);
/** legacy-related stuff - anybody got a better idea? */
char* get_str_from_str_or_direct(int32_t& len);
int32_t get_int_from_int_or_str();
float64_t get_real_from_real_or_str();
bool get_bool_from_bool_or_str();
void get_vector_from_int_vector_or_str(
int32_t*& vector, int32_t& len);
void get_vector_from_real_vector_or_str(
float64_t*& vector, int32_t& len);
int32_t get_vector_len_from_str(int32_t expected_len=0);
char* get_str_from_str(int32_t& len);
int32_t get_num_args_in_str();
/// get line from user/stdin/file input
/// @return true at EOF
char* get_line(FILE* infile=stdin, bool show_prompt=true);
protected:
/** lhs counter */
int32_t m_lhs_counter;
/** rhs counter */
int32_t m_rhs_counter;
/** nlhs */
int32_t m_nlhs;
/** nrhs */
int32_t m_nrhs;
// related to cmd_exec and cmd_echo
/** file out */
FILE* file_out;
/** input */
char input[10000];
/** echo */
bool echo;
/** legacy strptr */
char* m_legacy_strptr;
};
/** sg interface ptr typedef */
typedef bool (CSGInterface::*CSGInterfacePtr)();
#ifndef DOXYGEN_SHOULD_SKIP_THIS
/** interface method */
typedef struct {
/// command
const char* command;
/// method
CSGInterfacePtr method;
/// usage prefix
const char* usage_prefix;
/// usage suffix
const char* usage_suffix;
} CSGInterfaceMethod;
}
#endif
#endif // __SGINTERFACE__H_
|