LPBoost.h

Go to the documentation of this file.
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 "lib/config.h"
00015 #ifdef USE_CPLEX
00016 
00017 #include <stdio.h>
00018 #include "lib/common.h"
00019 #include "lib/DynamicArray.h"
00020 
00021 #include "features/Features.h"
00022 #include "features/SparseFeatures.h"
00023 #include "classifier/LinearClassifier.h"
00024 
00025 namespace shogun
00026 {
00048 class CLPBoost : public CLinearClassifier
00049 {
00050     public:
00051         CLPBoost();
00052         virtual ~CLPBoost();
00053 
00062         virtual bool train(CFeatures* data=NULL);
00063 
00064         inline virtual EClassifierType get_classifier_type()
00065         {
00066             return CT_LPBOOST;
00067         }
00068 
00069         bool init(int32_t num_vec);
00070         void cleanup();
00071 
00076         virtual inline void set_features(CDotFeatures* feat)
00077         {
00078             if (feat->get_feature_class() != C_SPARSE ||
00079                 feat->get_feature_type() != F_DREAL)
00080                 SG_ERROR("LPBoost requires SPARSE REAL valued features\n");
00081 
00082             CLinearClassifier::set_features(feat);
00083         }
00084 
00085         inline void set_C(float64_t c1, float64_t c2) { C1=c1; C2=c2; }
00086 
00087         inline float64_t get_C1() { return C1; }
00088         inline float64_t get_C2() { return C2; }
00089 
00090         inline void set_bias_enabled(bool enable_bias) { use_bias=enable_bias; }
00091         inline bool get_bias_enabled() { return use_bias; }
00092 
00093         inline void set_epsilon(float64_t eps) { epsilon=eps; }
00094         inline float64_t get_epsilon() { return epsilon; }
00095 
00096         float64_t find_max_violator(int32_t& max_dim);
00097 
00099         inline virtual const char* get_name() const { return "LPBoost"; }
00100 
00101     protected:
00102         float64_t C1;
00103         float64_t C2;
00104         bool use_bias;
00105         float64_t epsilon;
00106 
00107         float64_t* u;
00108         CDynamicArray<int32_t>* dim;
00109 
00110         int32_t num_sfeat;
00111         int32_t num_svec;
00112         TSparse<float64_t>* sfeat;
00113 
00114 };
00115 }
00116 #endif //USE_CPLEX
00117 #endif //_LPBOOST_H___

SHOGUN Machine Learning Toolbox - Documentation