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-2009 Soeren Sonnenburg 00008 * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society 00009 */ 00010 00011 #ifndef _LIBLINEAR_H___ 00012 #define _LIBLINEAR_H___ 00013 00014 #include "lib/config.h" 00015 00016 #ifdef HAVE_LAPACK 00017 #include "lib/common.h" 00018 #include "classifier/LinearClassifier.h" 00019 00020 namespace shogun 00021 { 00022 enum LIBLINEAR_LOSS 00023 { 00024 LR = 0, 00025 L2 = 1 00026 }; 00027 00029 class CLibLinear : public CLinearClassifier 00030 { 00031 public: 00036 CLibLinear(LIBLINEAR_LOSS loss); 00037 00044 CLibLinear( 00045 float64_t C, CDotFeatures* traindat, 00046 CLabels* trainlab); 00047 00048 virtual ~CLibLinear(); 00049 00058 virtual bool train(CFeatures* data=NULL); 00059 00064 virtual inline EClassifierType get_classifier_type() { return CT_LIBLINEAR; } 00065 00071 inline void set_C(float64_t c1, float64_t c2) { C1=c1; C2=c2; } 00072 00077 inline float64_t get_C1() { return C1; } 00078 00083 inline float64_t get_C2() { return C2; } 00084 00089 inline void set_epsilon(float64_t eps) { epsilon=eps; } 00090 00095 inline float64_t get_epsilon() { return epsilon; } 00096 00101 inline void set_bias_enabled(bool enable_bias) { use_bias=enable_bias; } 00102 00107 inline bool get_bias_enabled() { return use_bias; } 00108 00110 inline virtual const char* get_name() const { return "LibLinear"; } 00111 00112 protected: 00114 float64_t C1; 00116 float64_t C2; 00118 bool use_bias; 00120 float64_t epsilon; 00121 00123 LIBLINEAR_LOSS loss; 00124 }; 00125 } 00126 #endif //HAVE_LAPACK 00127 #endif //_LIBLINEAR_H___