SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LPM.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2007-2009 Soeren Sonnenburg
8  * Copyright (C) 2007-2009 Fraunhofer Institute FIRST and Max-Planck-Society
9  */
10 
11 #ifndef _LPM_H___
12 #define _LPM_H___
13 
14 #include <shogun/lib/config.h>
15 #ifdef USE_CPLEX
16 
17 #include <stdio.h>
18 #include <shogun/lib/common.h>
21 
22 namespace shogun
23 {
43 class CLPM : public CLinearClassifier
44 {
45  public:
46  CLPM();
47  virtual ~CLPM();
48 
50  {
51  return CT_LPM;
52  }
53 
58  virtual inline void set_features(CDotFeatures* feat)
59  {
60  if (feat->get_feature_class() != C_SPARSE ||
61  feat->get_feature_type() != F_DREAL)
62  SG_ERROR("LPM requires SPARSE REAL valued features\n");
63 
64  CLinearClassifier::set_features(feat);
65  }
66 
73  inline void set_C(float64_t c_neg, float64_t c_pos) { C1=c_neg; C2=c_pos; }
74 
75  inline float64_t get_C1() { return C1; }
76  inline float64_t get_C2() { return C2; }
77 
78  inline void set_bias_enabled(bool enable_bias) { use_bias=enable_bias; }
79  inline bool get_bias_enabled() { return use_bias; }
80 
81  inline void set_epsilon(float64_t eps) { epsilon=eps; }
82  inline float64_t get_epsilon() { return epsilon; }
83 
85  inline virtual const char* get_name() const { return "LPM"; }
86 
87  protected:
96  virtual bool train_machine(CFeatures* data=NULL);
97 
98  protected:
101  bool use_bias;
103 };
104 }
105 #endif //USE_CPLEX
106 #endif //_LPM_H___
virtual EFeatureType get_feature_type()=0
EClassifierType
Definition: Machine.h:27
Class LPM trains a linear classifier called Linear Programming Machine, i.e. a SVM using a norm regu...
Definition: LPM.h:43
#define SG_ERROR(...)
Definition: SGIO.h:75
virtual void set_features(CDotFeatures *feat)
Definition: LPM.h:58
Features that support dot products among other operations.
Definition: DotFeatures.h:41
float64_t get_epsilon()
Definition: LPM.h:82
virtual const char * get_name() const
Definition: LPM.h:85
virtual ~CLPM()
Definition: LPM.cpp:28
virtual EFeatureClass get_feature_class()=0
double float64_t
Definition: common.h:56
float64_t C2
Definition: LPM.h:100
virtual bool train_machine(CFeatures *data=NULL)
Definition: LPM.cpp:32
float64_t get_C2()
Definition: LPM.h:76
void set_bias_enabled(bool enable_bias)
Definition: LPM.h:78
bool get_bias_enabled()
Definition: LPM.h:79
The class Features is the base class of all feature objects.
Definition: Features.h:56
virtual EClassifierType get_classifier_type()
Definition: LPM.h:49
float64_t get_C1()
Definition: LPM.h:75
float64_t epsilon
Definition: LPM.h:102
void set_epsilon(float64_t eps)
Definition: LPM.h:81
void set_C(float64_t c_neg, float64_t c_pos)
Definition: LPM.h:73
float64_t C1
Definition: LPM.h:99
bool use_bias
Definition: LPM.h:101

SHOGUN Machine Learning Toolbox - Documentation