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) 2007-2009 Soeren Sonnenburg 00008 * Copyright (C) 2007-2009 Fraunhofer Institute FIRST and Max-Planck-Society 00009 */ 00010 00011 #ifndef _LPBOOST_H___ 00012 #define _LPBOOST_H___ 00013 00014 #include <shogun/lib/config.h> 00015 #ifdef USE_CPLEX 00016 00017 #include <stdio.h> 00018 #include <shogun/lib/common.h> 00019 #include <shogun/lib/DynamicArray.h> 00020 00021 #include <shogun/features/Features.h> 00022 #include <shogun/features/SparseFeatures.h> 00023 #include <shogun/machine/LinearMachine.h> 00024 00025 namespace shogun 00026 { 00048 class CLPBoost : public CLinearMachine 00049 { 00050 public: 00051 MACHINE_PROBLEM_TYPE(PT_BINARY); 00052 00053 CLPBoost(); 00054 virtual ~CLPBoost(); 00055 00056 virtual EMachineType get_classifier_type() 00057 { 00058 return CT_LPBOOST; 00059 } 00060 00061 bool init(int32_t num_vec); 00062 void cleanup(); 00063 00068 virtual void set_features(CDotFeatures* feat) 00069 { 00070 if (feat->get_feature_class() != C_SPARSE || 00071 feat->get_feature_type() != F_DREAL) 00072 SG_ERROR("LPBoost requires SPARSE REAL valued features\n"); 00073 00074 CLinearMachine::set_features(feat); 00075 } 00076 00083 inline void set_C(float64_t c_neg, float64_t c_pos) { C1=c_neg; C2=c_pos; } 00084 00085 inline float64_t get_C1() { return C1; } 00086 inline float64_t get_C2() { return C2; } 00087 00088 inline void set_bias_enabled(bool enable_bias) { use_bias=enable_bias; } 00089 inline bool get_bias_enabled() { return use_bias; } 00090 00091 inline void set_epsilon(float64_t eps) { epsilon=eps; } 00092 inline float64_t get_epsilon() { return epsilon; } 00093 00094 float64_t find_max_violator(int32_t& max_dim); 00095 00097 virtual const char* get_name() const { return "LPBoost"; } 00098 00099 protected: 00108 virtual bool train_machine(CFeatures* data=NULL); 00109 00110 protected: 00111 float64_t C1; 00112 float64_t C2; 00113 bool use_bias; 00114 float64_t epsilon; 00115 00116 float64_t* u; 00117 CDynamicArray<int32_t>* dim; 00118 00119 int32_t num_sfeat; 00120 int32_t num_svec; 00121 SGSparseVector<float64_t>* sfeat; 00122 00123 }; 00124 } 00125 #endif //USE_CPLEX 00126 #endif //_LPBOOST_H___