SHOGUN
v3.2.0
|
00001 /* 00002 * This program is free software; you can redistribute it and/or modify 00003 * it under the terms of the GNU General Public License as published by 00004 * the Free Software Foundation; either version 3 of the License, or 00005 * (at your option) any later version. 00006 * 00007 * Written (W) 1999-2008 Soeren Sonnenburg 00008 * Copyright (C) 1999-2008 Fraunhofer Institute FIRST and Max-Planck-Society 00009 */ 00010 00011 #ifndef _GUICLASSIFIER_H__ 00012 #define _GUICLASSIFIER_H__ 00013 00014 #include <shogun/lib/config.h> 00015 #include <shogun/base/SGObject.h> 00016 #include <shogun/machine/Machine.h> 00017 #include <shogun/classifier/svm/SVM.h> 00018 00019 namespace shogun 00020 { 00021 class CSGInterface; 00022 00024 class CGUIClassifier : public CSGObject 00025 { 00026 public: 00028 CGUIClassifier() { }; 00032 CGUIClassifier(CSGInterface* interface); 00034 ~CGUIClassifier(); 00035 00037 bool new_classifier(char* name, int32_t d=6, int32_t from_d=40); 00039 bool set_max_train_time(float64_t max); 00041 bool load(char* filename, char* type); 00045 bool save(char* param); 00047 CLabels* classify(); 00049 CLabels* classify_kernelmachine(); 00051 CLabels* classify_distancemachine(); 00053 CLabels* classify_linear(); 00055 CLabels* classify_byte_linear(); 00060 bool classify_example(int32_t idx, float64_t& result); 00062 inline CMachine* get_classifier() { return classifier; } 00063 00073 bool get_trained_classifier( 00074 float64_t* &weights, int32_t& rows, int32_t& cols, 00075 float64_t*& bias, int32_t& brows, int32_t& bcols, 00076 int32_t idx=-1); // which SVM in Multiclass 00077 00079 int32_t get_num_svms(); 00089 bool get_svm( 00090 float64_t* &weights, int32_t& rows, int32_t& cols, 00091 float64_t*& bias, int32_t& brows, int32_t& bcols, 00092 int32_t idx=-1); // which SVM in Multiclass 00101 bool get_linear( 00102 float64_t* &weights, int32_t& rows, int32_t& cols, 00103 float64_t*& bias, int32_t& brows, int32_t& bcols); 00112 bool get_clustering( 00113 float64_t* &weights, int32_t& rows, int32_t& cols, 00114 float64_t*& bias, int32_t& brows, int32_t& bcols); 00115 00116 // perceptron learnrate & maxiter 00121 bool set_perceptron_parameters(float64_t lernrate, int32_t maxiter); 00122 00123 // SVM functions 00128 bool set_svm_C(float64_t C1, float64_t C2); 00132 bool set_svm_bufsize(int32_t bufsize); 00136 bool set_svm_qpsize(int32_t qpsize); 00140 bool set_svm_max_qpsize(int32_t max_qpsize); 00144 bool set_svm_shrinking_enabled(bool enabled); 00148 bool set_svm_nu(float64_t nu); 00152 bool set_svm_batch_computation_enabled(bool enabled); 00156 bool set_do_auc_maximization(bool do_auc); 00160 bool set_svm_linadd_enabled(bool enabled); 00164 bool set_svm_bias_enabled(bool enabled); 00168 bool set_mkl_interleaved_enabled(bool enabled); 00172 bool set_svm_epsilon(float64_t epsilon); 00176 bool set_svr_tube_epsilon(float64_t tube_epsilon); 00182 bool set_svm_mkl_parameters( 00183 float64_t weight_epsilon, float64_t C_mkl, float64_t mkl_norm); 00187 bool set_mkl_block_norm(float64_t mkl_bnorm); 00191 bool set_elasticnet_lambda(float64_t lambda); 00195 bool set_svm_precompute_enabled(int32_t precompute); 00196 00198 bool set_krr_tau(float64_t tau=1); 00200 bool set_solver(char* solver); 00202 bool set_constraint_generator(char* cg); 00203 00205 bool train_mkl_multiclass(); 00207 bool train_mkl(); 00209 bool train_svm(); 00211 bool train_knn(int32_t k=3); 00213 bool train_krr(); 00215 bool train_clustering(int32_t k=3, int32_t max_iter=1000); 00219 bool train_linear(float64_t gamma=0); 00221 bool train_sparse_linear(); 00223 bool train_wdocas(); 00224 00226 virtual const char* get_name() const { return "GUIClassifier"; } 00227 00228 protected: 00230 CSGInterface* ui; 00232 CMachine* classifier; 00234 float64_t max_train_time; 00236 float64_t perceptron_learnrate; 00238 int32_t perceptron_maxiter; 00240 int32_t svm_qpsize; 00242 int32_t svm_bufsize; 00244 int32_t svm_max_qpsize; 00246 float64_t mkl_norm; 00248 float64_t mkl_block_norm; 00250 float64_t ent_lambda; 00252 float64_t svm_weight_epsilon; 00254 float64_t svm_epsilon; 00256 float64_t svm_tube_epsilon; 00258 float64_t svm_nu; 00260 float64_t svm_C1; 00262 float64_t svm_C2; 00264 float64_t C_mkl; 00266 float64_t krr_tau; 00268 bool mkl_use_interleaved; 00270 bool svm_use_bias; 00272 bool svm_use_batch_computation; 00274 bool svm_use_linadd; 00276 bool svm_use_precompute; 00278 bool svm_use_precompute_subkernel; 00280 bool svm_use_precompute_subkernel_light; 00282 bool svm_use_shrinking; 00284 bool svm_do_auc_maximization; 00285 00287 CSVM* constraint_generator; 00289 ESolverType solver_type; 00290 }; 00291 } 00292 #endif