SHOGUN
v2.0.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 * Copyright (C) 2012 Evgeniy Andreev (gsomix) 00008 */ 00009 00010 #ifndef _DIRECTORLINEARMACHINE_H___ 00011 #define _DIRECTORLINEARMACHINE_H___ 00012 00013 #ifdef USE_SWIG_DIRECTORS 00014 #include <shogun/lib/common.h> 00015 #include <shogun/lib/DataType.h> 00016 #include <shogun/machine/Machine.h> 00017 #include <shogun/machine/LinearMachine.h> 00018 00019 namespace shogun 00020 { 00021 00022 #define IGNORE_IN_CLASSLIST 00023 IGNORE_IN_CLASSLIST class CDirectorLinearMachine : public CLinearMachine 00024 { 00025 public: 00026 /* default constructor */ 00027 CDirectorLinearMachine() 00028 : CLinearMachine() 00029 { 00030 00031 } 00032 00033 /* destructor */ 00034 virtual ~CDirectorLinearMachine() 00035 { 00036 00037 } 00038 00048 virtual bool train(CFeatures* data=NULL) 00049 { 00050 return CLinearMachine::train(data); 00051 } 00052 00053 virtual bool train_function(CFeatures* data=NULL) 00054 { 00055 SG_ERROR("Train function of Director Linear Machine needs to be overridden.\n"); 00056 return false; 00057 } 00058 00063 virtual inline void set_features(CDotFeatures* feat) 00064 { 00065 CLinearMachine::set_features(feat); 00066 } 00067 00072 virtual CDotFeatures* get_features() 00073 { 00074 CLinearMachine::get_features(); 00075 } 00076 00083 virtual CLabels* apply(CFeatures* data=NULL) 00084 { 00085 return CLinearMachine::apply(data); 00086 } 00087 00089 virtual CBinaryLabels* apply_binary(CFeatures* data=NULL) 00090 { 00091 return CLinearMachine::apply_binary(data); 00092 } 00093 00095 virtual CRegressionLabels* apply_regression(CFeatures* data=NULL) 00096 { 00097 return CLinearMachine::apply_regression(data); 00098 } 00099 00101 using CLinearMachine::apply_multiclass; 00102 00103 virtual float64_t apply_one(int32_t vec_idx) 00104 { 00105 return CLinearMachine::apply_one(vec_idx); 00106 } 00107 00112 virtual void set_labels(CLabels* lab) 00113 { 00114 CLinearMachine::set_labels(lab); 00115 } 00116 00121 virtual CLabels* get_labels() 00122 { 00123 return CLinearMachine::get_labels(); 00124 } 00125 00130 virtual EMachineType get_classifier_type() { return CT_DIRECTORLINEAR; } 00131 00137 virtual void set_store_model_features(bool store_model) 00138 { 00139 CLinearMachine::set_store_model_features(store_model); 00140 } 00141 00150 virtual bool train_locked(SGVector<index_t> indices) 00151 { 00152 return CLinearMachine::train_locked(indices); 00153 } 00154 00160 virtual CLabels* apply_locked(SGVector<index_t> indices) 00161 { 00162 return CLinearMachine::apply_locked(indices); 00163 } 00164 00165 virtual CBinaryLabels* apply_locked_binary(SGVector<index_t> indices) 00166 { 00167 return CLinearMachine::apply_locked_binary(indices); 00168 } 00169 00170 virtual CRegressionLabels* apply_locked_regression( 00171 SGVector<index_t> indices) 00172 { 00173 return CLinearMachine::apply_locked_regression(indices); 00174 } 00175 00176 using CLinearMachine::apply_locked_multiclass; 00177 00186 virtual void data_lock(CLabels* labs, CFeatures* features) 00187 { 00188 CLinearMachine::data_lock(labs, features); 00189 } 00190 00192 virtual void data_unlock() 00193 { 00194 CLinearMachine::data_unlock(); 00195 } 00196 00198 virtual bool supports_locking() const 00199 { 00200 return CLinearMachine::supports_locking(); 00201 } 00202 00203 //TODO change to pure virtual 00204 inline virtual EProblemType get_machine_problem_type() const 00205 { 00206 return CLinearMachine::get_machine_problem_type(); 00207 } 00208 00209 virtual const char* get_name() const { return "DirectorLinearMachine"; } 00210 00211 protected: 00222 virtual bool train_machine(CFeatures* data=NULL) 00223 { 00224 return train_function(data); 00225 } 00226 }; 00227 00228 } 00229 00230 #endif /* USE_SWIG_DIRECTORS */ 00231 #endif /* _DIRECTORLINEARMACHINE_H___ */