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 _LDA_H___ 00012 #define _LDA_H___ 00013 00014 #include "lib/config.h" 00015 00016 #ifdef HAVE_LAPACK 00017 #include "lib/common.h" 00018 #include "features/Features.h" 00019 #include "features/SimpleFeatures.h" 00020 #include "classifier/LinearClassifier.h" 00021 00022 namespace shogun 00023 { 00024 template <class ST> class CSimpleFeatures; 00052 class CLDA : public CLinearClassifier 00053 { 00054 public: 00059 CLDA(float64_t gamma=0); 00060 00067 CLDA(float64_t gamma, CSimpleFeatures<float64_t>* traindat, CLabels* trainlab); 00068 virtual ~CLDA(); 00069 00074 inline void set_gamma(float64_t gamma) 00075 { 00076 m_gamma=gamma; 00077 } 00078 00083 inline float64_t get_gamma() 00084 { 00085 return m_gamma; 00086 } 00087 00096 virtual bool train(CFeatures* data=NULL); 00097 00102 inline virtual EClassifierType get_classifier_type() 00103 { 00104 return CT_LDA; 00105 } 00106 00111 virtual inline void set_features(CDotFeatures* feat) 00112 { 00113 if (feat->get_feature_class() != C_SIMPLE || 00114 feat->get_feature_type() != F_DREAL) 00115 SG_ERROR("LDA requires SIMPLE REAL valued features\n"); 00116 00117 CLinearClassifier::set_features(feat); 00118 } 00119 00121 inline virtual const char* get_name() const { return "LDA"; } 00122 00123 protected: 00125 float64_t m_gamma; 00126 }; 00127 } 00128 #endif 00129 #endif