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 <shogun/lib/config.h> 00015 00016 #ifdef HAVE_LAPACK 00017 #include <shogun/lib/common.h> 00018 #include <shogun/features/Features.h> 00019 #include <shogun/features/SimpleFeatures.h> 00020 #include <shogun/machine/LinearMachine.h> 00021 00022 namespace shogun 00023 { 00024 template <class ST> class CSimpleFeatures; 00052 class CLDA : public CLinearMachine 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 00092 inline virtual EClassifierType get_classifier_type() 00093 { 00094 return CT_LDA; 00095 } 00096 00101 virtual inline void set_features(CDotFeatures* feat) 00102 { 00103 if (feat->get_feature_class() != C_SIMPLE || 00104 feat->get_feature_type() != F_DREAL) 00105 SG_ERROR("LDA requires SIMPLE REAL valued features\n"); 00106 00107 CLinearMachine::set_features(feat); 00108 } 00109 00111 inline virtual const char* get_name() const { return "LDA"; } 00112 00113 protected: 00122 virtual bool train_machine(CFeatures* data=NULL); 00123 00124 protected: 00126 float64_t m_gamma; 00127 }; 00128 } 00129 #endif 00130 #endif